1. ~ vim reset_centos.sh
    2. #!/bin/bash
    3. #Initialize the system script
    4. #SHELL ENV
    5. BASECOLOR="\E[1;46m"
    6. WARNCOLOR="\E[1;5;31m"
    7. ENDCOLOR="\E[0m"
    8. #yum install -y cowsay
    9. #SHELL Function
    10. function set_alias() {
    11. echo -e "${BASECOLOR}Starting set alias......${ENDCOLOR}"
    12. echo "" >> /etc/bashrc
    13. cat >> /etc/bashrc <<-'EOF'
    14. # Bash Alias Starting
    15. alias cdnet='cd /etc/sysconfig/network-scripts/'
    16. alias cdyum='cd /etc/yum.repos.d/'
    17. alias nm='systemctl restart NetworkManager'
    18. alias disepel='sed -ri /enabled/s/enabled=1/enabled=0/ /etc/yum.repos.d/base.repo'
    19. alias egrep='egrep --color=auto'
    20. alias epel='sed -ri /enabled/s/enabled=0/enabled=1/ /etc/yum.repos.d/base.repo'
    21. alias fgrep='fgrep --color=auto'
    22. alias i.='ls -d .* --color=auto'
    23. alias lh='ls -lh --color=auto'
    24. alias more='more -d'
    25. alias p='poweroff'
    26. alias restart='systemctl restart '
    27. alias restartnet='systemctl restart network'
    28. alias scandisk='echo "- - -" > /sys/class/scsi_host/host0/scan;\
    29. echo "- - -" > /sys/class/scsi_host/host1/scan;\
    30. echo "- - -" > /sys/class/scsi_host/host2/scan'
    31. alias vie0='vim /etc/sysconfig/network-scripts/ifcfg-eth0'
    32. alias vie1='vim /etc/sysconfig/network-scripts/ifcfg-eth1'
    33. alias xzfgrep='xzfgrep --color=auto'
    34. alias xzgrep=' xzgrep --color=auto'
    35. alias yr='yum remove'
    36. alias yy='yum -y install'
    37. alias zegrep='zegrep --color=auto'
    38. alias zfgrep='zfgrep --color=auto'
    39. alias zgrep='zgrep --color=auto'
    40. alias more='more -d'
    41. # Bash Alias End
    42. EOF
    43. echo -e "${BASECOLOR}Alias set finished......${ENDCOLOR}"
    44. }
    45. function set_command_prompt() {
    46. FILE="/etc/bashrc"
    47. echo -e "${BASECOLOR}"
    48. cat <<-'EOF'
    49. 1:(Red)
    50. 2:(Green)
    51. 3:(Yellow)
    52. 4:(Blue)
    53. 5:(Pink)
    54. 6:(Light Blue)
    55. EOF
    56. echo -e "${ENDCOLOR}"
    57. echo "" >> ${FILE}
    58. echo "# System Command Prompt ENV EBGIN" >> ${FILE}
    59. ENDCOMMAND=`echo '# System Command Prompt ENV END' >> ${FILE}`
    60. read -p "Command prompt color modification:" OPTIONS
    61. case ${OPTIONS} in
    62. 1)
    63. echo 'PS1="\[\e[1;31m\][\u@\h \W]\\$\[\e[0m\]"' >> ${FILE}
    64. ${ENDCOMMAND}
    65. ;;
    66. 2)
    67. echo 'PS1="\[\e[1;32m\][\u@\h \W]\\$\[\e[0m\]"' >> ${FILE}
    68. ${ENDCOMMAND}
    69. ;;
    70. 3)
    71. echo 'PS1="\[\e[1;33m\][\u@\h \W]\\$\[\e[0m\]"' >> ${FILE}
    72. ${ENDCOMMAND}
    73. ;;
    74. 4)
    75. echo 'PS1="\[\e[1;34m\][\u@\h \W]\\$\[\e[0m\]"' >> ${FILE}
    76. ${ENDCOMMAND}
    77. ;;
    78. 5)
    79. echo 'PS1="\[\e[1;35m\][\u@\h \W]\\$\[\e[0m\]"' >> ${FILE}
    80. ${ENDCOMMAND}
    81. ;;
    82. 6)
    83. echo 'PS1="\[\e[1;36m\][\u@\h \W]\\$\[\e[0m\]"' >> ${FILE}
    84. ${ENDCOMMAND}
    85. ;;
    86. *)
    87. echo -e "${BASECOLOR}Your input options are wrong${ENDCOLOR}"
    88. ;;
    89. esac
    90. }
    91. function set_yum() {
    92. echo -e "${BASECOLOR}Starting set Yum Repo......${ENDCOLOR}"
    93. mkdir -pv /etc/yum.repos.d/repobackup &> /dev/null
    94. mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/repobackup &> /dev/null
    95. # Determine the operating system type
    96. # (currently, CentOS7 and CentOS8 are supported)
    97. OS_VERSION=$(cat /etc/redhat-release|cut -d" " -f4|awk -F"." '{print $1}')
    98. case $OS_VERSION in
    99. 7)
    100. cat > /etc/yum.repos.d/CentOS7-all.repo <<END
    101. [CentOS7-Base]
    102. name=CentOS7-Base
    103. baseurl=https://mirrors.cloud.tencent.com/centos/\$releasever/os/\$basearch/
    104. https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/os/\$basearch/
    105. http://mirrors.163.com/centos/\$releasever/os/\$basearch/
    106. https://repo.huaweicloud.com/centos/\$releasever/os/\$basearch/
    107. https://mirrors.aliyun.com/centos/\$releasever/os/\$basearch/
    108. enabled=1
    109. gpgcheck=0
    110. [CentOS7-extras]
    111. name=CentOS7-extras
    112. baseurl=https://mirrors.cloud.tencent.com/centos/\$releasever/extras/\$basearch/
    113. https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/extras/\$basearch/
    114. http://mirrors.163.com/centos/\$releasever/extras/\$basearch/
    115. https://repo.huaweicloud.com/centos/\$releasever/extras/\$basearch/
    116. https://mirrors.aliyun.com/centos/\$releasever/extras/\$basearch/
    117. enabled=1
    118. gpgcheck=0
    119. [CentOS7-epel]
    120. name=CentOS7-epel
    121. baseurl=https://mirrors.aliyun.com/epel/\$releasever/\$basearch/
    122. https://repo.huaweicloud.com/epel/\$releasever/\$basearch/
    123. https://mirrors.tuna.tsinghua.edu.cn/epel/\$releasever/\$basearch/
    124. https://mirrors.cloud.tencent.com/epel/\$releasever/\$basearch/
    125. enabled=1
    126. gpgcheck=0
    127. [CentOS7-updates]
    128. name=CentOS7-updates
    129. baseurl=https://mirrors.cloud.tencent.com/centos/\$releasever/updates/\$basearch/
    130. https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/updates/\$basearch/
    131. http://mirrors.163.com/centos/\$releasever/updates/\$basearch/
    132. https://repo.huaweicloud.com/centos/\$releasever/updates/\$basearch/
    133. https://mirrors.aliyun.com/centos/\$releasever/updates/\$basearch/
    134. enabled=1
    135. gpgcheck=0
    136. END
    137. ;;
    138. 8)
    139. cat > /etc/yum.repos.d/CentOS8-all.repo <<END
    140. [CentOS8-vault-BaseOS]
    141. name=CentOS8-vault-BaseOS
    142. baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/BaseOS/\$basearch/os/
    143. http://mirrors.aliyuncs.com/centos-vault/8.5.2111/BaseOS/\$basearch/os/
    144. http://mirrors.cloud.aliyuncs.com/centos-vault/8.5.2111/BaseOS/\$basearch/os/
    145. https://mirrors.tuna.tsinghua.edu.cn/centos-vault/8.5.2111/BaseOS/\$basearch/os/
    146. https://repo.huaweicloud.com/centos-vault/8.5.2111/BaseOS/\$basearch/os/
    147. https://mirrors.cloud.tencent.com/centos-vault/8.5.2111/BaseOS/\$basearch/os/
    148. enabled=1
    149. gpgcheck=0
    150. [CentOS8-vault-AppStream]
    151. name=CentOS8-vault-AppStream
    152. baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/AppStream/\$basearch/os/
    153. http://mirrors.aliyuncs.com/centos-vault/8.5.2111/AppStream/\$basearch/os/
    154. http://mirrors.cloud.aliyuncs.com/centos-vault/8.5.2111/AppStream/\$basearch/os/
    155. https://mirrors.tuna.tsinghua.edu.cn/centos-vault/8.5.2111/AppStream/\$basearch/os/
    156. https://mirrors.cloud.tencent.com/centos-vault/8.5.2111/AppStream/\$basearch/os/
    157. enabled=1
    158. gpgcheck=0
    159. [CentOS8-extras]
    160. name=CentOS8-extras
    161. baseurl=https://mirrors.cloud.tencent.com/centos/\$releasever/extras/\$basearch/os/
    162. https://repo.huaweicloud.com/centos/\$releasever/extras/\$basearch/os/
    163. https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/extras/\$basearch/os/
    164. https://mirrors.aliyun.com/centos/\$releasever/extras/\$basearch/os/
    165. https://repo.huaweicloud.com/centos-vault/8.5.2111/AppStream/\$basearch/os/
    166. enabled=1
    167. gpgcheck=0
    168. [CentOS8-epel]
    169. name=CentOS8-epel
    170. baseurl=https://mirrors.aliyun.com/epel/\$releasever/Everything/source/tree/
    171. https://mirrors.tuna.tsinghua.edu.cn/epel/\$releasever/Everything/source/tree/
    172. https://repo.huaweicloud.com/epel/\$releasever/Everything/\$basearch/
    173. https://mirrors.cloud.tencent.com/epel/\$releasever/Everything/\$basearch/
    174. enabled=1
    175. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
    176. gpgcheck=1
    177. END
    178. ;;
    179. *)
    180. echo "${WARNCOLOR}The operating system was not found${ENDCOLOR}"
    181. exit
    182. ;;
    183. esac
    184. echo -e "${BASECOLOR}Set Yum Repo finished......${ENDCOLOR}"
    185. }
    186. function set_software() {
    187. echo -e "${BASECOLOR}Staring install software......${ENDCOLOR}"
    188. yum install -y gcc make gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel zlib-devel vim lrzsz tree tmux lsof tcpdump wget net-tools iotop bc bzip2 zip unzip nfs-utils man-pages cowsay
    189. cowsay "Common software packages such as Tree, FTP, LFTP, and Telnet are installed"
    190. }
    191. function set_firewalld() {
    192. #Check the operating system type
    193. VERSION=$(cat /etc/os-release|grep "^ID="|tr -dc [a-z])
    194. echo -e "${BASECOLOR}Disabling the Firewall${ENDCOLOR}"
    195. case $VERSION in
    196. ubuntu)
    197. service ufw stop &> /dev/null
    198. ufw disable &> /dev/null
    199. echo -e "${BASECOLOR}The Firewall is stop${ENDCOLOR}"
    200. ;;
    201. centos)
    202. NUMBER=$(cat /etc/redhat-release|tr -dc [0-9]|head -c1)
    203. if [ $NUMBER -le 6 ];then
    204. service iptables stop
    205. chkconfig iptables off
    206. elif [ $NUMBER -ge 7 ];then
    207. systemctl stop firewalld
    208. systemctl disable firewalld
    209. fi
    210. echo -e "${BASECOLOR}The Firewall is stop${ENDCOLOR}"
    211. #Close the SELINUX
    212. echo -e "${BASECOLOR}Disabling the SELINUX${ENDCOLOR}"
    213. sed -i -r '/^SELINUX=/s#(.*)=.*#\1=disabled#g' /etc/selinux/config
    214. echo -e "${BASECOLOR}The SELINUX is stop${ENDCOLOR}"
    215. ;;
    216. *)
    217. echo -e "${ENDCOLOR}Sorry, this script does not support this operating system${ENDCOLOR}"
    218. exit;
    219. ;;
    220. esac
    221. }
    222. function set_network() {
    223. #Check the operating system type
    224. VERSION=$(cat /etc/os-release|grep "^ID="|tr -dc [a-z])
    225. echo -e "${BASECOLOR}Reset Network Card Name${ENDCOLOR}"
    226. case $VERSION in
    227. ubuntu)
    228. sed -i.bak -r '/^GRUB_CMDLINE_LINUX=/s@(.*=).*@\1"net.ifnames=0"@g' /etc/default/grub
    229. grub-mkconfig -o /boot/grub/grub.cfg
    230. read -p "Restart the operating system for the configuration to take effect(Yes|No) : " CHOICE
    231. while true;do
    232. case $CHOICE in
    233. [Yy]|[Yy][Ee][Ss])
    234. echo -e "${WARNCOLOR}Starting Reboot System(Last time:5 second)${ENDCOLOR}"
    235. sleep 5
    236. reboot
    237. ;;
    238. [Nn]|[Nn][Oo])
    239. echo -e "${WARNCOLOR}Restart the system later for the configuration to take effect${ENDCOLOR}"
    240. break
    241. ;;
    242. *)
    243. echo -e "${WARNCOLOR}Your input is wrong\nPlease re-enter${ENDCOLOR}"
    244. exit
    245. ;;
    246. esac
    247. done
    248. ;;
    249. centos)
    250. sed -i.bak -r '/^GRUB_CMDLINE_LINUX=/s#(.*)="(.*)"#\1="\2 net.ifnames=0"#g' /etc/default/grub
    251. grub2-mkconfig -o /boot/grub2/grub.cfg
    252. read -p "Restart the operating system for the configuration to take effect(Yes|No) : " CHOICE
    253. while true;do
    254. case $CHOICE in
    255. [Yy]|[Yy][Ee][Ss])
    256. echo -e "${WARNCOLOR}Starting Reboot System(Last time:5 second)${ENDCOLOR}"
    257. sleep 5
    258. reboot
    259. ;;
    260. [Nn]|[Nn][Oo])
    261. echo -e "${WARNCOLOR}Restart the system later for the configuration to take effect${ENDCOLOR}"
    262. break
    263. ;;
    264. *)
    265. echo -e "${WARNCOLOR}Your input is wrong\nPlease re-enter${ENDCOLOR}"
    266. exit
    267. ;;
    268. esac
    269. done
    270. ;;
    271. *)
    272. echo -e "${ENDCOLOR}Sorry, this script does not support this operating system${ENDCOLOR}"
    273. exit;
    274. ;;
    275. esac
    276. }
    277. function set_vim_format() {
    278. cat > ~/.vimrc <<EOF
    279. set number
    280. set cursorline
    281. set paste
    282. set textwidth=65
    283. set expandtab
    284. set tabstop=4
    285. autocmd BufNewFile *.sh exec ":call SetTitle()"
    286. func SetTitle()
    287. if expand("%:e") == "sh"
    288. call setline(1,"#!/bin/bash")
    289. call setline(2,"#")
    290. call setline(3,"#**************************************************#")
    291. call setline(4,"#Author: kubesphere")
    292. call setline(5,"#QQ: www.935523993.com")
    293. call setline(6,"#Date: ".strftime("%Y-%m-%d"))
    294. call setline(7,"#FileName: ".expand("%"))
    295. call setline(8,"#URL: http://www.kubesphere.com")
    296. call setline(9,"#Description: The script is kubesphere")
    297. call setline(10,"#Copyright(C): ".strftime("%Y")."All rights reserved")
    298. call setline(11,"#**************************************************#")
    299. call setline(12,"")
    300. endif
    301. endfunc
    302. autocmd BufNewFile * normal G
    303. EOF
    304. }
    305. while true;do
    306. cat <<EOF
    307. (1) 设置命令别名
    308. (2) 设置命令提示符颜色
    309. (3) Yum仓库配置
    310. (4) 安装常用 tree,ftp,lftp,telnet 等包
    311. (5) 配置防火墙(关闭firewalld selinux)
    312. (6) 初始化网卡名(将网卡名改为传统命名方式:eth<Number>)
    313. (7) 设置VIM常用格式设置
    314. (8) 以上全部执行
    315. (9) 退出脚本
    316. EOF
    317. read -p "Please input your hope choice : " CHOICE
    318. case $CHOICE in
    319. 1)
    320. set_alias
    321. ;;
    322. 2)
    323. set_command_prompt
    324. ;;
    325. 3)
    326. set_yum
    327. ;;
    328. 4)
    329. set_yum
    330. set_software
    331. ;;
    332. 5)
    333. set_firewalld
    334. ;;
    335. 6)
    336. set_network
    337. ;;
    338. 7)
    339. set_vim_format
    340. ;;
    341. 8)
    342. set_alias
    343. set_command_prompt
    344. set_yum
    345. set_software
    346. set_firewalld
    347. set_network
    348. set_vim_format
    349. ;;
    350. 9)
    351. break
    352. exit
    353. ;;
    354. *)
    355. echo -e "${WARNCOLOR}Your input number error${ENDCOLOR}"
    356. ;;
    357. esac
    358. done
    #!/bin/bash
    #Description:       LNMP wordpress 博客系统 
    SRC_DIR=/usr/local/src
    NGINX='nginx-1.18.0.tar.gz'
    MYSQL='mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz'
    PHP='php-7.4.10.tar.xz'
    APP='wordpress-5.6.2-zh_CN.tar.gz'
    COLOR="echo -e \\033[01;31m"
    END='\033[0m'
    MYSQL_ROOT_PASSWORD=laowang
    MYSQL_WORDPRESS_PASSWORD=laowang
    CPU=`lscpu| awk '/^CPU\(s\):/{print $NF}'`
    
    ${COLOR}'开始安装基于LNMP的wordpress'$END
    sleep 3
    
    check_file (){
    cd  $SRC_DIR
    $COLOR"请将相关软件放在${SRC_DIR}目录下"$END
    if [ ! -e $NGINX ];then
        $COLOR"缺少${NGINX}文件"$END
            exit
    elif [ !  -e $MYSQL ];then
            $COLOR"缺少${MYSQL}文件"$END
            exit
    elif [ ! -e $PHP ];then
            $COLOR"缺少${PHP}文件"$END
            exit
    elif [ ! -e $APP ];then
            $COLOR"缺少${APP}文件"$END
            exit
    else
        $COLOR"相关文件已准备好"$END
    fi
    } 
    install_mysql(){
        $COLOR"开始安装MySQL数据库"$END
        cd $SRC_DIR
        tar xf $MYSQL -C /usr/local/
        if [ -e /usr/local/mysql ];then
            $COLOR"数据库已存在,安装失败"$END
            exit
        fi
        MYSQL_DIR=`echo $MYSQL| sed -nr 's/^(.*[0-9]).*/\1/p'`
        ln -s  /usr/local/$MYSQL_DIR /usr/local/mysql
        chown -R  root.root /usr/local/mysql/
        id mysql &> /dev/null || { useradd -s /sbin/nologin -r  mysql ; $COLOR"创建mysql用户"$END; }
        yum  -y -q install numactl-libs   libaio &> /dev/null
    
        echo 'PATH=/usr/local/mysql/bin/:$PATH' > /etc/profile.d/lamp.sh
        .  /etc/profile.d/lamp.sh
        cat > /etc/my.cnf <<-EOF
    [mysqld]
    server-id=1
    log-bin
    datadir=/data/mysql
    socket=/data/mysql/mysql.sock                                                                                                   
    log-error=/data/mysql/mysql.log
    pid-file=/data/mysql/mysql.pid
    [client]
    socket=/data/mysql/mysql.sock
    EOF
        [ -d /data ] || mkdir /data
        mysqld --initialize --user=mysql --datadir=/data/mysql 
        cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld
        chkconfig --add mysqld
        chkconfig mysqld on
        service mysqld start
        [ $? -ne 0 ] && { $COLOR"数据库启动失败,退出!"$END;exit; }
        MYSQL_OLDPASSWORD=`awk '/A temporary password/{print $NF}' /data/mysql/mysql.log`
        mysqladmin  -uroot -p$MYSQL_OLDPASSWORD password $MYSQL_ROOT_PASSWORD &>/dev/null
        $COLOR"数据库安装完成"$END
    }
    
    install_nginx(){
       ${COLOR}"开始安装NGINX"$END
       id nginx  &> /dev/null || { useradd -s /sbin/nologin -r  nginx; $COLOR"创建nginx用户"$END; }
       $COLOR"安装nginx相关包"$END
       yum -q -y install gcc pcre-devel openssl-devel zlib-devel perl-ExtUtils-Embed git &> /dev/null
       cd $SRC_DIR
       tar xf $NGINX 
    #   git clone https://github.com/openresty/echo-nginx-module.git || { $COLOR"下载NGINX第三方模块失败,退出!"$END;exit; }
       NGINX_DIR=`echo $NGINX| sed -nr 's/^(.*[0-9]).*/\1/p'`
       cd $NGINX_DIR
       ./configure --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_perl_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module 
       make -j $CPU && make install 
       [ $? -eq 0 ] && $COLOR"NGINX编译安装成功"$END ||  { $COLOR"NGINX编译安装失败,退出!"$END;exit; }
       [ -d /data/www ] || mkdir -pv /data/www/
       cat > /apps/nginx/conf/nginx.conf <<EOF
    worker_processes  auto;
    events {
        worker_connections  10240;
    }
    http {
        include       mime.types;
        default_type  application/octet-stream;
        server_tokens off;
        log_format  main  '\$remote_addr - \$remote_user [\$time_local] "\$request" '
        sendfile        on;
        client_max_body_size 100m;
        keepalive_timeout  65;
        server {
            listen       80 default_server;
            server_name  localhost ; 
            root /data/www ;
            access_log  logs/nginx.access.log  main;
            location / {
                root   /data/www/;
                index  index.php index.html index.htm;
            }
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
            location ~ \.php$ {
                root           /data/www;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  \$document_root\$fastcgi_script_name;
                include        fastcgi_params;
            }
        }
    }
    EOF
        echo  'PATH=/apps/nginx/sbin:$PATH' >> /etc/profile.d/lamp.sh
        cat > /usr/lib/systemd/system/nginx.service <<EOF
    [Unit]
    After=network.target remote-fs.target nss-lookup.target 
    
    [Service]
    Type=forking 
    
    ExecStart=/apps/nginx/sbin/nginx
    
    ExecReload=/apps/nginx/sbin/nginx -s reload
    
    ExecStop=/apps/nginx/sbin/nginx -s stop
    
    [Install]
    WantedBy=multi-user.target
    EOF
    
        systemctl daemon-reload
        systemctl start nginx 
        systemctl is-active nginx &> /dev/null ||  { $COLOR"NGINX 启动失败,退出!"$END ; exit; }
        $COLOR"NGINX安装完成"
    }
    install_php (){
        ${COLOR}"开始安装PHP"$END
        yum -y -q  install gcc make libxml2-devel bzip2-devel libmcrypt-devel libsqlite3x-devel oniguruma-devel &>/dev/null
        cd $SRC_DIR
        tar xf $PHP
        PHP_DIR=`echo $PHP| sed -nr 's/^(.*[0-9]).*/\1/p'`
        cd $PHP_DIR
         ./configure --prefix=/apps/php74 --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl    --with-zlib  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets --enable-fpm --enable-maintainer-zts --disable-fileinfo
        make -j $CPU && make install 
        [ $? -eq 0 ] && $COLOR"PHP编译安装成功"$END ||  { $COLOR"PHP编译安装失败,退出!"$END;exit; }
        cp php.ini-production  /etc/php.ini
        mkdir /etc/php.d/
        cat > /etc/php.d/opcache.ini <<EOF
    [opcache]
    zend_extension=opcache.so               
    opcache.enable=1
    EOF
    
        cp  sapi/fpm/php-fpm.service /usr/lib/systemd/system/
        cd /apps/php74/etc
        cp  php-fpm.conf.default  php-fpm.conf
        cd  php-fpm.d/
        cp www.conf.default www.conf
        id nginx  &> /dev/null || { useradd -s /sbin/nologin -r  nginx; $COLOR"创建nginx用户"$END; }
        sed -i.bak  -e  's/^user.*/user = nginx/' -e 's/^group.*/group = nginx/' /apps/php74/etc/php-fpm.d/www.conf
        systemctl daemon-reload
        systemctl start php-fpm 
        systemctl is-active  php-fpm &> /dev/null ||  { $COLOR"PHP-FPM 启动失败,退出!"$END ; exit; }
        $COLOR"PHP安装完成"
    
    }
    install_wordpress(){
        cd $SRC_DIR
        tar xf $APP  
        [ -d /data/www ] || mkdir -pv /data/www
        mv wordpress/* /data/www/
        chown -R nginx.nginx /data/www/wp-content/
        cd /data/www/
        mv wp-config-sample.php wp-config.php
        mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -e "create database wordpress;grant all on wordpress.* to wordpress@'127.0.0.1' identified by '$MYSQL_WORDPRESS_PASSWORD'" &>/dev/null
        sed -i.bak -e 's/database_name_here/wordpress/' -e 's/username_here/wordpress/' -e 's/password_here/'''$MYSQL_WORDPRESS_PASSWORD'''/' -e 's/localhost/127.0.0.1/'  wp-config.php
        $COLOR"WORDPRESS安装完成"
    }
    
    check_file
    install_mysql
    install_nginx
    install_php
    install_wordpress