PHP-fastCGI安装
1.提前安装数据库MysqL与Web服务,确定MysqL与Web服务是否安装
ss -lntup|egrep "3306|80"
2.安装PHP基础依赖包,安装前修改epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum install -y zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel
yum install -y freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel
yum install -y libmcrypt-devel mhash mcrypt
3.提前下载好编译安装的软件包到指定的目录,先安装PHP依赖库libiconv
cd /home/rich/tools
rz -y libiconv-1.15.tar.gz
tar zxf libiconv-1.15.tar.gz
cd libiconv-1.15
./configure --prefix=/usr/local/libiconv
make && make install
4.提前下载好PHP编译安装包到指定目录下并上传到服务器上
rz -y PHP-5.3.27.tar.gz
5.解压软件包并进入到解压的目录下
tar zxf PHP-5.3.27.tar.gz
cd PHP-5.3.27
6.开始编译生成MAKEFILE文件
./configure --prefix=/application/PHP5.3.27 \
--with-MysqL=/application/MysqL \
--with-pdo-MysqL=MysqLnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=Nginx \
--with-fpm-group=Nginx \
--enable-ftp \
7.为了避免安装是出现缺少MysqL相关库文件,先提前创建MysqL的库文件软件链接到系统库下
ln -s /application/MysqL/lib/libMysqLclient.so.18 /usr/lib/
8.进入到解压包目录下开始编译安装
cd /home/rich/tools/PHP-5.3.27
touch ext/phar/phar.phar //有时会报错缺少phar.phar文件,所以先提前创建
make && make install
9.安装完毕后创建安装目录的软链接
ln -s /application/PHP5.3.27/ /application/PHP
10.修改部分配置文件方便使用
cp PHP.ini-production /application/PHP/lib/PHP.ini
cd /application/PHP/etc
cp PHP-fpm.conf.default PHP-fpm.conf
11.启动PHP
/application/PHP/sbin/PHP-fpm
netstat -lntup|grep 9000
12.调整Web服务Nginx支持PHP
cd /application/Nginx/conf
vim Nginx.conf
... ...
location ~ .*.(PHP|PHP5)?$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.PHP;
include fastcgi.conf;
}
... ...
13.创建Web服务测试PHP的index文件
cd /application/Nginx/html
echo "<?PHP PHPinfo(); ?>" >test_info.PHP
14.检查Nginx语法并重启服务
/application/Nginx/sbin/Nginx -t
/application/Nginx/sbin/Nginx -s reload
15.windows浏览器输入服务器的IP地址加测试PHP的index文件,测试Web服务是否成功支持PHP
http://192.168.23.249/test_info.php