首页 > 代码库 > linux 配置 Apache mysql php最新版

linux 配置 Apache mysql php最新版

第一部分:安装mysql

官方下载 mysql5.6.19 64位的rpm格式文件

0、rpm 四个mysql5.6.19

卸载默认的mysql 

yum -y remove mysql-libs-*

 yum -y remove mysql-libs-5.1.52* 

1、su命令
2、/etc/init.d/mysql start 开启mysql
3、mysql -uroot -p

出现错误:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)

------------------------------------
解决方案:
在这个目录下找密码/root/.mysql_secret
cd /root
ls -la
cat .mysql_secret 复制密码
4、查看mysql启动状态/etc/rc.d/init.d/mysql status

登陆进去重新设置密码
set password=password(‘admin‘); 

第二部分:安装apache

1、

# tar zxvf httpd-2.2.11.tar.gz

# ./configure --prefix=/usr/local/apache2 --enable-dav --enable-modules=so

./configure  --prefix=/usr/local/apache  --enable-so【这个也行】

make

make install

一般出现这个-bash: make: command not found提示,是因为安装系统的时候使用的是最小化mini安装,系统没有安装make、vim等常用命令,直接yum安装下即可。

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

解决方案: 

yum -y install gcc automake autoconf libtool make
 
直接ssh运行即可,安装make。
 

启动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的安装目录下的conf文件修改如下
   (1) ServerName localhost:80                       

   或者在 /etc/hosts 中填入自己的主机名称 bogon,如下:
   (2)127.0.0.1 bogon
---------------------------------------------

 

/usr/local/apache2/modules/libphp5.so: cannot open shared object file: No such file or directory

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

解决方案:Apache 安装目录http。conf文件增加这一行

LoadModule php5_module       /usr/local/apache2/modules/libphp5.so

还是/usr/local/apache2/modules/libphp5.so: cannot open shared object file: No such file or directory 错误,那就先装php吧 

 

第三部分:安装php

安装libxml2

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 zvxf php-5.3.8.tar.gz
2、cd php-5.3.8
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

出现错误

configure: error: xml2-config not found. Please check your libxml2 installation.

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

解决方案:http://www.cnblogs.com/happyhotty/articles/2539864.html

【检查是否安装了libxm包

[root@XKWB3403 php-5.3.8]# rpm -qa |grep  libxml2
libxml2-2.6.26-2.1.12
libxml2-python-2.6.26-2.1.12 

重新安装libxml2和libxml2-devel包

yum install libxml2

yum install libxml2-devel -y 

安装完之后查找xml2-config文件是否存在

[root@XKWB3403 php-5.3.8]# find / -name "xml2-config"

/usr/bin/xml2-config

然后再重新 config

+--------------------------------------------------------------------+
| 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

 然后再

make  make install

出现这个

[PEAR] Console_Getopt - installed: 1.3.1
warning: pear/PEAR requires package "pear/Structures_Graph" (recommended version 1.0.4)
warning: pear/PEAR requires package "pear/XML_Util" (recommended version 1.2.1)
[PEAR] PEAR           - installed: 1.9.4
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util       - installed: 1.2.1
/usr/local/php-5.3.28/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f /usr/local/php/bin/phar.phar /usr/local/php/bin/phar
Installing PDO headers:          /usr/local/php/include/php/ext/pdo/

安装成功了

 

 

 

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

最后 php链接php还是不成功。原因解决方案:

cp 一个php.ini 到 /usr/local/php/lib 【cp /usr/local/php-5.3.28/php.ini-production /usr/local/php/lib/php.ini 或者直接操作复制过去那个文件 】

extension=mysql.so

php。ini里面 去掉分号,加上面这个链接。重启Apache即可

 

./configure --with-php-config=/usr/local/bin/php-config

ln -s /usr/lib64/mysql/libmysqlclient.a /usr/lib/libmysqlclient.a 
ln -s /usr/lib64/mysql/libmysqlclient_r.a /usr/lib/libmysqlclient_r.a
 )
参考网站:http://www.cnblogs.com/wangtao_20/archive/2011/03/07/1973621.html
 
--------------------------------------------------------
具体的说,如下:
是解决php与mysql连接的问题,
步骤大致是:
a、进入php目录下ext下mysql下
b、/usr/local/php/bin/phpize
c、./configure --with-php-config=/usr/local/bin/php-config

tip:若configure不成功,则进行下列操作:

ln -s /usr/lib64/mysql/libmysqlclient.a /usr/lib/libmysqlclient.a 
ln -s /usr/lib64/mysql/libmysqlclient_r.a /usr/lib/libmysqlclient_r.a
 )

d、make
e、make install
f、配置mysql.so