3.安装php
[root@lly ~]# tar -zxvf php-5.4.3.tar.gz -C /usr/local/src/
[root@lly ~]# cd /usr/local/src/php-5.4.3/
[root@lly php-5.4.3]# ./configure --prefix=/usr/local/php --sysconfdir=/etc --with-apxs2=/usr/local/apache/bin/apxs --with-zlib --with-gd --with-jpeg-dir --with-png-dir --enable-mbstring --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-xml --with-freetype-dir
[root@lly php-5.4.3]# make && make install
[root@lly php-5.4.3]# cd /usr/local/php/
[root@lly php]# vim /etc/profile
[root@lly php]# vim /etc/ld.so.conf.d/php.conf
写入
/usr/local/mysql/lib
[root@lly php]# ldconfig
[root@lly php]# ln -s include /usr/include/php
[root@lly php]# vim /etc/httpd/httpd.conf
在apache的配置文件中会自动添加modules/libphp5.so模块
[root@lly ~]# service httpd restart重启apache
注意:若出现如下错误,可能是是Linux有一个SELinux保护模式引起的
starting apache......httpd: Syntax error on line 147 of /etc/httpd/httpd.conf: Cannot load modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
Fail
可以进行如下操作
1关闭SELINUX的方法:
vi /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disabled
需要重启
这个方法可能会对服务器带来风险。
2不关闭SELINUX的方法:
# setenforce 0
# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so
# service httpd restart
# setenforce 1
[root@lly ~]# cd /usr/local/apache/htdocs apache的默认站点目录