91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

shell腳本一鍵部署LNMP架構

發布時間:2020-07-07 23:33:02 來源:網絡 閱讀:317 作者:wx5d8a17c45cb5b 欄目:系統運維

shell腳本一鍵部署LNMP架構

詳細過程請看上篇文章:LNMP搭建過程
軟件包:鏈接:https://pan.baidu.com/s/1smqzl0usPj6rqsFUQCUAnA
提取碼:tbvt

下面給出腳本(適用于尚未搭建過的服務器):

軟件包路徑:

[root@localhost ~]# ls tar/LNMP-C7/
Discuz_X3.4_SC_UTF8.zip php-7.1.10.tar.bz2
mysql-boost-5.7.20.tar.gz php-7.1.20.tar.bz2
ncurses-5.6.tar.gz php-7.1.20.tar.gz
nginx-1.12.2.tar.gz zend-loader-php5.6-linux-x86_64_update1.tar.gz
php-5.6.11.tar.bz2

1.main.sh(將三個腳本放入main.sh中逐一執行)

#!/bin/bash
./nginx.sh
./mysql.sh 123456  //mysqladmin 免交互時所需的密碼可以自己設置
./php.sh

2.nginx.sh

#!/bin/bash
#該腳本是實現Nginx的手工編譯安裝
pkgpath=~/tar/LNMP-C7/
nginxpath=/usr/local/nginx/
nginx_serpath=/lib/systemd/system/nginx.service

systemctl stop firewalld.service 
setenforce 0
echo "正在安裝所需環境相關軟件包"
yum install -y gcc gcc-c++ make pcre pcre-devel zlib-devel &> /dev/null 
if test $? != 0
then 
    echo "環境安裝有誤,準備退出..."
    sleep 1
    exit 
fi

cd $pkgpath 
tar zxf nginx-1.12.2.tar.gz -C /opt/
#指定用戶但不創建家目錄
egrep "^nginx" /etc/passwd >& /dev/null
if [ $? -ne 0 ]
then
    useradd -M -s /sbin/nologin nginx
fi
#參數配置
echo "正在配置相關參數..."
sleep 2
cd /opt/nginx-1.12.2/
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module &> /dev/null
if test $? == 0
then 
    echo "配置參數正確!"
else
    echo "配置參數有誤!"
    exit 1
fi

echo "正在編譯..."

make &> /dev/null 
if test $? == 0
then 
    echo "編譯成功!"
else
    echo "編譯有誤!"
    exit 1
fi

echo "正在安裝..."
make install &> /dev/null
if test $? == 0
then 
    echo "安裝成功!"
else
    echo "安裝失敗!"
    exit 1
fi
ln -s $nginxpathsbin/nginx /usr/local/sbin/

cat  >$nginx_serpath <<EOF
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/bin/kill -s HUP $MAINPID
ExecStop=/usr/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
chmod 754 $nginx_serpath
systemctl restart nginx.service
if test $? == 0
then 
    echo "nginx 服務啟動完成!"
else
    echo "nginx 服務啟動失敗!"
    exit 1
fi

3.mysql.sh

#!/bin/bash
if test $# != 1
then 
    echo "error!"
    exit
fi
#手工編譯安裝MySQL腳本
pkgpath=~/tar/LNMP-C7/
mysqlpath=/usr/local/mysql 

#安裝所需環境軟件包
echo "安裝所需環境軟件包..."
yum install -y ncurses ncurses-devel bison cmake  expect &> /dev/null
if test $? != 0
then 
    echo "環境安裝有誤,準備退出..."
    sleep 1
    exit 
fi
#ncurses 字符終端包 bison 函數庫 cmake 編譯工具

#創建非登錄用戶
egrep "^mysql" /etc/passwd &> /dev/null
if [ $? -ne 0 ]
then
    useradd -s /sbin/nologin mysql
fi

#解壓縮mysql軟件包
cd  $pkgpath
tar zxf mysql-boost-5.7.20.tar.gz -C /opt/

#配置參數設置
echo "正在執行配置參數設置..."
sleep 2
cd /opt/mysql-5.7.20/
cmake \
-DCMKAE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/etc \
-DSYSTEMD_PID_DIR=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=boost \
-DWITH_SYSTEMD=1 &> /dev/null
if test $? == 0
then 
    echo "配置參數正確!"
else
    echo "配置參數有誤!"
    exit 1
fi
echo "正在編譯..."
echo "編譯所需時間較長,請耐心等待(20-45min)..."
sleep 3
make &> /dev/null
if test $? == 0
then 
    echo "編譯成功!"
else
    echo "編譯失敗!"
    exit 1
fi
echo "正在安裝..."
make install &> /dev/null 
if test $? == 0
then 
    echo "安裝成功!"
else
    echo "安裝失敗!"
    exit 1
fi
cd /usr/local
chown -R mysql.mysql mysql/
cat >/etc/my.cnf <<EOF
[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysql]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
EOF

chown mysql.mysql /etc/my.cnf
#echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
#echo 'export PATH' >> /etc/profile
#source /etc/profile
ln -s $mysqlpath/bin/* /usr/local/bin/ 
ln -s $mysqlpath/lib/* /usr/local/bin/
cd $mysqlpath 
bin/mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data >& /dev/null 

cp usr/lib/systemd/system/mysqld.service /lib/systemd/system/

systemctl start mysqld.service 

passwd=$1
/usr/bin/expect <<-EOF
spawn mysqladmin -u root -p password 
expect {
    "Enter password:"
    { send "\r";exp_continue }
    "New password:"
    { send "$1\r";exp_continue }
    "Confirm new password:"
    { send "$1\r"; }
}
expect eof
EOF

echo "數據庫登錄密碼設置完成,請稍后手動創建自己的數據庫..."

4.php.sh

#!/bin/bash
#手工編譯安裝php
pkgpath=~/tar/LNMP-C7/
php_inifile=/usr/local/php/lib/php.ini

echo "正在安裝所需軟件環境"
yum install -y \
libjpeg \
libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel &> /dev/null
if test $? != 0
then 
    echo "環境安裝有誤,準備退出..."
    sleep 1
    exit 
fi

echo "正在解壓縮軟件包(PHP)"
cd $pkgpath
tar jxf php-7.1.10.tar.bz2 -C /opt/
echo "正在配置相關參數..."
cd /opt/php-7.1.10/
./configure \
--prefix=/usr/local/php \
--with-mysql-sock=/usr/local/mysql/mysql.sock \
--with-mysqli \
--with-zlib \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--enable-fpm \
--enable-mbstring \
--enable-xml \
--enable-session \
--enable-ftp \
--enable-pdo \
--enable-tokenizer \
--enable-zip &> /dev/null
if test $? == 0
then 
    echo "配置參數正確!"
else 
    echo "配置參數有誤!"
    exit 1
fi
echo "正在編譯,請耐心等待...(8-20min)"
make &> /dev/null
if test $? == 0
then 
    echo "編譯成功!"
else 
    echo "編譯失敗!"
    exit 1
fi
echo "正在安裝,馬上就好..."
make install &> /dev/null 
if test $? == 0
then 
    echo "安裝成功!"
else 
    echo "安裝失敗!"
    exit 1
fi
#進行相關優化和必要配置
echo "php有三個配置文件 php.ini:核心配置文件 php-fpm.conf:進程服務配置文件 www.conf:擴展配置文件"
echo "進行核心文件配置..."
cp php.ini-development $php_inifile
sed -i '/mysqli.default_socket =/ s/$/ \/usr\/local\/mysql\/mysql.sock/p' $php_inifile
sed -i '/;date.timezone =/ s/^;//' $php_inifile
sed -i '/date.timezone =/ s/$/ Asia\/Shanghai/p' $php_inifile
echo "核心配置文件配置完畢!"
echo "進行進程服務配置文件設置..."
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf
sed -i '/;pid/ s/^;//' /usr/local/php/etc/php-fpm.conf 
echo "進程服務配置文件配置完畢!"

echo "進行擴展配置文件配置..."
cd /usr/local/php/etc/php-fpm.d/ 
cp www.conf.default www.conf
echo "配置完成!"

echo "啟動中..."
/usr/local/php/sbin/php-fpm -c $php_inifile
echo "初始化完成,創建命令軟鏈接..."
ln -s /usr/local/php/bin/* /usr/local/bin/
echo "更改Nginx主配置文件,以支持PHP功能"
cat > b.txt <<EOF
location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html\$fastcgi_script_name;
            include        fastcgi_params;
        }
EOF
sed -i '/# pass/ r b.txt' /usr/local/nginx/conf/nginx.conf 
sleep 3
rm b.txt
echo "Nginx配置文件設置完畢!"
echo "重啟Nginx服務..."
systemctl restart nginx.service

echo "創建PHP首頁..."
cd /usr/local/nginx/html/
mv index.html index.php
cat >index.php <<EOF
<?php
    phpinfo();
?>
EOF
echo "php測試文件寫入完畢!"

5.創建自己的數據庫

mysql -uroot -p (交互輸入密碼腳本給的密碼是123456)
create database mydb;
grant all on mydb. to 'mydbuser'@'%' identified by '123123';
grant all on mydb.
to 'mydbuser'@'localhost' identified by '123123';
flush privileges;
quit

6.Discuz論壇搭建配置腳本discu.sh

#!/bin/bash
echo "discuz論壇設置..."
cd ~/tar/LNMP-C7/
unzip Discuz_X3.4_SC_UTF8.zip -d /opt/  &> /dev/null 
cd /opt/dir_SC_UTF8/

cp -r upload/ /usr/local/nginx/html/mydb
cd /usr/local/nginx/html/mydb/
chown -R root:nginx ./config/
chown -R root:nginx ./data/
chown -R root:nginx ./uc_client/
chown -R root:nginx ./uc_server/
chmod -R 777 ./config/
chmod -R 777 ./data/
chmod -R 777 ./uc_client/
chmod -R 777 ./uc_server/

之后的步驟操作參照上篇文章:手工編譯搭建LNMP架構

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

叶城县| 汉沽区| 尤溪县| 虹口区| 张掖市| 府谷县| 和政县| 孟连| 杂多县| 安康市| 崇左市| 江陵县| 浙江省| 涿州市| 贵港市| 常州市| 榆中县| 桑植县| 阿鲁科尔沁旗| 忻州市| 双桥区| 朝阳区| 蒙阴县| 夹江县| 新源县| 无锡市| 苍南县| 团风县| 渝中区| 台南市| 申扎县| 府谷县| 南丹县| 丽水市| 瑞安市| 河北区| 淳化县| 水城县| 南城县| 翼城县| 吉首市|