CentOS 6.3编译安装LAMP环境笔记

2019-10-14 12:38:20王旭

--------------- 
# chkconfig --add httpd
# chkconfig httpd on
# service httpd restart

6).修改log日志格式实现每天保存.

#vi /usr/local/apache2/conf/httpd.conf
找到CustomLog和ErrorLog行,注释掉修改为以下参数
--------------------------------
CustomLog "|/usr/local/apache2/bin/rotatelogs /usr/local/apache2/logs/%Y_%m_%d.access_log 86400 480" combined
ErrorLog "|/usr/local/apache2/bin/rotatelogs /usr/local/apache2/logs/%Y_%m_%d.error_log 86400 480"
---------------------------------

7).修改apache权限:

# vi /usr/local/apache2/conf/httpd.conf
------------------
User www
Group www
------------------

注:这里其实就相当于用户执行WEB浏览会触发httpd进程,该进程由于属主属组都为www,所以对属主属组为www的目录都有读写权限,当然前提你的目录u=r+w+x,这样就保证开发人员在执行PHP语句时能对项目目录下的文件具有读写权限,避免运维人员手动对需要读写的子目录再设置777权限,保证项目顺利实施.

五.安装php模块

1.处理依赖包

暂无..

2.安装PHP

# wget http://cn2.php.net/distributions/php-5.4.13.tar.bz2
# tar -jxvf php-5.4.13.tar.bz2
# cd php-5.4.13

此处编译安装了我们项目经常用到的PHP模块,如有其它需要可以自定义添加.

# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml-dir=/usr/local/lib --with-zlib-dir=/usr/local/lib --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd --enable-soap --enable-sockets  --enable-xml --enable-mbstring --with-png-dir=/usr/local --with-jpeg-dir=/usr/local --with-curl=/usr/lib --with-freetype-dir=/usr/include/freetype2/freetype/ --enable-bcmath --enable-calendar --enable-zip --enable-maintainer-zts
# 注:其中最后一个参数--enable-maintainer-zts在安装PHP5.4最新版本时必须添加(5.3貌似不需要),表示打开PHP进程安全Thread Safe,默认不添加为NON Thread Safe,开启apache服务会报错.....(此处被坑了一下午...#$%^&*)
# make
# make install

安装结束后:

添加php配置文件,需要CP一个源码里面的php.ini-development或php.ini-production  到/usr/local/php/lib为php.ini
#cd ~/php-5.4.13
#cp php.ini-development /usr/local/php5/lib/php.ini

 
3.配置APACHE的PHP模块:

编辑Apache配置文件,
# vi /usr/local/apache2/conf/httpd.conf
并添加以下一行:
--------------------------------------------
AddType application/x-httpd-php .php
--------------------------------------------

并在 DirectoryIndex 一行后面加上 index.php
如果PHP无法加载,检查httpd.conf配置下是否有该行配置(默认安装PHP后会自动将该行写入)