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
转载于:https://blog.51cto.com/11047966/2067653