centos下使用shell腳本自動安裝程式
- 2019 年 12 月 11 日
- 筆記
用shell安裝程式非常方便,省得每一步都需要人為操作,在這裡我自己嘗試安裝了PHP7到伺服器,已經測試成功了我將我寫的腳本分享出來,希望能幫助到一部分朋友!
#!/bin/bash #PHP7.0安裝腳本 #author Sindsun #date 2019年4月9日13:39:45 #:set ff=unix #先停止php-fpm if [ -f "/etc/init.d/php-fpm" ]; then /etc/init.d/php-fpm stop fi service php-fpm stop #添加新用戶和組 groupadd nginx useradd -g nginx nginx #執行卸載 rm -rf /usr/local/php* rm -rf /usr/bin/php* rm -rf /usr/sbin/php* rm -rf /var/lib/php* rm -rf /usr/lib64/php* rm -rf /usr/share/php* #安裝依賴 wget -P /usr/src http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz cd /usr/src tar -zxvf /usr/src/libmcrypt-2.5.8.tar.gz cd /usr/src/libmcrypt-2.5.8 ./configure make && make install yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel cd /usr/src/php #編譯php /usr/src/php/configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-config-file-scan-dir=/usr/local/php7/etc/php.d --with-mcrypt=/usr/include --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-gd --with-iconv --with-zlib --enable-xml --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache #安裝 make && make install #新建目錄 mkdir /usr/local/php7/tmp chmod -R 777 /usr/local/php7/tmp #移動複製配置文件 cp /usr/src/php/php.ini-dev /usr/local/php7/etc/php.ini if [ -f "/etc/init.d/php-fpm" ]; then mv /etc/init.d/php-fpm /etc/init.d/php-fpm-20190409 fi cp /usr/src/php/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf #添加環境變數 echo 'export PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH' >> /etc/profile source /etc/profile #添加自啟動 chkconfig --add php-fpm chkconfig php-fpm on chkconfig --list php-fpm #啟動服務 chmod 777 /etc/init.d/php-fpm /etc/init.d/php-fpm start /usr/local/nginx/sbin/nginx -s reload
版權聲明: 此文為本站源創文章[或由本站編輯從網路整理改編], 轉載請備註出處: [ 狂碼一生] http://www.sindsun.com/article-details-107.html