差異處
這裏顯示兩個版本的差異處。
兩邊的前次修訂版 前次修改 下次修改 | 前次修改 | ||
tech:wordpress [2019/02/25 21:08] – [評估外掛與相關資源] jonathan_tsai | tech:wordpress [2019/07/22 17:41] (目前版本) – [評估外掛與相關資源] jonathan_tsai | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== CentOS7 安裝 WordPress 5 程序 ====== | ||
+ | * CentOS 7.6.1810 (Core) | ||
+ | * Nginx 1.12.2 | ||
+ | * MariaDB 10.3.12 | ||
+ | * PHP 7.3.1 | ||
+ | ===== 安裝 Nginx / MariaDB / PHP 7 ===== | ||
+ | * EPEL <code sh> | ||
+ | yum install -y epel-release yum-utils | ||
+ | </ | ||
+ | * Remi 關閉 5.4 啟用 7.3<code sh> | ||
+ | rpm -Uvh http:// | ||
+ | yum-config-manager --disable remi-php54 | ||
+ | yum-config-manager --enable remi-php73 | ||
+ | </ | ||
+ | * nginx <code sh> | ||
+ | vi / | ||
+ | [nginx] | ||
+ | name=nginx repo | ||
+ | baseurl=http:// | ||
+ | gpgcheck=0 | ||
+ | enabled=1</ | ||
+ | yum install -y nginx | ||
+ | </ | ||
+ | * php-fpm <code sh> | ||
+ | yum install -y php-fpm php | ||
+ | </ | ||
+ | * mariadb-server <code sh> | ||
+ | vi / | ||
+ | # MariaDB 10.3 CentOS repository list - created 2019-01-25 13:04 UTC | ||
+ | # http:// | ||
+ | [mariadb] | ||
+ | name = MariaDB | ||
+ | baseurl = http:// | ||
+ | gpgkey=https:// | ||
+ | gpgcheck=1 | ||
+ | </ | ||
+ | yum install -y MariaDB-server | ||
+ | </ | ||
+ | |||
+ | ===== 設定與驗證 nginx+php-fpm / mariadb ===== | ||
+ | * Firewall 開啟 http / https <code sh> | ||
+ | firewall-cmd --permanent --zone=public --add-service=http | ||
+ | firewall-cmd --permanent --zone=public --add-service=https | ||
+ | firewall-cmd --reload | ||
+ | </ | ||
+ | * 設定 nginx 開機啟動 <code sh> | ||
+ | systemctl restart nginx | ||
+ | systemctl enable nginx | ||
+ | </ | ||
+ | * 設定主網站頁目錄 <code sh> | ||
+ | vi / | ||
+ | </ | ||
+ | server { | ||
+ | listen | ||
+ | server_name | ||
+ | |||
+ | gzip on; | ||
+ | gzip_comp_level | ||
+ | gzip_min_length | ||
+ | gzip_proxied | ||
+ | gzip_vary | ||
+ | |||
+ | gzip_types | ||
+ | application/ | ||
+ | application/ | ||
+ | application/ | ||
+ | application/ | ||
+ | application/ | ||
+ | application/ | ||
+ | application/ | ||
+ | application/ | ||
+ | application/ | ||
+ | application/ | ||
+ | application/ | ||
+ | application/ | ||
+ | font/ | ||
+ | image/bmp | ||
+ | image/ | ||
+ | image/ | ||
+ | text/ | ||
+ | text/css | ||
+ | text/plain | ||
+ | text/vcard | ||
+ | text/ | ||
+ | text/vtt | ||
+ | text/ | ||
+ | text/ | ||
+ | # text/html is always compressed by gzip module | ||
+ | |||
+ | location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf)$ { | ||
+ | expires 7d; | ||
+ | } | ||
+ | |||
+ | |||
+ | charset utf-8; | ||
+ | access_log | ||
+ | |||
+ | root / | ||
+ | index index.php index.html index.htm; | ||
+ | |||
+ | location / { | ||
+ | try_files $uri $uri/ =404; | ||
+ | } | ||
+ | |||
+ | error_page | ||
+ | |||
+ | # redirect server error pages to the static page /50x.html | ||
+ | # | ||
+ | error_page | ||
+ | location = /50x.html { | ||
+ | root / | ||
+ | } | ||
+ | |||
+ | location ~ \.php$ { | ||
+ | try_files $uri =404; | ||
+ | fastcgi_pass 127.0.0.1: | ||
+ | fastcgi_index index.php; | ||
+ | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
+ | include fastcgi_params; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | chcon -R -t httpd_sys_rw_content_t / | ||
+ | systemctl reload nginx | ||
+ | </ | ||
+ | * 修改 php 設定< | ||
+ | vi / | ||
+ | </ | ||
+ | : | ||
+ | ; | ||
+ | cgi.fix_pathinfo=0 | ||
+ | : | ||
+ | [Date] | ||
+ | : | ||
+ | date.timezone = Asia/Taipei | ||
+ | : | ||
+ | </ | ||
+ | * 修改 php-fpm 設定< | ||
+ | vi / | ||
+ | </ | ||
+ | : | ||
+ | ; RPM: apache user chosen to provide access to the same directories as httpd | ||
+ | ;user = apache | ||
+ | user = nginx | ||
+ | ; RPM: Keep a group allowed to write in log dir. | ||
+ | ;group = apache | ||
+ | group = nginx | ||
+ | : | ||
+ | : | ||
+ | ; Default Values: user and group are set as the running user | ||
+ | ; mode is set to 0660 | ||
+ | listen.owner = nobody | ||
+ | listen.group = nobody | ||
+ | ; | ||
+ | : | ||
+ | </ | ||
+ | systemctl restart php-fpm | ||
+ | systemctl enable php-fpm | ||
+ | </ | ||
+ | * 啟動 MariaDB 與驗證新密碼< | ||
+ | systemctl restart mariadb | ||
+ | systemctl enable mariadb | ||
+ | mysql_secure_installation | ||
+ | mysql -u root -p | ||
+ | </ | ||
+ | * 安裝其他 php 套件 <code sh> | ||
+ | yum install php-mysqlnd php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-zip php-curl php-cli | ||
+ | systemctl restart php-fpm | ||
+ | systemctl restart nginx | ||
+ | </ | ||
+ | |||
+ | ===== 下載最新版 Wordpress ===== | ||
+ | * 下載網址 : http:// | ||
+ | < | ||
+ | yum install wget unzip | ||
+ | cd / | ||
+ | wget http:// | ||
+ | unzip latest.zip | ||
+ | chown -R nginx:nginx wordpress | ||
+ | </ | ||
+ | |||
+ | ===== 開始基本設定 ===== | ||
+ | * 建立 wordpress db <code sh> | ||
+ | mysql -u root -p | ||
+ | </ | ||
+ | create database `wordpress`; | ||
+ | create user ' | ||
+ | grant all on wordpress.* to ' | ||
+ | flush privileges; | ||
+ | quit | ||
+ | </ | ||
+ | * 透過網頁安裝設定 wordpress : http:// | ||
+ | * 使用 admin 與預設密碼(0adf3e 這樣的密碼) 登入, 先將預設密碼改成你要的密碼 | ||
+ | |||
+ | ===== 設定固定網址 ===== | ||
+ | * / | ||
+ | : | ||
+ | index index.php index.html index.htm; | ||
+ | |||
+ | location / { | ||
+ | try_files $uri $uri/ / | ||
+ | } | ||
+ | |||
+ | error_page | ||
+ | : | ||
+ | </ | ||
+ | * 檢查設定檔與重啟 nginx< | ||
+ | nginx -t | ||
+ | systemctl restart nginx | ||
+ | </ | ||
+ | |||
+ | ===== 設定特定 IP 可存取 wp-admin ===== | ||
+ | * Exp. 開放 10.x.x.x 以及 172.16.x.x 可以進入 wp-admin 管理介面 | ||
+ | * 編輯 / | ||
+ | : | ||
+ | location / { | ||
+ | try_files $uri $uri/ / | ||
+ | } | ||
+ | |||
+ | location /wp-admin/ { | ||
+ | allow 10.0.0.0/8; | ||
+ | allow 172.16.0.0/ | ||
+ | deny all; | ||
+ | } | ||
+ | |||
+ | location / | ||
+ | allow all; | ||
+ | } | ||
+ | |||
+ | error_page | ||
+ | : | ||
+ | </ | ||
+ | * 重新啟動 nginx 讓設定生效< | ||
+ | systemctl restart nginx | ||
+ | </ | ||
+ | |||
+ | ===== 評估外掛與相關資源 ===== | ||
+ | * CDN 整合 | ||
+ | * [[https:// | ||
+ | * 數據統計 | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * 網站測速 | ||
+ | * http:// | ||
+ | * 網站優化 | ||
+ | * https:// | ||
+ | |||
+ | * plugin 參考文章 | ||
+ | * https:// | ||
+ | |||
+ | < | ||
+ | * 如果要更改網址 -> 參考 **[[tech/ | ||
+ | * 如果要更改已經上傳的媒體(圖片, | ||
+ | </ | ||
+ | |||
+ | ====== 參考網址 ====== | ||
+ | * http:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * http:// | ||
+ | * https:// | ||
+ | |||
+ | |||
+ | {{tag> |