1. 程式人生 > 其它 >一鍵安裝wordpress部落格平臺

一鍵安裝wordpress部落格平臺

#!/bin/bash
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i "s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo
mv CentOS7-Base-163.repo /etc/yum.repos.d/
yum makecache
yum install epel-release -y

yum install mariadb-server httpd wget -y #資料庫這裡使用mariadb,可自行再次指定
my=`cat /etc/my.cnf -n|grep '\[mysqld\]'|awk '{print $1}'`
let my++
sed -i ''"$my"'askip_name_resolve = NO' /etc/my.cnf

systemctl enable --now mariadb
#建立庫和使用者,可自行指定賬號密碼,後續修改php配置檔案即可
mysql -e "create database wordpress;"
mysql -e "create user wpuser@'%' identified by '123456';"
mysql -e "grant all on wordpress.* to wpuser@'%';"
#安裝httpd php
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum clean all
yum makecache
#yum -y install httpd php php-fpm php-mysqlnd php-gd wget php-mysql --skip-broken
yum install -y php72w php72w-fpm php72w-cli php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml php72w-ldap php72w-mcrypt --skip-broken
systemctl enable --now httpd php-fpm
#wget https://wordpress.org/latest.tar.gz
#tar -xf latest.tar.gz
wget https://cn.wordpress.org/latest-zh_CN.tar.gz
tar -xvf latest-zh_CN.tar.gz

mv wordpress /var/www/html/
setfacl -R -m u:apache:rwx /var/www/html/wordpress/

#若是自定義的賬號密碼這裡要修改

sed -i 's#database_name_here#wordpress#' /var/www/html/wordpress/wp-config-sample.php
sed -i 's#username_here#wpuser#' /var/www/html/wordpress/wp-config-sample.php
sed -i 's#password_here#123456#' /var/www/html/wordpress/wp-config-sample.php
sed -i 's/DocumentRoot "\/var\/www\/html"/DocumentRoot "\/var\/www\/html\/wordpress"/' /etc/httpd/conf/httpd.conf

systemctl restart httpd php-fpm mariadb


echo "開啟瀏覽器輸入本機ip 對部落格初始化"