本教程使用服務(wù)器騰訊云云服務(wù)器 CVM(以下簡稱 CVM),以 Linux 系統(tǒng) CentOS 7.0以上為例,來完成 WordPress 搭建工作。
根據(jù)個(gè)人需要購買云服務(wù)器。 并可以參照騰訊云的創(chuàng)建指引創(chuàng)建 Linux 云服務(wù)器。
服務(wù)器創(chuàng)建成功后,登錄騰訊云管理控制臺(tái)可以查看或編輯云主機(jī)狀態(tài)
3、在控制臺(tái)操作欄可以直接登錄服務(wù)器,進(jìn)入命令行窗口后,依次輸入云主機(jī)的用戶名和密碼,就可連接到云主機(jī),進(jìn)行后續(xù)操作
yum -y install httpd
2、啟動(dòng)httpd并且設(shè)置為開機(jī)啟動(dòng)
systemctl start httpd.servicesystemctl enable httpd.service
3、安裝firewall
yum -y install firewalld firewall-configsystemctl start firewalld.servicesystemctl enable firewalld.service
4、配置firewall
firewall-cmd --permanent --zone=public --add-service=http firewall-cmd --permanent --zone=public --add-service=httpsfirewall-cmd --reload
1、利用yum命令進(jìn)行安裝,并配置開機(jī)啟動(dòng)
yum -y install mariadb-server mariadbsystemctl start mariadb.servicesystemctl enable mariadb.service
2、配置root密碼
mysql_secure_installation
具體有以下幾個(gè)選項(xiàng),可以根據(jù)各自情況進(jìn)行配置(建議全部選Y)
Enter current password for root (enter for none):(輸入原始root密碼,若無則按enter)OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation. Set root password? [Y/n] (按Y設(shè)置root密碼)New password:Re-enter new password:Password updated successfully!Reloading privilege tables.. ... Success!Remove anonymous users? [Y/n] (按Y移除匿名用戶) ... Success!Disallow root login remotely? [Y/n] (按Y禁止遠(yuǎn)程root登陸,一般root都設(shè)定為只允許本地登陸) ... skipping.Remove test database and access to it? [Y/n] (按Y刪除測試數(shù)據(jù)庫)Reload privilege tables now? [Y/n] (按Y重新載入) ... Success!Cleaning up...All done! If you've completed all of the above steps, your MariaDBinstallation should now be secure.Thanks for using MariaDB!
1、首先下載PHP及常用組件,同樣運(yùn)用yum命令
yum -y install php
2、查看下載的所有組件
yum search php
3、安裝需要的組件
yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
4、新建一個(gè)php頁面查看安裝的組件
vi /var/www/html/info.php
按字母i或insert鍵進(jìn)入編輯模式,編輯為以下內(nèi)容
<?phpphpinfo();?>
編輯完成后鍵入“Esc:wq”,保存文件并退回到命令行模式
5、重啟httpd服務(wù)
systemctl restart httpd.service
6、在瀏覽器打開網(wǎng)址 http://x.x.x.x/info.php 進(jìn)行查看(x.x.x.x為你的服務(wù)器公網(wǎng)IP)
1、登陸MariaDB為WordPress建立數(shù)據(jù)庫及用戶
mysql -u root -p
2、新建數(shù)據(jù)庫wordpressdb,用戶為wordpressuser,密碼為123456
CREATE DATABASE wordpressdb;CREATE USER wordpressuser@localhost IDENTIFIED BY '123456';
3、更改用戶權(quán)限,保存并退出
GRANT ALL PRIVILEGES ON wordpressdb.* TO wordpressuser@localhost;FLUSH PRIVILEGES;exit
4、重啟相關(guān)服務(wù)
systemctl restart httpd.servicesystemctl restart mariadb.service
1、新建一個(gè)文件夾,此處取名wp
mkdir wpcd wpyum -y install wget unzip net-toolswget http://wordpress.org/latest.zip
2、解壓文件,并且將其復(fù)制到/var/www/html目錄下
unzip -q latest.zipcp -rf wordpress/* /var/www/html/
3、修改文件夾權(quán)限
chown -R apache:apache /var/www/html/chmod -R 755 /var/www/html/mkdir -p /var/www/html/wp-content/uploadschown -R :apache /var/www/html/wp-content/uploads
4、編輯配置文件
cd /var/www/htmlcp wp-config-sample.php wp-config.php vi wp-config.php
打開文件后,按i鍵或insert鍵進(jìn)入編輯模式,將其修改為以下格式(其中wordpressdb為數(shù)據(jù)庫名稱,wordpressuser為數(shù)據(jù)庫用戶名,123456為數(shù)據(jù)庫密碼)
// * MySQL settings - You can get this info from your web host * // /* The name of the database for WordPress / define(‘DB_NAME’, ‘wordpressdb’);/* mysql database username / define(‘DB_USER’, ‘wordpressuser’);/* MySQL database password / define(‘DB_PASSWORD’, ‘123456’);
鍵入“Esc:wq”,存盤并退出
5、重啟相關(guān)服務(wù)
systemctl restart httpd.servicesystemctl restart mariadb.service
登錄 http://x.x.x.x/訪問你的博客(x.x.x.x為你的服務(wù)器公網(wǎng)IP),按照自己的喜好進(jìn)行相關(guān)的設(shè)置。
聯(lián)系客服