CentOS 7 yum 安裝 Nginx
1.添加Nginx到Y(jié)UM源
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 #安全關(guān)閉nginx
Nginx配置信息
/usr/share/nginx/html # 網(wǎng)站文件存放默認(rèn)目錄
/etc/nginx/conf.d/default.conf # 網(wǎng)站默認(rèn)站點(diǎn)配置
/etc/nginx/conf.d/ # 自定義Nginx站點(diǎn)配置文件存放目錄
/etc/nginx/nginx.conf # Nginx全局配置
Nginx配置root權(quán)限
在/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;#監(jiān)聽端口
server_name mock.it100.xyz;
location / {
proxy_pass http://118.25.18.13:7300; #另一個(gè)路徑
}
}