nginx簡易安裝指令碼備份,其中刪除安裝包和啟動nginx部分可刪除,啟動nginx部分ip需要根據主機ip網段修改。
系統環境:
centos linux release 7.2.1511 (core)
pcre_version="8.36"
openssl_version="1.1.1"
zlib_version="1.2.11"
nginx_version="1.14.0"
vim /home/install-nginx.sh
檔案內容如下:
#!/bin/bash
# nginx簡易安裝指令碼,版本以及nginx安裝模組可修改。
echo "start"
# pcre_version="8.36"
# openssl_version="1.0.1j"
# zlib_version="1.2.11"
# nginx_version="1.8.0"
pcre_version="8.36"
openssl_version="1.1.1"
zlib_version="1.2.11"
nginx_version="1.14.0"
echo "安裝:gcc gcc-c++"
yum install -y gcc gcc-c++
echo "進入目錄:/usr/local/"
cd /usr/local/
echo ""
pcre_url=""$pcre_version"/pcre-"$pcre_version".tar.gz"
wget $pcre_url
echo "解壓:pcre-"$pcre_version".tar.gz"
tar -zxvf pcre-"$pcre_version".tar.gz
echo "進入目錄:/usr/local/pcre-"$pcre_version""
cd pcre-"$pcre_version"
echo "編譯安裝:pcre-"$pcre_version""
./configure
make && make install
echo "返回到目錄:/usr/local/"
cd /usr/local/
echo ""
openssl_url=""$openssl_version".tar.gz"
wget $openssl_url
echo "解壓:openssl-"$openssl_version".tar.gz"
tar -zxvf openssl-"$openssl_version".tar.gz
echo "進入目錄:openssl-"$openssl_version""
cd openssl-"$openssl_version"
echo "編譯安裝:openssl-"$openssl_version""
./config
make && make install
echo "返回到目錄:/usr/local/"
cd /usr/local/
echo ""
zlib_url=""$zlib_version".tar.gz"
wget $zlib_url
echo "解壓:zlib-"$zlib_version".tar.gz"
tar -zxvf zlib-"$zlib_version".tar.gz
echo "進入目錄:zlib-"$zlib_version""
cd zlib-"$zlib_version"
echo "編譯安裝:zlib-"$zlib_version""
./configure
make && make install
echo "返回到目錄:/usr/local/"
cd /usr/local/
echo ""
nginx_url=""$nginx_version".tar.gz"
wget $nginx_url
echo "解壓:nginx-"$nginx_version".tar.gz"
tar -zxvf nginx-"$nginx_version".tar.gz
echo "重新命名nginx-"$nginx_version"為nginx"
mv nginx-"$nginx_version" nginx
echo "進入目錄:nginx"
cd nginx
echo "編譯安裝:nginx-"$nginx_version""
echo "建立目錄:/usr/local/nginx/logs"
mkdir logs
echo "返回到目錄:/usr/local/"
cd /usr/local/
echo ""
if [ "$inputmsg" == 'y' ] || [ "$inputmsg" == 'y' ]
then
rm -rf nginx-"$nginx_version".tar.gz pcre-"$pcre_version".tar.gz openssl-"$openssl_version".tar.gz zlib-"$zlib_version".tar.gz
echo "刪除完成"
else
echo "不刪除"
fiecho ""
read -p "是否需要啟動nginx(輸入y/y啟動,其他不啟動):" startnginxmsg
if [ "$startnginxmsg" == 'y' ] || [ "$startnginxmsg" == 'y' ]
then
/usr/local/nginx/sbin/nginx
if [ $? -eq 0 ]
# 獲取本機ip,需要根據實際修改主機ip域。兩端需要加反引號以獲取命令返回資訊。如果不設定ip域則可能會取出包含127.0.0.1等多個位址資訊
then
localip=`/sbin/ifconfig -a|grep inet|grep 172.17.*.*|grep -v inet6|awk ''|tr -d "addr:"`
else
echo "啟動失敗,請檢視異常資訊確定失敗原因"
fielse
echo "不啟動"
fiecho ""
echo "版本資訊:"
echo "pcre:"$pcre_version
echo "openssl:"$openssl_version
echo "zlib:"$zlib_version
echo "nginx:"$nginx_version
echo ""
echo "安裝路徑: /usr/local/"
echo "end"
chmod +x /home/install-nginx.sh
然後執行指令碼即可:
/home/install-nginx.sh
CentOS一鍵安裝LAMP
用環境 系統支援 centos 5 32bit 64bit centos 6 32bit 64bit 記憶體要求 256m 安裝了什麼 1 apache 2.2.22或apache 2.4.2 2 mysql 5.5.24 3 php 5.2.17或php 5.3.13 4 phpmyadmin 3...
centos一鍵安裝redmine
官網給出的環境要求 用wget 獲取最新版本 bitnami redmine 2.6.3 0 linux installer.run 安裝過程如下 1 安裝mysql資料庫。官網要求的,必須先安裝 我第一次沒有安裝mysql資料庫,第二次檢視了官方文件,需要安裝mysql,並控制台鏈結mysql成功...
LNMP 一鍵安裝 centOS
適用環境 系統支援 centos 5 32bit 64bit centos 6 32bit 64bit 記憶體要求 128m 安裝了什麼 1 nginx 1.0.14 2 mysql 5.1.62或mysql 5.5.22 3 php 5.2.17或php 5.3.10 4 phpmyadmin 3...