yum install gcc gcc-c++ wget ntpdate vim-enhanced autoconf automake openssl-devel pcre-devel unzip -y
cd /root
git clone https://github.com/aperezdc/ngx-fancyindex.git ngx-fancyindex
wget http://nginx.org/download/nginx-1.16.1.tar.gz
wget -O fancytheme.zip https://github.com/Naereen/Nginx-Fancyindex-Theme/archive/master.zip
unzip fancytheme.zip
tar -xzvf nginx-1.16.1.tar.gz
cd nginx-1.16.1/
./configure --prefix=/usr/local/nginx --add-module=/root/ngx-fancyindex
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
vi /usr/lib/systemd/system/nginx.service
如下
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
[Install]
WantedBy=multi-user.target
结束
systemctl enable nginx
cd
cat Nginx-Fancyindex-Theme-master/fancyindex.conf
vi /usr/local/nginx/conf/nginx.conf
nginx -t
rm -rf /usr/local/nginx/html/*
cp -r Nginx-Fancyindex-Theme-master/Nginx-Fancyindex-Theme-light /usr/local/nginx/html/
nginx
cd /usr/local/nginx/html/
touch a.txt
浏览器输入IP, 最终效果如下
发表评论