Linux上安装Mysql+Apache+Php

时间:2022-09-01 08:14:22

一、安装Mysql

1、卸载默认的mysql

yum -y remove mysql-libs-*

Removed:
  mysql-libs.x86_64 0:5.1.73-3.el6_5

卸载成功

2、上传四个文件,然后rpm

rpm -ivh MySQL-server-5.6.-.el6.x86_64.rpm
rpm -ivh MySQL-client-5.6.-.el6.x86_64.rpm
rpm -ivh MySQL-devel-5.6.-.el6.x86_64.rpm
rpm -ivh MySQL-shared-5.6.-.el6.x86_64.rpm

说明:如果第一步没有卸载,会出现包冲突

出现问题一:
file /usr/share/man/man1/mysqlshow.1.gz from install of MySQL-client-4.1.16-1.glibc23
conflicts with file from package mysql-3.23.54a-11----------------------------------------------------------解决方案:卸载软件原因有包冲突。解决冲突: 
yum -y remove mysql-libs-*
yum -y remove mysql-libs-5.1.61*        -y的意思就是不用询问是否remove
卸载完成之后,再安装MySQL成功了

3、开启Mysql

/etc/init.d/mysql start 

4、

第一次如何登陆mysql呢
1、su命令【root用户就不需要了】
2、/etc/init.d/mysql start 开启mysql
3、mysql -uroot -p
在这个目录下找密码/root/.mysql_secret
cd /root
ls -la
cat .mysql_secret 复制密码【复制粘贴即可】

5、修改密码

set password=password('admin');

6、其他问题

其他问题:

/etc/init.d/mysql stop
/etc/init.d/mysql start 开启mysql
查看一下这个目录cd /etc/rc.d/init.d/
查看mysql启动状态/etc/rc.d/init.d/mysql status

第二部分:安装apache

1、上传对应的文件

tar zxvf httpd-2.2.27.tar.gz 
2、  cd httpd-2.2.27
3、  ./configure --prefix=/usr/local/apache2 --enable-dav --enable-modules=so
4、 make
5、  make install

-----------------------------------

make[1]: Leaving directory `/usr/local/httpd-2.2.27' 代表OK

6、启动apache

/usr/local/apache2/bin/apachectl start

出现错误:

httpd: apr_sockaddr_info_get() failed for VM_74_204_centos
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

-------------------------------

解决方案:

在Apache的安装目录下的hhtpd。conf文件修改如下【  cd apache2/conf  ls一下】
   (1) ServerName localhost:80

第三部分:安装php

安装前要准备安装libxml2, 上传百度云这个文件到usr/local

1 tar zxvf libxml2-2.6.32.tar.gz
2 cd libxml2-2.6.32
3 ./configure --prefix=/usr/local/libxml2
4 make
5 make install

安装Php

1、tar zxvf php-5.3.28.tar.gz 
 2、 cd php-5.3.28
 3、 ./configure --prefix=/usr/local/php --with-mysqli=/usr/bin/mysql_config --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml-dir=/usr/local/libxml2

+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

出现这个,成功安装php

------------------------

继续:
4、make 
5、make install

----------------------

输入IP地址

http://182.92.227.100/ 出现itworks 就代表成功了【其实Apache第二步开启了,就可以测试是否成功了】

这一篇安装过程讲到这

下一篇文章为他们的配置问题。

Apache支持php,php加载mysql的文章