CentOS 7 yum 安装 Nginx
1.添加Nginx到YUM源
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2.安装Nginx
sudo yum install -y nginx
Nginx常用命令
nginx #启动nginx
nginx -s reload #重新加载配置
nginx -s reopen #重启nginx
nginx -s stop #快速停止nginx
nginx -s quit #安全关闭nginx
Nginx配置信息
/usr/share/nginx/html # 网站文件存放默认目录
/etc/nginx/conf.d/default.conf # 网站默认站点配置
/etc/nginx/conf.d/ # 自定义Nginx站点配置文件存放目录
/etc/nginx/nginx.conf # Nginx全局配置
Nginx配置root权限
在/etc/nginx/nginx.conf 中 修改 user nginx; 为 user root root;
Nginx配置自定义访问路径及图片展示
在/etc/nginx/conf.d/default.conf中配置
location / {
root /root/home; #路径是自定义的地址
index index.html index.htm;
}
location /images/ {
root /root/home/;
autoindex on;
}
Nginx配置域名代理端口
在/etc/nginx/conf.d/default.conf中配置
server {
listen 80;#监听端口
server_name mock.it100.xyz;
location / {
proxy_pass http://118.25.18.13:7300; #另一个路径
}
}