使用xshell连接到192.168.223.60虚拟机,配置yum源
1.修改主机名
[root@localhost ~]# hostnamectl set-hostname php
[root@localhost ~]# bash
bash
[root@php ~]#
2.关闭防火墙
[root@php ~]#setenforce 0
[root@php ~]#systemctl stop firewalld
3.安装配置服务
[root@php ~]# yum -y install gcc gcc-c++ libxml2-devel libcurl-devel openssl-devel bzip2-devel
4.将lib和php包上传到/usr/local/src目录下
[root@php ~]# cd /usr/local/src
[root@php src]# tar -zxvf libmcrypt-2.5.8.tar.gz
[root@php src]# cd libmcrypt-2.5.8/
[root@php libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt && make && make install
5.安装PHP环境
[root@php src]# tar -zxvf php-5.6.27.tar.gz
[root@php src]# cd php-5.6.27/
[root@php php-5.6.27]# ./configure --prefix=/usr/local/php5.6 --with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --enable-fpm \
--enable-sockets --enable-sysvshm --enable-mbstring --with-freetype-dir --with-jpeg-dir \
--with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --with-mhash \
--with-mcrypt=/usr/local/libmcrypt --with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts
[root@php php-5.6.27]# make && make install
6.创建用户ID
[root@php php-5.6.27]# groupadd -g 1001 nginx
[root@php php-5.6.27]# useradd -u 900 nginx -g nginx -s /sbin/nologin
[root@php php-5.6.27]# tail -1 /etc/passwd
nginx:x:900:1001::/home/nginx:/sbin/nologin
7.配置PHP环境
[root@php php-5.6.27]# cp php.ini-production /etc/php.ini
[root@php php-5.6.27]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
赋予文件执行权限
[root@php php-5.6.27]# chmod +x /etc/init.d/php-fpm
添加PHP服务到启动列表,并设置开机自启
[root@php php-5.6.27]# chkconfig --add php-fpm
[root@php php-5.6.27]# chkconfig php-fpm on
修改PHP的主配置文件php-fpm.conf
[root@php php-5.6.27]# cp /usr/local/php5.6/etc/php-fpm.conf.default /usr/local/php5.6/etc/php-fpm.conf
[root@php php-5.6.27]# vi /usr/local/php5.6/etc/php-fpm.conf
[root@php ~]# grep -n '^'[a-Z] /usr/local/php5.6/etc/php-fpm.conf
25:pid = run/php-fpm.pid
149:user = nginx
150:group = nginx
164:listen = 192.168.200.60:9000
224:pm = dynamic
235:pm.max_children = 50
240:pm.start_servers = 5
245:pm.min_spare_servers = 5
250:pm.max_spare_servers = 35
8.启动PHP服务
[root@localhost php-5.6.27]# service php-fpm start
Starting php-fpm done
[root@php ~]# yum -y install net-tools
[root@php ~]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.200.60:9000 0.0.0.0:* LISTEN 123948/php-fpm: mas
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1403/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2516/master
tcp6 0 0 :::22 :::* LISTEN 1403/sshd
tcp6 0 0 ::1:25 :::* LISTEN 2516/master