1. 禁用防火墙

    systemctl disable firewalld

    systemctl stop firewalld

    setenforce 0

  2. 安装pcre库/zlib库

    yum install pcre* zlib*


  3. 编译安装openssl

增加nginx用户:groupadd nginx

               useradd nginx -g nginx

编译安装nginx:./configure --prefix=/usr/local/nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --user=nginx --group=nginx 

make && make install


添加nginx服务

vi /lib/systemd/system/nginx.service

[Unit]

Description=nginxAfter=network.target 

[Service]

Type=forking

ExecStart=/usr/local/nginx/sbin/nginx

ExecReload=/usr/local/nginx/sbin/nginx -s reload

ExecStop=/usr/local/nginx/sbin/nginx -s quit

PrivateTmp=true 

[Install]WantedBy=multi-user.target


chmod 745 /lib/systemd/system/nginx.service


启动nginx:systemctl enable nginx.service

systemctl start nginx.service


安装mariadb    

yum install mariadb* 


启动mariadb    

systemctl start mariadb 

修改mariadb root密码    

mysql -uroot -p    

use mysql;    

update user 

set password=password("123456") where user='root';    

flush privileges;    

exit;


编译安装php7环境

yum install libxml2* curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxslt-devel openssl-devel


ln -sv /usr/local/openssl/lib/libssl.so /usr/lib64


安装PHP gd JPEG support

wget http://www.ijg.org/files/jpegsrc.v9b.tar.gz

tar -zxf jpegsrc.v9b.tar.gz

cd jpeg-9b/

 ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static

make && make install


编译安装php7

./configure --prefix=/usr/local/php  --with-curl  --with-freetype-dir  --with-gd  --with-gettext  --with-iconv-dir  --with-kerberos  --with-libdir=lib64  --with-libxml-dir  --with-mysqli  --with-openssl  --with-pcre-regex  --with-pdo-mysql  --with-pdo-sqlite  --with-pear  --with-png-dir  --with-xmlrpc  --with-xsl  --with-zlib  --enable-fpm  --enable-bcmath  --enable-libxml  --enable-inline-optimization  --enable-gd-native-ttf  --enable-mbregex  --enable-mbstring  --enable-opcache  --enable-pcntl  --enable-shmop   --enable-soap  --enable-sockets  --enable-sysvsem  --enable-xml  --enable-zip --with-openssl-dir=/usr/local/openssl-1.1.0e --with-jpeg-dir=/usr/local/jpeg


make

make install


配置文件

cp php.ini-development /usr/local/php/lib/php.ini

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm


修改php.ini

pdo_mysql.default_socket=/var/lib/mysql/mysql.sock

mysqli.default_socket = /var/lib/mysql/mysql.sock


启动php/etc/init.d/php-fpm


修改nginx配置文件


server {       

listen       80;       

server_name  localhost;        

#access_log  logs/host.access.log  main;        

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  /usr/local/nginx/html$fastcgi_script_name;            

include        fastcgi_params;        }


检查php

vi index.php

        $conn=mysqli_connect('localhost','root','123456','mysql');

        if ($conn)

                 echo "OK";

        else

                echo "fail";

        mysqli_close($conn);


        phpinfo();

?>

14. 重新加载nginx

 /usr/local/nginx/sbin/nginx -s reload

15.查看index.php页面显示。


16. 安装phpmyadmin

    unzip phpMyAdmin-4.7.0-all-languages.zip

    mv phpMyAdmin-4.7.0-all-languages /usr/local/nginx/html/

    ln -sv phpMyAdmin-4.7.0-all-languages pma

    cp config.sample.inc.php config.inc.php

17. 通过 http://localhost/pma 访问phpmyadmin