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
yum install -y epel-release yum-utils
Remi 關閉 5.4 啟用 7.3
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum-config-manager --disable remi-php54
yum-config-manager --enable remi-php73
nginx
vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
yum install -y nginx
php-fpm
yum install -y php-fpm php
mariadb-server
vi /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.3 CentOS repository list - created 2019-01-25 13:04 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
yum install -y MariaDB-server
設定與驗證 nginx+php-fpm / mariadb
Firewall 開啟 http / https
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
設定 nginx 開機啟動
systemctl restart nginx
systemctl enable nginx
設定主網站頁目錄
vi /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
gzip on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
application/atom+xml
application/javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy;
# text/html is always compressed by gzip module
location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf)$ {
expires 7d;
}
charset utf-8;
access_log /var/log/nginx/access.log main;
root /var/www/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
chcon -R -t httpd_sys_rw_content_t /usr/share/nginx/html
systemctl reload nginx
修改 php 設定
vi /etc/php.ini
:
;cgi.fix_pathinfo=1
cgi.fix_pathinfo=0
:
[Date]
:
date.timezone = Asia/Taipei
:
修改 php-fpm 設定
vi /etc/php-fpm.d/www.conf
:
; 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
;listen.mode = 0660
:
systemctl restart php-fpm
systemctl enable php-fpm
啟動 MariaDB 與驗證新密碼
systemctl restart mariadb
systemctl enable mariadb
mysql_secure_installation
mysql -u root -p
安裝其他 php 套件
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
yum install wget unzip
cd /var/www/html/
wget http://wordpress.org/latest.zip
unzip latest.zip
chown -R nginx:nginx wordpress
開始基本設定
設定固定網址
/etc/nginx/conf.d/default.conf
:
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
error_page 404 /404.html;
:
檢查設定檔與重啟 nginx
nginx -t
systemctl restart nginx
設定特定 IP 可存取 wp-admin
評估外掛與相關資源
參考網址