0
点赞
收藏
分享

微信扫一扫

阿里云CentOS部署

1.安装nginx
2.启动nginx
3.开启本地80端口
规则方向选入方向,端口范围写   80/80,
授权对象写                  0.0.0.0/0
4.配置访问路径

注:nginx默认网站目录是/usr/share/nginx/html

server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;
    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;
    location / {
    }
    error_page 404 /404.html;
        location = /40x.html {
    }
    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}
server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    # 修改root默认目录如下
    root         /data/www;
    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;
    location / {
        // 静态资源存放路径
        root /data/www/; 
        // 默认读取文件
        index index.html index.htm; 
    }
    error_page 404 /404.html;
        location = /40x.html {
    }
    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}
5.新建目录&上传静态文件
cd /

mkdir -p /data/www
6.重启nginx
nginx -s reload
7.nginx常用命令
nginx -s reload  :修改配置后重新加载生效

nginx -s reopen  :重新打开日志文件

nginx -t :测试nginx配置文件是否正确

nginx -t -c /path/to/nginx.conf :测试nginx配置文件是否正确
nginx -s stop: 快速停止nginx
nginx -s quit: 完整有序的停止nginx
ps -ef | grep nginx

kill -QUIT 主进程号     :从容停止Nginx

kill -TERM 主进程号     :快速停止Nginx

pkill -9 nginx         :强制停止Nginx
nginx -c /path/to/nginx.conf
kill -HUP 主进程号
举报

相关推荐

0 条评论