shell下比較完善的LNMP一鍵安裝包
[重要通告]如您遇疑難雜癥,本站支持知識付費業(yè)務(wù),掃右邊二維碼加博主微信,可節(jié)省您寶貴時間哦!
這是今天一個朋友說他搞了一個LNMP一鍵安裝包腳本,其實這些腳本沒必要的,因為會有很多完善的區(qū)域來操作;
代碼如下:
#!/bin/bash #by cuiyuxin zhanshi(){ echo "+------------------------------------------------+ | | | _o0o_ 1. 編譯安裝Nginx1.17.10 | | 08880 2. yum安裝Apache | | 88"."88 3. yum安裝MySQL5.7 | | (|-_-|) 4. yum安裝PHP7 | | 0\=/0 5. 部署LNMP環(huán)境 | | __/ \ 6.退出此管理程序| | ‘\ ///‘ | | / Linux一鍵 \ | | || Server || ====================== | | \ //// 一鍵安裝服務(wù) | | ||| i i i ||| by laoliang | | ___ ___ ====================== | |___‘. /--.--\ .‘___ | +------------------------------------------------+ " } install_nginx(){ #1.第一步:依賴環(huán)境安裝: echo -e "\033[41;33m 開始安裝依賴環(huán)境 \033[0m" yum install pcre pcre-devel openssl openssl-devel zlib zlib-devel -y yum install gcc gcc-c++ make libtool -y yum install wget -y #2.開始下載nginx源碼包,nginx-1.17.10 echo -e "\033[41;33m 開始下載目前穩(wěn)定版nginx-1.17.10 \033[0m" wget -P /tmp http://nginx.org/download/nginx-1.17.10.tar.gz #3.解壓nginxtar包,進行編譯 echo -e "\033[41;33m 開始解壓nginx-1.17.10 并且進行編譯 \033[0m" tar xf /tmp/nginx-1.17.10.tar.gz -C /tmp cd /tmp/nginx-1.17.10 ./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tem/nginx/client --http-proxy-temp-path=/var/tem/nginx/proxy --http-fastcgi-temp-path=/var/tem/nginx/fcgi --with-http_stub_status_module make && make install useradd -s /sbin/nologin -M nginx mkdir -p /var/tem/nginx/client if [ $? == 0 ];then echo -e "\033[41;33m nginx-1.17.10安裝完成,安裝目錄為/etc/nginx 日志目錄在/ar/log/nginx/ 輸入命令"nginx" 即可啟動nginx服務(wù) \033[0m" fi } install_apache(){ echo "開始安裝Apache請稍后" yum install httpd -y &>/dev/null if [ "$?" -eq 0 ] then echo "Apache安裝成功!" else echo "Apache安裝失?。? fi } install_mysql(){ echo "開始下載mysql 5.7的rpm安裝包" wget -P /tmp https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm echo "開始安裝mysql 5.7的rpm安裝包" yum -y localinstall /tmp/mysql57-community-release-el7-11.noarch.rpm echo "開始在線安裝MySQL 文件比較大,安裝較慢??!" yum -y install mysql-community-server if [ "$?" -eq 0 ] then echo "Mysql安裝成功!輸入命令:systemctl start mysqld 啟動Mysql" echo "mysql安裝完成之后,會在/var/log/mysqld.log文件中給root生成了一個臨時的默認密碼" else echo "Mysql安裝失??!" fi } install_php() { echo "開始移除舊的php" yum remove php-mysql-5.4 php php-fpm php-common cat >>/etc/yum.repos.d/php.repo<<'EOF' [php-fpm] name = php Repository baseurl = http://us-east.repo.webtatic.com/yum/el7/x86_64/ gpgcheck = 0 EOF echo "開始安裝php7" yum -y install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb if [ $? -eq 0 ];then echo "php7安裝成功,使用systemctl start php-fpm 來啟動php-fpm" else echo "php7安裝失敗" fi } install_lnmp(){ install_nginx install_mysql install_php } zhanshi read -p "請您輸入需要安裝的服務(wù):" NUM case $NUM in 1) install_nginx ;; 2) install_apache ;; 3) install_mysql ;; 4) install_php ;; 5) install_lnmp ;; 6) exit ;; esac
其實不用這些東西,也有比較完善的腳本~
問題未解決?付費解決問題加Q或微信 2589053300 (即Q號又微信號)右上方掃一掃可加博主微信
所寫所說,是心之所感,思之所悟,行之所得;文當(dāng)無敷衍,落筆求簡潔。 以所舍,求所獲;有所依,方所成!
賞
支付寶贊助
微信贊助
免責(zé)聲明,若由于商用引起版權(quán)糾紛,一切責(zé)任均由使用者承擔(dān)。
您必須遵守我們的協(xié)議,如您下載該資源,行為將被視為對《免責(zé)聲明》全部內(nèi)容的認可->聯(lián)系老梁投訴資源 LaoLiang.Net部分資源來自互聯(lián)網(wǎng)收集,僅供用于學(xué)習(xí)和交流,請勿用于商業(yè)用途。如有侵權(quán)、不妥之處,請聯(lián)系站長并出示版權(quán)證明以便刪除。
敬請諒解! 侵權(quán)刪帖/違法舉報/投稿等事物聯(lián)系郵箱:service@laoliang.net
意在交流學(xué)習(xí),歡迎贊賞評論,如有謬誤,請聯(lián)系指正;轉(zhuǎn)載請注明出處: » shell下比較完善的LNMP一鍵安裝包