1. 修改配置文件

1、进入nginx的配置目录,执行以下操作:
[root@web01 conf]# cd /app/nginx/conf/
[root@web01 conf]# egrep -v “^$|#” nginx.conf.default >nginx.conf

2、修改nginx.conf文件内容跟下面的一致
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.etiantian.org;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}

2. 检查配置文件是否修改正确

[root@web01 conf]# /app/nginx/sbin/nginx -t
nginx: the configuration file /app/nginx-1.6.3/conf/nginx.conf syntax is ok
nginx: configuration file /app/nginx-1.6.3/conf/nginx.conf test is successful
提示:使用-t参数检查语法,只要出现 is ok和is successful成功的字样就表示配置文件没问题。

3. 重启Nginx使配置文件生效

修改好配置文件后,并不会马上生效,需要重启Nginx,使其刚修改的配置文件加载到内存中。

[root@web01 conf]# /app/nginx/sbin/nginx -s reload
提示:-s reload参数是优雅(平滑)重启Nginx。

4. 修改网站首页内容

网站目录默认在Nginx安装目录下的html目录里。
[root@web01 conf]# cd /app/nginx/html/ #进入网站目录
修改index.html文件内容跟下面的一致:





Welcome to Web World



修改保存好后,通过浏览器访问就能看到如下的效果了
创建web站点 - 图1