Skip to content

Instantly share code, notes, and snippets.

@hellokaton
Forked from vmlive/install_nginx.sh
Last active March 20, 2021 11:37
Show Gist options
  • Save hellokaton/af568a613fd6d325c6419f2e89996fb2 to your computer and use it in GitHub Desktop.
Save hellokaton/af568a613fd6d325c6419f2e89996fb2 to your computer and use it in GitHub Desktop.
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
@hellokaton
Copy link
Author

hellokaton 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