wordpress搭建教程-147SEO
wordpress搭建教程,WordPress是一款使用PHP語言開發的博客平臺,站長可使用通過WordPress搭建屬于個人的網站。本文主要分享如何wordpress建站的wordpress搭建教程,從服務器配置、域名解析、面板設置、wordpress建站、網站優化等一些列操作講解wordpress搭建教程,站長可以學習到的不僅僅是如何成功搭建一個Wordpress網站,更多的是學習Wordpress網站優化,Wordpress可以很強大,但是前提是站長已經掌握了它。
wordpress搭建教程技巧分享,詳細步驟說明如下:
Linux:Linux 操作系統,以ubuntu18.04 為例;nginx:Web 服務器;mysql:數據庫;PHP:腳本語言;CMS:WordPress,操作步驟:
wordpress搭建教程步驟1:登錄云服務器
win系統建議使用Xshell軟件進行登陸
Mac以及ubuntu系統可以使用自帶的終端進行登陸
ssh-p端口號服務器用戶名@ip(例如ssh-p22 username@111.222.111.222)
wordpress搭建教程步驟2:搭建環境
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:配置數據庫
執行以下命令,進入mysql
mysql
執行以下命令,創建 mysql 數據庫。例如 “wordpress”
CREATE DATABASE wordpress;
執行以下命令,創建一個新用戶。例如 “user”,登錄密碼為 123456
CREATE USER 'user'@'localhost' IDENTIFIED BY '123456';
執行以下命令,創建一個新用戶。例如 “user”,登錄密碼為 123456
GRANT ALL PRIVILEGES ON wordpress.* TO 'user'@'localhost' IDENTIFIED BY '123456';
執行以下命令,退出 mysql
\q
wordpress搭建教程步驟4:安裝和配置 WordPress
下載并解壓WordPress軟件包
wget WordPress/latest.zip && unzip latest.zip
設置目錄權限
chown -R www-data:www-data wordpress/
wordpress搭建教程步驟5:域名解析獲取https證書
域名解析一般設置兩條記錄就夠了,即將域名指向站長自己VPS的 IP地址
申請https證書這里使用 Let’s Encrypt 免費證書
配置 Nginx 以便于 Let’s Encrypt 能起作用:
sudo vim /etc/nginx/sites-enabled/default
default替換成你自己的Nginx配置文件名,清空原有內容并添加下面的配置
server {
listen 80;
listen [::]:80;
server_name 你的域名;
}
保存退出之后,執行以下命令來檢測 Nginx 的配置文件是否有錯
sudo nginx -t
如果出現這樣的語句,就說明 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
執行命令獲取證書
sudo certbot --nginx -d 你的域名
如果第一次運行 certbot 命令的話,需要在彈出的窗口輸入站長的郵箱地址還有需要接受 Let’s Encrypt 的協議,執行完后,就會有輸出一段字符
然后在文字中,這個/etc/letsencrypt/live/你的域名/fullchain.pem 路徑很重要,就是你的 SSL 證書路徑。
自動更新證書
因為 Let’s Encrypt 簽發的證書有效期只有 90 天,所有在過期之前,我們需要自動更新 SSL 證書,而如果你使用最新的 certbot 的話,Let’s Encrypt 會幫你添加自動更新的腳本到 /etc/cron.d 里,你只需要去檢測一下這個命令是否生效就OK!
sudo certbot renew --dry-run
如果這個命令你沒看到什么 error 的話,那就是沒什么問題了。
wordpress搭建教程步驟6:配置nginx
打開第五步設置的Nginx配置文件名
sudo vim /etc/nginx/sites-enabled/default
在ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot后加入如下內容
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;
}
保存退出之后,執行以下命令來檢測 Nginx 的配置文件是否有錯
sudo nginx -t
如果出現這樣的語句,就說明 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
搭建完成,訪問站點,“現在開始”,按提示配置 WordPress。
填寫上面記錄下的數據庫信息,提交。
填寫網站標題以及設置管理員賬號密碼
登陸后臺
wordpress搭建教程的總體過程已經分享給大家,希望對大家能有所幫助,如果還有不明白,可以結合文章圖片來閱讀,快速完成一鍵建站。
147SEO » wordpress搭建教程-147SEO