一.关闭防火墙和SElinux
systemctl stop firewalld
setenforce 0
二.源码安装NGINX
下载源码包并解压:
wget http://nginx.org/download/nginx-1.16.0.tar.gz
tar -zxvf nginx-1.16.0.tar.gz
三.编译安装
cd /usr/local/src
cd nginx-1.16.0
./configure --prefix=/data/server/nginx
make && make install
进到NGINX目录中启动NGINX
cd /data/server/nginx/sbin
./nginx
在网页输入IP:
配置目录索引
- 在/var/www/html目录下创建文件www xxx yyy
cd /var/www/html
touch www xxx yyy
2.分别在www xxx yyy三个文件内加入安装包
vim www
在其中放入安装链接http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
vim xxx
在其中放入安装链接http://nginx.org/en/download.html
3.配置文件
vim /data/server/nginx/conf/nginx.conf
在server模块下添加
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
root /var/www/html;
在location下添加
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
4.进到启动nginx的目录
cd /data/server/nginx/sbin
5.重读nginx
./nginx -s reload
6.在浏览器输入ip