nginx实现目录索引
连接xshell,搭建yum。
安装nginx依赖环境。
[root@localhost ~]#yum -y install gcc gcc-c++
[root@localhost ~]#yum -y install pcre-devel
[root@localhost ~]#yum -y install zlib-devel
将nginx安装包传送到虚拟机。
[root@localhost ~]# mkdir -p /data/server
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# rz
[root@localhost src]# ls
nginx-1.11.5.tar.gz
安装nginx。
[root@localhost src]# tar zxf nginx-1.11.5.tar.gz -C /data/server/
[root@localhost src]# cd /data/server/nginx-1.11.5/
[root@localhost nginx-1.11.5]# groupadd nginx
[root@localhost nginx-1.11.5]# useradd -s /sbin/nologin -M -g nginx nginx
[root@localhost nginx-1.11.5]# ./configure --prefix=/data/server/nginx --user=nginx --group=nginx
[root@localhost nginx-1.11.5]# make && make install
切换路径,做路径优化。
[root@localhost nginx-1.11.5]# cd /data/server/nginx/conf/
[root@localhost conf]# ln -s /data/server/nginx/sbin/nginx /usr/local/sbin/
修改配置文件,保存并退出。
[root@localhost conf]# vim nginx.conf
root /data/server/nginx;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
启动服务,关闭防火墙。
[root@localhost conf]# cd /data/server/nginx/sbin/
[root@localhost sbin]# ./nginx
[root@localhost sbin]# netstat -anput | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 13400/nginx: master
[root@localhost sbin]# systemctl stop firewalld
打开浏览器,输入IP。