Skip to content

Instantly share code, notes, and snippets.

@biezhi

biezhi/install_nginx.sh

Forked from vmlive/install_nginx.sh
Last active Mar 20, 2021
Embed
What would you like to do?
Nginx 一键安装脚本
#!/bin/bash
clear
echo "========================================================================="
echo "Nginx script V1.0 for CentOS/RadHat Linux Written by llama"
echo "========================================================================="
echo "A tool to auto-compile & install Nginx on Linux "
echo ""
echo "For more information please contact llama"
echo "========================================================================="
#
# # sample usage
# curl -o /tmp/install_nginx.sh https://gist.githubusercontent.com/vmlive/9993932/raw
# nohup /bin/bash /tmp/install_nginx.sh > /tmp/install_nginx.sh.log && rm -f /tmp/install_nginx.sh &
#
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
#add the third-party repo
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
#install packges
for packages in patch 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 libxslt-devel pcre pcre-devel gd-devel GeoIP-devel;
do yum -y install $packages; done
cd /usr/local/src
if [ -s nginx-1.12.2.tar.gz ]; then
echo "nginx-1.12.2.tar.gz [found]"
else
echo "Error: nginx-1.12.2.tar.gz not found!!!download now......"
wget -c http://nginx.org/download/nginx-1.12.2.tar.gz
fi
tar zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2
./configure --prefix=/usr/local/nginx \
--with-http_gzip_static_module \
--with-http_ssl_module \
--with-http_sub_module \
--with-sha1=/usr/include/openssl \
--with-md5=/usr/include/openssl
make && make install
curl -o /etc/init.d/nginx https://gist.githubusercontent.com/biezhi/fcb0a51960f2a200a0f2c4c95c90b951/raw/764590eef32d1d5d4c35af83255bc187675e2006/nginx
chmod 755 /etc/init.d/nginx
mkdir -p /etc/nginx/conf.d
# curl -o /etc/nginx/nginx.conf https://gist.githubusercontent.com/vmlive/10022016/raw
# mkdir -p /var/log/nginx
# chown nginx:root /var/log/nginx
# mkdir -p /var/lib/nginx
# chown nginx:root /var/lib/nginx
# mkdir -p /data/wwwroot
# chown nginx:root /data/wwwroot
@biezhi

This comment has been minimized.

Copy link
Owner Author

@biezhi biezhi commented Nov 14, 2017

wget https://gist.githubusercontent.com/biezhi/af568a613fd6d325c6419f2e89996fb2/raw/522cb75404ab7926c088bb2e5262f03f2de22991/install_nginx.sh && chmod +x install_nginx.sh && ./install_nginx.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment