Skip to content

Instantly share code, notes, and snippets.



Forked from vmlive/
Last active Mar 20, 2021
What would you like to do?
Nginx 一键安装脚本
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/
# nohup /bin/bash /tmp/ > /tmp/ && rm -f /tmp/ &
# 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
#add the third-party repo
rpm -Uvh
#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]"
echo "Error: nginx-1.12.2.tar.gz not found!!!download now......"
wget -c
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 \
make && make install
curl -o /etc/init.d/nginx
chmod 755 /etc/init.d/nginx
mkdir -p /etc/nginx/conf.d
# curl -o /etc/nginx/nginx.conf
# 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

This comment has been minimized.

Copy link
Owner Author

@biezhi biezhi commented Nov 14, 2017

wget && chmod +x && ./
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment