1. PHP是什么 #

2. 安装php #

cd /usr/local/src
yum -y install gcc gcc-c++ make automake autoconf libtool openssl-devel pcre-devel libxml2 libxml2-devel bzip2 bzip2-devel libjpeg-turbo libjpeg-turbo-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel libcurl libcurl-devel
wget http://upload-markdown-images.oss-cn-beijing.aliyuncs.com/libmcrypt-2.5.8.tar.gz
tar -xzvf libmcrypt-2.5.8.tar.gz
cd /usr/local/src/libmcrypt-2.5.8 && \
    ./configure && \
    make -j 2 && \
    make install

wget http://upload-markdown-images.oss-cn-beijing.aliyuncs.com/php-5.6.31.tar.gz
tar -xzvf php-5.6.31.tar.gz
cd /usr/local/src/php-5.6.31 && \
    ./configure --prefix=/usr/local/php --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --with-openssl --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-mcrypt --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --enable-fpm --with-config-file-path=/usr/local/php/etc --with-bz2 --with-gd && \
    make -j 2 && \
    make install
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# sed -i 's/127.0.0.1/0.0.0.0/g' /usr/local/php/etc/php-fpm.conf
# sed -i  '89a daemonize = no' /usr/local/php/etc/php-fpm.conf
rm -rf /usr/local/src/php-5.6.30 && yum clean all 
#  -R 指允许用root启动
/usr/local/php/sbin/php-fpm -R -c /usr/local/php/etc/php-fpm.conf

# 重启 kill  -USR2   php旧进程号      平滑加载  如果这儿的旧进程号是nginx.pid
kill -USR2 $(ps -ef | grep php-fpm | awk '{print $2}' | head -n 1)  
netstat -anpt | grep 9000

修改启动用户为root vi /usr/local/php/etc/php-fpm.conf

user = root
group = root

3. 布署nignx #

3.1 关闭防火墙 #

功能 命令
停止防火墙 systemctl stop firewalld.service
永久关闭防火墙 systemctl disable firewalld.service

3.2 安装nignx #

vi /etc/yum.repos.d/nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

安装nginx

yum install nginx -y 
nginx -v 查看安装的版本

3.3 配置虚拟主机 #

/usr/share/nginx/html/dev-php/main.php

<?php echo phpinfo()?>

vi /etc/nginx/conf.d/dev-php.conf

server {
    listen       80;
    server_name  www.dev-php.com;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
    location /status{
       stub_status  on;
    }
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
        root           /usr/share/nginx/html/dev-php;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

vi /etc/nginx/nginx.conf

user  root;

启动和重启

systemctl start nginx.service
netstat -anpt | grep 80

C:\Windows\System32\drivers\etc\hosts js 192.168.20.132 www.dev-php.com `