一键部署wordpress脚本

部署wordpress

  • 基础环境

[root@node ~]# ls
lnmp  wordpress-5.0.2-zh_CN.tar.gz

[root@node ~]# vim local.repo
[lnmp]
name=lnmp
baseurl=file:///opt/lnmp 
gpgcheck=0
[root@node-1 
  • 编写nginx.conf

[root@node ~]# cp /etc/nginx/nginx.conf nginx.conf
[root@node ~]# vim nginx.conf       
    server{
        listen             80;
        server_name     localhost;
       location / {
            root   /usr/share/nginx/html;
            index  index.php index.html index.htm;
        }
        
        location ~ \.php$ {
            root           /usr/share/nginx/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
      }
  • 编写sh文件

[root@node ~]# vim install_wordpress.sh
#!/bin/bash
Init(){
  mv /etc/yum.repos.d/* /media/
  mv lnmp/ /opt/
  mv local.repo  /etc/yum.repos.d/
  yum install -y nginx mariadb mariadb-server php-fpm php-mysql
  systemctl start mariadb
  mysqladmin -uroot password 000000
  mysql -uroot -p000000 -e "create database wordpress;"
  mysql -uroot -p000000 -e "grant all privileges on *.* to root@'%' identified by'000000';"
  mysql -uroot -p000000 -e "grant all privileges on *.* to root@localhost identified by'000000';"
}

NginxInstall(){
  rm -rf /usr/share/nginx/html/*
  tar -zvxf wordpress-5.0.2-zh_CN.tar.gz
  cp -rvf wordpress/* /usr/share/nginx/html/
  chmod 777 /usr/share/nginx/
  cp /usr/share/nginx/html/wp-config-sample.php /usr/share/nginx/html/wp-config.php
  cp -rf nginx.conf /etc/nginx/nginx.conf
  systemctl restart nginx && systemctl restart php-fpm
}

SedConfig(){
  sed -i 's/database_name_here/wordpress/g' /usr/share/nginx/html/wp-config.php
  sed -i 's/username_here/root/g' /usr/share/nginx/html/wp-config.php
  sed -i 's/password_here/000000/g' /usr/share/nginx/html/wp-config.php
}

Init
NginxInstall
SedConfig

 

posted @ 2022-03-15 07:51  衡衡酱  阅读(4)  评论(0)    收藏  举报
Live2D