yum -y install epel-release yum -y install gcc gcc-c++ make pcre pcre-devel zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel openldap openldap-devel libmcrypt libmcrypt-devel cd /usr/local/src/ wget 'http://download.zhufunin.com/php-5.6.34.tar.gz' tar -zxf php-5.6.34.tar.gz cd php-5.6.34 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-ctype --with-mysql=mysqlnd --with-mysqli=mysqlnd --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-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-fpm make && make install cp php.ini-production /usr/local/php/etc/php.ini #环境变量 echo 'export PATH=$PATH:/usr/local/php/sbin:/usr/local/php/bin/' >> /etc/profile 使用默认配置文件 mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
上面的可以放入文件中用bash 文件名,来运行
source /etc/profile
php 编译安装说明
--prefix 指定php 的安装目录
--with-config-file-path 指定php的配置文件位置
--with-myslq --with-mysqli 让php可以操作mysql
--enable-fpm 主要是nginx 要来调用php语言得使用php-fpm
检查配置文件语法
php-fpm -t
或者/usr/local/php/sbin/php-fpm -t
使用systemctl 管理php-fpm, /usr/lib/systemd/system/php-fpm.service
[Unit] Description=php-fpm After=network.target [Service] Type=forking ExecStart=/usr/local/php/sbin/php-fpm [Install] WantedBy=multi-user.target
启动PHP
systemctl start php-fpm.service
验证 php-fpm 的启动
进程 'ps -ef | grep php-fpm'
端口 'netstat -lpnt|grep php'
nginx 的默认配置无法处理php程序 /usr/local/nginx/html/test.php
<?php echo "taobao zabbix" ?>
nginx-php-fpm 结合的配置
location / { root html; index index.html index.htm index.php; } location ~ .php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }