/etc/logrotate.d/nginx nginx日志轮转配置文件
/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf 立即执行一次日志循环
ll /var/log/nginx/ 查询nginx日志文件
/etc/nginx/conf.d/default.conf nginx主配置文件
/etc/nginx/nginx.conf nginx子配置文件
同一个ip可同时挂载多个网页
nginx主配置文件 :/etc/nginx/conf.d/default.conf
创建nginx子配置文件 /etc/nginx/conf.d/xupeng.conf (在 /etc/nginx/conf.d/ 下创建结尾以.conf即可)
1.先自己配置一个子配置文件
server {
listen 80;
server_name xupeng;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
当网页出现500等报错时候 显示 /usr/share/nginx/html 里的内容
方法一: 将ip 配置多个子网卡 即可获得多个ip 每个ip可挂载一个页面
listen 80;
server_name 10.18.46.6;
location / {
root /xupeng;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
listen 80;
server_name 10.18.46.7;
location / {
root /xupeng1;
index index1.html index1.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
方法二:将每个网页使用不同的端口即可
listen 80;
server_name 10.18.46.6;
location / {
root /xupeng;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
listen 8080;
server_name 10.18.46.6;
location / {
root /xupeng1;
index index1.html index1.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
第三种:使用不同的域名实现
listen 80;
server_name xupeng.com;
location / {
root /xupeng;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
listen 80;
server_name xupengpeng.com;
location / {
root /xupeng;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
在电脑上打开 :C:\Windows\System32\drivers\etc
将 10.18.46.6 xupeng.com
10.18.46.6 xupengpeng.com
保存退出即可
网友评论