Php官网
http://php.net/
https://www.php.net/releases/
php编译安装
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://hk1.php.net/distributions/php-5.6.40.tar.gz’
tar -zxvf php-5.6.40.tar.gz
cd php-5.6.40
./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
php编译安装说明
–prefix指点php的安装目录
–with-config-file-path指定php的配置文件位置
–with-mysql 、–with-mysqli让php可以操作mysql
–enable-fpm主要是nginx要来调用php语言得使用php-fpm
启动php-fpm
环境变量:PATH=
P
A
T
H
:
/
u
s
r
/
l
o
c
a
l
/
p
h
p
/
s
b
i
n
/
:
/
u
s
r
/
l
o
c
a
l
/
p
h
p
/
b
i
n
/
(
在
/
e
t
c
/
p
r
o
f
i
l
e
文
件
的
最
后
一
行
加
上
这
条
e
x
p
o
r
t
P
A
T
H
=
PATH:/usr/local/php/sbin/:/usr/local/php/bin/ (在/etc/profile文件的最后一行加上这条 export PATH=
PATH:/usr/local/php/sbin/:/usr/local/php/bin/(在/etc/profile文件的最后一行加上这条exportPATH=PATH:/usr/local/php/sbin/:/usr/local/php/bin/ ) 之后命令行终端输入 source /etc/profile 最后检测 php -v
检查配置文件:php-fpm -t
使用默认配置文件:mv /usr/local/php/etc/php-fpm.conf.deafult /usr/local/php/etc/php-fpm.conf
查看php-fpm的listen配置
验证php-fpm的启动
进程 ps auxf |grep php-fpm
端口 ss -ntulp | grep php-fpm
日志 tail -f /var/log/access.logs
使用systemctl管理php-fpm, /usr/lib/systemd/system/php-fpm.service
[Unit]
Decription=php-fpm (需要改的地方如nginx名字)
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/php/sbin/php-fpm
[install]
WantedBy=multi-user.target
nginx的默认配置无法处理php程序/usr/local/nginx/html/test.php
<?php echo "this is a php test"; 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; }