更新 'README.md'
This commit is contained in:
parent
e02b458ac1
commit
2c47462908
39
README.md
39
README.md
@ -5,12 +5,13 @@ OS: Debian / Ubuntu
|
|||||||
----
|
----
|
||||||
## 安裝步驟
|
## 安裝步驟
|
||||||
- 安裝 Nginx
|
- 安裝 Nginx
|
||||||
```bash
|
```
|
||||||
sudo apt-get install nginx
|
sudo apt-get install nginx
|
||||||
```
|
```
|
||||||
- 安裝 MariaDB (MySQL)
|
- 安裝 MariaDB (MySQL)
|
||||||
> 官方網站 https://downloads.mariadb.org/mariadb/repositories/
|
> 官方網站 https://downloads.mariadb.org/mariadb/repositories/
|
||||||
```bash
|
|
||||||
|
```
|
||||||
# 安裝系統依賴
|
# 安裝系統依賴
|
||||||
sudo apt-get install software-properties-common dirmngr
|
sudo apt-get install software-properties-common dirmngr
|
||||||
# 新增安裝包來源與金鑰
|
# 新增安裝包來源與金鑰
|
||||||
@ -22,7 +23,8 @@ sudo apt-get install mariadb-server
|
|||||||
```
|
```
|
||||||
- 修改資料庫設定
|
- 修改資料庫設定
|
||||||
> 設定資料庫文字編碼為UTF-8
|
> 設定資料庫文字編碼為UTF-8
|
||||||
```bash
|
|
||||||
|
```
|
||||||
# sudo vim /etc/mysql/mariadb.cnf
|
# sudo vim /etc/mysql/mariadb.cnf
|
||||||
# MariaDB-specific config file.
|
# MariaDB-specific config file.
|
||||||
# Read by /etc/mysql/my.cnf
|
# Read by /etc/mysql/my.cnf
|
||||||
@ -44,21 +46,21 @@ collation_server = utf8_general_ci
|
|||||||
# Import all .cnf files from configuration directory
|
# Import all .cnf files from configuration directory
|
||||||
```
|
```
|
||||||
- 重啟資料庫完成設定
|
- 重啟資料庫完成設定
|
||||||
```bash
|
```
|
||||||
sudo systemctl restart mysql
|
sudo systemctl restart mysql
|
||||||
```
|
```
|
||||||
- 安裝 PHP-FPM 與相關套件 (PHP 7.0)
|
- 安裝 PHP-FPM 與相關套件 (PHP 7.0)
|
||||||
```bash
|
```
|
||||||
sudo apt-get install php7.0-cli php7.0-curl php7.0-dev php7.0-fpm php7.0-imap php7.0-intl php7.0-json php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-readline php7.0-xml php7.0-xmlrpc php7.0-zip
|
sudo apt-get install php7.0-cli php7.0-curl php7.0-dev php7.0-fpm php7.0-imap php7.0-intl php7.0-json php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-readline php7.0-xml php7.0-xmlrpc php7.0-zip
|
||||||
```
|
```
|
||||||
- 修改 php-fpm 設定
|
- 修改 php-fpm 設定
|
||||||
```bash
|
```
|
||||||
# sudo vim /etc/php/7.0/fpm/pool.d/www.conf
|
# sudo vim /etc/php/7.0/fpm/pool.d/www.conf
|
||||||
# 確認 fpm cgi 監聽位置
|
# 確認 fpm cgi 監聽位置
|
||||||
listen = /run/php/php7.0-fpm.sock
|
listen = /run/php/php7.0-fpm.sock
|
||||||
```
|
```
|
||||||
- 新增 Nginx 執行 PHP 設定
|
- 新增 Nginx 執行 PHP 設定
|
||||||
```bash
|
```
|
||||||
# sudo vim /etc/nginx/php-fpm.conf
|
# sudo vim /etc/nginx/php-fpm.conf
|
||||||
location ~ \.php$ {
|
location ~ \.php$ {
|
||||||
include snippets/fastcgi-php.conf;
|
include snippets/fastcgi-php.conf;
|
||||||
@ -70,11 +72,11 @@ location ~ \.php$ {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
- 產生SSL DHParam
|
- 產生SSL DHParam
|
||||||
```bash
|
```
|
||||||
sudo openssl -out /etc/nginx/dhparam.pem 2048
|
sudo openssl -out /etc/nginx/dhparam.pem 2048
|
||||||
```
|
```
|
||||||
- 新增Let's encrypt 設定
|
- 新增Let's encrypt 設定
|
||||||
```bash
|
```
|
||||||
# sudo vim /etc/nginx/letsencrypt.conf
|
# sudo vim /etc/nginx/letsencrypt.conf
|
||||||
location ^~ /.well-known/acme-challenge/ {
|
location ^~ /.well-known/acme-challenge/ {
|
||||||
default_type "text/plain";
|
default_type "text/plain";
|
||||||
@ -82,12 +84,13 @@ location ^~ /.well-known/acme-challenge/ {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
- 安裝 Certbot (let's encrypt cli)
|
- 安裝 Certbot (let's encrypt cli)
|
||||||
```bash
|
```
|
||||||
sudo apt-get install certbot -t stretch-backports
|
sudo apt-get install certbot -t stretch-backports
|
||||||
```
|
```
|
||||||
- 修改 Nginx 設定用來執行 Let's encrypt
|
- 修改 Nginx 設定用來執行 Let's encrypt
|
||||||
> 找到 location / 在上面新增 include letsencrypt.conf;
|
> 找到 location / 在上面新增 include letsencrypt.conf;
|
||||||
```bash
|
|
||||||
|
```
|
||||||
# sudo vim /etc/nginx/sites-enabled/default
|
# sudo vim /etc/nginx/sites-enabled/default
|
||||||
include letsencrypt.conf;
|
include letsencrypt.conf;
|
||||||
|
|
||||||
@ -98,22 +101,23 @@ try_files $uri $uri/ =404;
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
- 建立 let's encrypt 驗證用資料夾
|
- 建立 let's encrypt 驗證用資料夾
|
||||||
```bash
|
```
|
||||||
sudo mkdir -p /var/www/letsencrypt
|
sudo mkdir -p /var/www/letsencrypt
|
||||||
# 變更資料夾擁有者到 www-data
|
# 變更資料夾擁有者到 www-data
|
||||||
sudo chown -R www-data:www-data /var/www
|
sudo chown -R www-data:www-data /var/www
|
||||||
```
|
```
|
||||||
- 重新啟動 Nginx 應用剛剛修改的設定
|
- 重新啟動 Nginx 應用剛剛修改的設定
|
||||||
```bash
|
```
|
||||||
sudo systemctl restart nginx
|
sudo systemctl restart nginx
|
||||||
```
|
```
|
||||||
- 申請SSL憑證 (webroot)
|
- 申請SSL憑證 (webroot)
|
||||||
> 執行前確定DNS A record 是不是有指到伺服器上
|
> 執行前確定DNS A record 是不是有指到伺服器上
|
||||||
```bash
|
|
||||||
|
```
|
||||||
sudo certbot certonly --webroot -w /var/www/letsencrypt -d domain.name
|
sudo certbot certonly --webroot -w /var/www/letsencrypt -d domain.name
|
||||||
```
|
```
|
||||||
- 下載Wordpress 網頁檔案
|
- 下載Wordpress 網頁檔案
|
||||||
```bash
|
```
|
||||||
cd /var/www
|
cd /var/www
|
||||||
sudo wget https://tw.wordpress.org/wordpress-5.2-zh_TW.tar.gz
|
sudo wget https://tw.wordpress.org/wordpress-5.2-zh_TW.tar.gz
|
||||||
sudo tar zxvf wordpress-5.2-zh_TW.tar.gz
|
sudo tar zxvf wordpress-5.2-zh_TW.tar.gz
|
||||||
@ -121,7 +125,8 @@ sudo chown -R www-data:www-data /var/www
|
|||||||
```
|
```
|
||||||
- 新增wordpress nginx 設定
|
- 新增wordpress nginx 設定
|
||||||
> [Config file](wordpress.conf) 下載此設定檔到伺服器,並且修改設定檔內部的 "domain.name" 為自己的domain name
|
> [Config file](wordpress.conf) 下載此設定檔到伺服器,並且修改設定檔內部的 "domain.name" 為自己的domain name
|
||||||
```bash
|
|
||||||
|
```
|
||||||
# 移動檔案到 nginx 工作目錄
|
# 移動檔案到 nginx 工作目錄
|
||||||
sudo mv wordpress.conf /etc/nginx/sites-available/
|
sudo mv wordpress.conf /etc/nginx/sites-available/
|
||||||
# 建立軟連結到 nginx 啟用的設定檔案目錄
|
# 建立軟連結到 nginx 啟用的設定檔案目錄
|
||||||
@ -132,7 +137,7 @@ sudo nginx -t
|
|||||||
sudo systemctl restart nginx
|
sudo systemctl restart nginx
|
||||||
```
|
```
|
||||||
- 建立wordpress用的資料庫
|
- 建立wordpress用的資料庫
|
||||||
```bash
|
```
|
||||||
# 建立名為 wordpress 的資料庫
|
# 建立名為 wordpress 的資料庫
|
||||||
echo "create database wordpress;" | mysql -u root -p
|
echo "create database wordpress;" | mysql -u root -p
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user