参考:https://www.cnblogs.com/jimisun/p/8057156.html 主要
https://blog.csdn.net/yelllowcong/article/details/75945339 关闭防火墙
https://blog.csdn.net/qq_34869990/article/details/103727377 开机自启

先来安装一大堆yum

yum install -y git composer readline-devel freetype gmp-devel net-tools pcre pcre-devel mariadb mariadb-server epel-release autoconf automake vim wget libmcrypt-devel libxslt curl-devel libxslt-devel gcc gcc-c++ zlib zlib-devel openssl openssl-devel make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel

在/usr/local/nginx下下载官网的tgz安装包,然后进入nginx.1.16

./configure --prefix=/usr/local/nginx
make && make install

/usr/local/nginx/sbin/nginx -t // 检查配置文件是否正确 /sbin/nginx // 启动(ps -ef|grep nginx检查下)

然后用自己电脑访问,访问不成功,是因为防火墙开着的,而centos7关闭防火墙的命令是systemctl stop firewalld.service
然后去nginx.conf最后一个括号前面加行include /usr/local/nginx/conf/vhost/*.conf;
里面写


server {
    listen 80;
    server_name deskpic.top;
    index index.html index.php
    client_max_body_size 50M;
   # error_log /home/deploy/apps/logs/example.error.log;
   # access_log /home/deploy/apps/logs/example.access.log;
    root /usr/local/nginx/html/blog/public;

location / {
    try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php {
    try_files $uri = 404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_index index.php;
    fastcgi_pass 127.0.0.1:9000;
}

}

最后去域名管理那把域名绑定到我的服务器就好了。

同时也设置下service和开机自启吧😋

vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=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

systemctl disable firewalld.service  关闭防火墙
systemctl enable nginx.service	列入开机项
systemctl disable nginx.service  关闭开机项
systemctl [start|stop|reload|status] nginx.service	各个操作