wordpress搭建教程-147SEO
wordpress搭建教程,WordPress是一款使用PHP語言開發(fā)的博客平臺,站長可使用通過WordPress搭建屬于個人的網(wǎng)站。本文主要分享如何wordpress建站的wordpress搭建教程,從服務(wù)器配置、域名解析、面板設(shè)置、wordpress建站、網(wǎng)站優(yōu)化等一些列操作講解wordpress搭建教程,站長可以學(xué)習(xí)到的不僅僅是如何成功搭建一個Wordpress網(wǎng)站,更多的是學(xué)習(xí)Wordpress網(wǎng)站優(yōu)化,Wordpress可以很強(qiáng)大,但是前提是站長已經(jīng)掌握了它。
wordpress搭建教程技巧分享,詳細(xì)步驟說明如下:
Linux:Linux 操作系統(tǒng),以ubuntu18.04 為例;nginx:Web 服務(wù)器;mysql:數(shù)據(jù)庫;PHP:腳本語言;CMS:WordPress,操作步驟:
wordpress搭建教程步驟1:登錄云服務(wù)器
win系統(tǒng)建議使用Xshell軟件進(jìn)行登陸
Mac以及ubuntu系統(tǒng)可以使用自帶的終端進(jìn)行登陸
ssh-p端口號服務(wù)器用戶名@ip(例如ssh-p22 username@111.222.111.222)
wordpress搭建教程步驟2:搭建環(huán)境
apt update && apt upgrade
apt install -y nginx mysql-server unzip python-certbot-nginx
apt install -y php php-fpm php-mysql php-gd php-json php-xml php-mbstring
wordpress搭建教程步驟3:配置數(shù)據(jù)庫
執(zhí)行以下命令,進(jìn)入mysql
mysql
執(zhí)行以下命令,創(chuàng)建 mysql 數(shù)據(jù)庫。例如 “wordpress”
CREATE DATABASE wordpress;
執(zhí)行以下命令,創(chuàng)建一個新用戶。例如 “user”,登錄密碼為 123456
CREATE USER 'user'@'localhost' IDENTIFIED BY '123456';
執(zhí)行以下命令,創(chuàng)建一個新用戶。例如 “user”,登錄密碼為 123456
GRANT ALL PRIVILEGES ON wordpress.* TO 'user'@'localhost' IDENTIFIED BY '123456';
執(zhí)行以下命令,退出 mysql
\q
wordpress搭建教程步驟4:安裝和配置 WordPress
下載并解壓WordPress軟件包
wget WordPress/latest.zip && unzip latest.zip
設(shè)置目錄權(quán)限
chown -R www-data:www-data wordpress/
wordpress搭建教程步驟5:域名解析獲取https證書
域名解析一般設(shè)置兩條記錄就夠了,即將域名指向站長自己VPS的 IP地址
申請https證書這里使用 Let’s Encrypt 免費(fèi)證書
配置 Nginx 以便于 Let’s Encrypt 能起作用:
sudo vim /etc/nginx/sites-enabled/default
default替換成你自己的Nginx配置文件名,清空原有內(nèi)容并添加下面的配置
server {
listen 80;
listen [::]:80;
server_name 你的域名;
}
保存退出之后,執(zhí)行以下命令來檢測 Nginx 的配置文件是否有錯
sudo nginx -t
如果出現(xiàn)這樣的語句,就說明 Nginx 的配置文件沒有問題
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新加載 Nginx 的配置文件了
sudo nginx -s reload
執(zhí)行命令獲取證書
sudo certbot --nginx -d 你的域名
如果第一次運(yùn)行 certbot 命令的話,需要在彈出的窗口輸入站長的郵箱地址還有需要接受 Let’s Encrypt 的協(xié)議,執(zhí)行完后,就會有輸出一段字符
然后在文字中,這個/etc/letsencrypt/live/你的域名/fullchain.pem 路徑很重要,就是你的 SSL 證書路徑。
自動更新證書
因為 Let’s Encrypt 簽發(fā)的證書有效期只有 90 天,所有在過期之前,我們需要自動更新 SSL 證書,而如果你使用最新的 certbot 的話,Let’s Encrypt 會幫你添加自動更新的腳本到 /etc/cron.d 里,你只需要去檢測一下這個命令是否生效就OK!
sudo certbot renew --dry-run
如果這個命令你沒看到什么 error 的話,那就是沒什么問題了。
wordpress搭建教程步驟6:配置nginx
打開第五步設(shè)置的Nginx配置文件名
sudo vim /etc/nginx/sites-enabled/default
在ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot后加入如下內(nèi)容
root /home/wordpress;
## This should be in your http block and if it is, it's not needed here.
client_max_body_size 10M;
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
client_max_body_size 10m;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
保存退出之后,執(zhí)行以下命令來檢測 Nginx 的配置文件是否有錯
sudo nginx -t
如果出現(xiàn)這樣的語句,就說明 Nginx 的配置文件沒有問題
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
重新加載 Nginx 的配置文件了
sudo nginx -s reload
wordpress搭建教程步驟7:初始化wordpress
搭建完成,訪問站點,“現(xiàn)在開始”,按提示配置 WordPress。
填寫上面記錄下的數(shù)據(jù)庫信息,提交。
填寫網(wǎng)站標(biāo)題以及設(shè)置管理員賬號密碼
登陸后臺
wordpress搭建教程的總體過程已經(jīng)分享給大家,希望對大家能有所幫助,如果還有不明白,可以結(jié)合文章圖片來閱讀,快速完成一鍵建站。