使用xshell连接到192.168.223.60虚拟机,配置yum源

1.修改主机名

  1. [root@localhost ~]# hostnamectl set-hostname php
  2. [root@localhost ~]# bash
  3. bash
  4. [root@php ~]#

2.关闭防火墙

  1. [root@php ~]#setenforce 0
  2. [root@php ~]#systemctl stop firewalld

3.安装配置服务

  1. [root@php ~]# yum -y install gcc gcc-c++ libxml2-devel libcurl-devel openssl-devel bzip2-devel

4.将lib和php包上传到/usr/local/src目录下

  1. [root@php ~]# cd /usr/local/src
  2. [root@php src]# tar -zxvf libmcrypt-2.5.8.tar.gz
  3. [root@php src]# cd libmcrypt-2.5.8/
  4. [root@php libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt && make && make install

5.安装PHP环境

  1. [root@php src]# tar -zxvf php-5.6.27.tar.gz
  2. [root@php src]# cd php-5.6.27/
  3. [root@php php-5.6.27]# ./configure --prefix=/usr/local/php5.6 --with-mysql=mysqlnd \
  4. --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --enable-fpm \
  5. --enable-sockets --enable-sysvshm --enable-mbstring --with-freetype-dir --with-jpeg-dir \
  6. --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --with-mhash \
  7. --with-mcrypt=/usr/local/libmcrypt --with-config-file-path=/etc \
  8. --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts
  9. [root@php php-5.6.27]# make && make install

6.创建用户ID

  1. [root@php php-5.6.27]# groupadd -g 1001 nginx
  2. [root@php php-5.6.27]# useradd -u 900 nginx -g nginx -s /sbin/nologin
  3. [root@php php-5.6.27]# tail -1 /etc/passwd
  4. nginx:x:900:1001::/home/nginx:/sbin/nologin

7.配置PHP环境

  1. [root@php php-5.6.27]# cp php.ini-production /etc/php.ini
  2. [root@php php-5.6.27]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
  3. 赋予文件执行权限
  4. [root@php php-5.6.27]# chmod +x /etc/init.d/php-fpm
  5. 添加PHP服务到启动列表,并设置开机自启
  6. [root@php php-5.6.27]# chkconfig --add php-fpm
  7. [root@php php-5.6.27]# chkconfig php-fpm on
  8. 修改PHP的主配置文件php-fpm.conf
  9. [root@php php-5.6.27]# cp /usr/local/php5.6/etc/php-fpm.conf.default /usr/local/php5.6/etc/php-fpm.conf
  10. [root@php php-5.6.27]# vi /usr/local/php5.6/etc/php-fpm.conf
  11. [root@php ~]# grep -n '^'[a-Z] /usr/local/php5.6/etc/php-fpm.conf
  12. 25:pid = run/php-fpm.pid
  13. 149:user = nginx
  14. 150:group = nginx
  15. 164:listen = 192.168.200.60:9000
  16. 224:pm = dynamic
  17. 235:pm.max_children = 50
  18. 240:pm.start_servers = 5
  19. 245:pm.min_spare_servers = 5
  20. 250:pm.max_spare_servers = 35

8.启动PHP服务

  1. [root@localhost php-5.6.27]# service php-fpm start
  2. Starting php-fpm done
  3. [root@php ~]# yum -y install net-tools
  4. [root@php ~]# netstat -ntpl
  5. Active Internet connections (only servers)
  6. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
  7. tcp 0 0 192.168.200.60:9000 0.0.0.0:* LISTEN 123948/php-fpm: mas
  8. tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1403/sshd
  9. tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2516/master
  10. tcp6 0 0 :::22 :::* LISTEN 1403/sshd
  11. tcp6 0 0 ::1:25 :::* LISTEN 2516/master