1.下载 php-5.5.6 到 ~/downloads
cd ~/downloads
wget http://cn2.php.net/distributions/php-5.5.6.tar.gz
2.安装 php编译过程中需要用的的一些模块
sudo apt-get -y install libxml2 libxml2-dev autoconf libjpeg-dev libpng-dev php5-gd libmcrypt-dev
sudo apt-get -y install bzip2 libbz2-dev curl libcurl4-gnutls-dev libfreetype6-dev
3.解压
tar -zxf php-5.5.6.tar.gz
4.编译并安装
./configure --prefix=/usr/local/php-5.5.6 --with-apxs2=/usr/local/apache-2.4.7/bin/apxs --with-libxml-dir=/usr/include/libxml2 --with-config-file-path=/usr/local/php-5.5.6/etc/ --with-gd --enable-gd-native-ttf --with-zlib --with-mcrypt --with-mysql --enable-shmop --enable-soap --enable-sockets --enable-wddx --enable-zip --with-xmlrpc --enable-fpm --enable-mbstring --with-zlib-dir --with-bz2 --with-curl --enable-exif --enable-ftp --with-iconv --enable-xml --enable-inline-optimization --enable-bcmath --enable-sysvsem --with-openssl --with-gettext --enable-pcntl --enable-session
make
sudo make install
5.配置
sudo rm -rf /etc/php5/fpm
sudo update-rc.d -f php5-fpm remove
sudo rm /etc/init.d/php5-fpm
cd /usr/local/php-5.5.6/etc
sudo cp ~/downloads/php-5.5.6/php.ini-production php.ini
ln -s php.ini /etc/php.ini
sudo cp php-fpm.conf.default php-fpm.conf
编辑 php-fpm.conf
#取消前面的分号
pid = run/php-fpm.pid
保存并退出
为php-fpm添加一个group:nobody
groupadd nobody
设置 php-fpm开机启动
sudo cp ~/downloads/php-5.5.6/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
sudo chmod +x /etc/init.d/php-fpm
?
6.配置 apache 2
#配置apache以module方式使用php?
# vi /usr/local/apache/conf/httpd.conf?
? ??#此处添加php handler?
? ? AddType application/x-httpd-php .php .phtml
? ? PHPIniDir "/etc"?
?
#禁止文件列表功能?
#Options Indexes FollowSymLinks?
Options FollowSymLinks
#允许配置重写?
#AllowOverride None?
AllowOverride All
Require all granted
</Directory>
?
<IfModule dir_module>
? ? DirectoryIndex index.html index.php
</IfModule>
?