1 Nginx 安装部署(略)
2 修改nginx.conf配置文件
[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
server{
listen 10080;
server_name 192.168.10.200;
location /www/ {
root /data/;
index index.html index.htm;
autoindex on;
autoindex_localtime on;
autoindex_exact_size off;
}
location /image/ {
root /data/;
autoindex on; # 启用目录浏览,Nginx默认不允许列出目录下的内容
autoindex_localtime on; # 显示文件的时间为文件服务器的时间;默认为off,显示的文件时间为GMT时间
autoindex_exact_size off; # 显示文件的确切大小,单位是kB或者MB或者GB;默认为on,单位为bytes
}
3 创建相关目录
[root@nginx ~]# mkdir /data/www -p
[root@nginx ~]# mkdir /data/image -p
4 设置静态资源
[root@nginx ~]# cat /data/www/a.html
<h1>This is Jackson Web!!!</h1>
[root@nginx ~]# ls /data/image/
a.jpg
5 重启Nginx
[root@nginx sbin]# ./nginx -s reload
[root@nginx sbin]# ./nginx -s reopen
6 防火墙放行Nginx监听端口
[root@nginx ~]# firewall-cmd --zone=public --add-port=10080/tcp --permanent
success
[root@nginx ~]# firewall-cmd --reload
success
[root@nginx ~]# firewall-cmd --list-ports
10080/tcp
7 测试