目录
一、修改配置文件
当Nginx配置文件中有且只有一个Server的时候,该Server就被Nginx认为是默认网站,所有发给
Nginx服务器80端口的数据都会默认给该Server。
[root@003 ~]# vim /usr/local/nginx/conf/nginx.conf
user www; # 创建一个www用户
worker_processes 2; # 本机有2核CPU
error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
keepalive_timeout 5;
#gzip on;
server {
listen 80;
server_name localhost;
# 创建一个404页面
location / {
root html;
index index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
二、创建404.html
[root@003 ~]# cd /usr/local/nginx/html/
[root@003 html]# vim 404.html
输入
sorry,not found!
hhhhhhhha
三、创建用户
[root@003 html]# useradd -s /sbin/nologin -r www
-r 建立系统帐号
-s <shell> 指定用户登入后所使用的shell
[root@003 html]# killall -s HUP nginx
-s 用指定的进程号代替默认信号
HUP 重新加载(配置文件)进程
[root@003 html]# lsof -i :80
四、模拟404
正常进入:
404:
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/74668.html