Centos7安装WordPress

第一步:安装lamp

yum install sudo
1.apache
yum install httpd
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

2.mariadb
yum -y install mariadb-server mariadb
systemctl start mariadb
mysql_secure_installation

3.php7.2
yum-config-manager --enable remi-php72
yum -y install php php-opcache
yum -y install php-mysqlnd php-pdo
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel

systemctl restart httpd.service

systemctl start httpd.service
systemctl stop httpd.service
systemctl start mariadb.service
sudo systemctl enable mariadb.service

测试
vi /var/www/html/info.php

systemctl restart httpd.service
hgoods.site/info.php

测试
systemctl restart mariadb.service
mysql -u root -p

第二步:wordpress软件安装
方法一:下载安装
mkdir wp
cd wp
yum -y install wget unzip net-tools
wget http://wordpress.org/latest.zip
unzip -q latest.zip
cp -rf wordpress/* /var/www/html/
chown -R apache:apache /var/www/html/
chmod -R 755 /var/www/html/
mkdir -p /var/www/html/wp-content/uploads
chown -R :apache /var/www/html/wp-content/uploads
cd /var/www/html
cp wp-config-sample.php wp-config.php
vi wp-config.php
systemctl restart httpd.service
systemctl restart mariadb.service

方法二:git clone 安装
文件结构是newstart下面没有wp文件夹,直接是wordpress的文件。
mkdir /tmp/newstart
git clone https://github.com/yufeiluo/newstart.git /tmp/newstart
sudo mv /tmp/newstart/* /var/www/html/wp
一步clone
git clone https://github.com/yufeiluo/newstart.git /var/www/html/wp
第三步:安装数据库
mysqlword=“xyzzy”
mysql -u root -p m y s q l w o r d − e " C R E A T E D A T A B A S E w p d a t a b a s e ; " m y s q l − u r o o t − p mysqlword -e"CREATE DATABASE wpdatabase;" mysql -u root -p mysqlworde"CREATEDATABASEwpdatabase;"mysqlurootpmysqlword -e"use wpdatabase;"
mysql -u root -p m y s q l w o r d − e " C R E A T E U S E R w p u s e r @ l o c a l h o s t ; " m y s q l − u r o o t − p mysqlword -e"CREATE USER wpuser@localhost;" mysql -u root -p mysqlworde"CREATEUSERwpuser@localhost;"mysqlurootpmysqlword -e"SET PASSWORD FOR wpuser@localhost= PASSWORD(‘dbpassword’);"
mysql -u root -p m y s q l w o r d − e " G R A N T A L L P R I V I L E G E S O N w p d a t a b a s e . ∗ T O w p u s e r @ l o c a l h o s t I D E N T I F I E D B Y ′ d b p a s s w o r d ′ ; " m y s q l − u r o o t − p mysqlword -e"GRANT ALL PRIVILEGES ON wpdatabase.* TO wpuser@localhost IDENTIFIED BY 'dbpassword';" mysql -u root -p mysqlworde"GRANTALLPRIVILEGESONwpdatabase.TOwpuser@localhostIDENTIFIEDBYdbpassword;"mysqlurootpmysqlword -e"FLUSH PRIVILEGES;"

#wpuser 可以使用的数据库远远少于root 用户可以使用的数据库
mysql -u wpuser -pdbpassword
show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| wpdatabase |
±-------------------+
mysql -u root -p
show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| mysql |
| performance_schema |
| wpdatabase |
±-------------------+

方法三:备份安装方式
1.wordpress文件备份
scp -P 1000 -rp /var/www/html/wp [email protected]:/var/www/html
速度太慢
打包后,发送,再解压
tar -zcPf /tmp/wp.tar.gz -C /var/www/html wp
scp -P 1000 -rp /tmp/wp.tar.gz [email protected]:/var/www/html
tar -zxf /var/www/html/wp.tar.gz -C /var/www/html
或者
cd /var/www/html
tar -zxf wp.tar.gz

2.数据库产生
mysqlword=“xyzzy”
mysql -u root -p m y s q l w o r d − e " C R E A T E D A T A B A S E w p d a t a b a s e ; " m y s q l − u r o o t − p mysqlword -e"CREATE DATABASE wpdatabase;" mysql -u root -p mysqlworde"CREATEDATABASEwpdatabase;"mysqlurootpmysqlword -e"use wpdatabase;"
mysql -u root -p m y s q l w o r d − e " C R E A T E U S E R w p u s e r @ l o c a l h o s t ; " m y s q l − u r o o t − p mysqlword -e"CREATE USER wpuser@localhost;" mysql -u root -p mysqlworde"CREATEUSERwpuser@localhost;"mysqlurootpmysqlword -e"SET PASSWORD FOR wpuser@localhost= PASSWORD(‘dbpassword’);"
mysql -u root -p m y s q l w o r d − e " G R A N T A L L P R I V I L E G E S O N w p d a t a b a s e . ∗ T O w p u s e r @ l o c a l h o s t I D E N T I F I E D B Y ′ d b p a s s w o r d ′ ; " m y s q l − u r o o t − p mysqlword -e"GRANT ALL PRIVILEGES ON wpdatabase.* TO wpuser@localhost IDENTIFIED BY 'dbpassword';" mysql -u root -p mysqlworde"GRANTALLPRIVILEGESONwpdatabase.TOwpuser@localhostIDENTIFIEDBYdbpassword;"mysqlurootpmysqlword -e"FLUSH PRIVILEGES;"

3.上传数据库数据

mysqldump -u root -p wpdatabase > /tmp/back.sql
scp -P 1000 /tmp/back.sql [email protected]:/tmp
mysql -u root -pxyzzy wpdatabase < /tmp/back.sql
4.域名更换
UPDATE wp_posts SET post_content = replace(post_content, ‘http://127.0.0.1/wp’, ‘http://11.22.33.44/wp’);
UPDATE wp_options SET option_value = replace(option_value, ‘http://127.0.0.1/wp’, ‘http://11.22.33.44/wp’);
UPDATE wp_posts SET guid = replace(guid, ‘http://127.0.0.1/wp’, ‘http://11.22.33.44/wp’);
UPDATE wp_posts SET pinged = replace(pinged, ‘http://127.0.0.1/wp’, ‘http://11.22.33.44/wp’);
UPDATE wp_comments SET comment_author_url = REPLACE(comment_author_url, ‘http://127.0.0.1/wp’, ‘http://11.22.33.44/wp’);

你可能感兴趣的:(Centos7安装WordPress)