nginx -- 入门

安装

# 系统:centos 7
# /etc/yum.repos.d/nginx.repo 

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

$ yum -y install nginx

启动

$ nginx 
$ nginx -s quit  
$ nginx -s stop  # 强制退出
$ nginx -s reload
$ nginx -s reopen # 重新打开日志文件

配置

配置文件:/etc/nginx/conf.d/default.conf

# 在 server 内添加

# location 后面的符号是 URL
# root 后面是 目录,语句以分号结束
# URL 的匹配原则是优先匹配最长的
location / {
    root   /www/root;
    index  index.html index.htm;
}
# http://127.0.0.1/images/nginx.png  --- /www/images/nginx.png
location /images/ {
     root   /www;
}

日志

路径:/var/log/nginx/error.log

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容