Nginx one-click installation script under Centos

  
 

In the recent period, I’ve been tossing Nginx. First, all kinds of vps need to be loaded with webserver, and then I’m going to fight against it. Previously, I used the military brother's LNMP one-click installation package, without tangling various configurations. But recently I only needed Nginx one thing, and PHP
and MySQL have a particularly long installation time and space, so I decided to make a Nginx one-click installation script myself. The installation of Nginx is still quite simple, and the dependencies can basically be solved by the yum source. The only thing that is not there is PCRE. This is just a direct download from the official website.

This script is basically extracted from the LNMP one-click installation script. The default configuration file is also used inside. I just simplified the steps and modified the configuration file. Nginx runs by default with nobody privileges.

The script is tested in Alibaba Cloud and Linode Centos, and it still has some versatility.

Download: nginx.sh

#!/bin/bashPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr /local/sbin:~/binexport PATH#Install dependency environment yum install -y patch openssl make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10- Devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl Openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap diffutils# install PCREwget http://downloads.sourceforge.net/project/pcre/pcre/8.36/pcre-8.36 .tar.gztar zxf pcre-8.36.tar.gzcd pcre-8.36/./configure && make && make installcd ../#install NGINXwget http://nginx.org/download/nginx-1.6. 2.tar.gztar zxf nginx-1.6.2.tar.gzcd nginx-1.6.2/./configure -- User=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module --with-http_spdy_modulemake & & make installcd ../

ln -s /usr/local/lib/libpcre.so.1 /libln -s /usr/local/nginx/sbin/nginx /usr/bin/nginxrm -f /usr/local/nginx/conf/nginx.confmkdir -p /home/wwwroot/defaultchmod +w /home/wwwroot/defaultmkdir -p /home/wwwlogschmod 777 /home/wwwlogschown -R nobody:nobody /home/wwwroot/default

wget -c http://soft.vpser.net/lnmp/ext/init.d.nginxcp init.d.nginx /etc/init.d/nginxchmod +x /etc/init.d/Nginxchkconfig --level 345 nginx on/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT/sbin/iptables-saveldconfigwget -c http://hack0nair.me/Download/nginx.confmv nginx.conf /usr /local/nginx/conf//etc/init.d/nginx start

Copyright © Windows knowledge All Rights Reserved