背景
CentOS 8.2服務器,使用的虛擬服務器,只開放22與80埠,設定默認頁面是wordpress的入口,phpmyadmin使用虛擬目錄的形式進行訪問,
安裝
總體思路按照此文章進行,我進行的還算順利,
有的package教程上說有,但是自己使用yum install卻說沒有
需要安裝yum install epel-release,這樣很多拓展的包才可用,如果還不行,然后最好設定一下etc/yum.repo.d/epel.repo,將其中的非debug專案都enable=1,
使用yum install wordpress進行安裝
之前使用CentOS7自帶的源中,有wordpress,可以使用yum install wordpress的方式進行安裝,需要設定一下作業目錄,或者直接使用ln命令做一個軟鏈接,創建一個wordpress到/usr/share/nginx/html/的鏈接,即可正常使用,
安裝極慢
可以考慮使用國內安裝源進行,國內有https://mirrors.ustc.edu.cn/和https://mirrors.tuna.tsinghua.edu.cn/
,兩個都可以用,除了baseOS以外,還都有epel的源,
配置
無法安裝wordpress插件,提示無法創建目錄,
需要給wp-content、wp-content/plugins、wp-content/uploads、wp-content/themes分配權限,使用chmod分配755權限,使用chown -R nginx:nginx ./wp-content分配nginx訪問的權限,
phpMyAdmin提示session_start(): open(SESSION_FILE, O_RDWR)) failed: Permission denied (13)
這篇文章說了下原理,我的情況比較符合這種,session目錄就在/var/lib/php/session這個位置,chown設定一下權限,就OK了,
wordpress提示上傳檔案有2M限制或者提示413 Request Entity Too Large,
找到etc/php.ini,修改
upload_max_filesize
post_max_size
max_execution_time
max_input_time
max_input_vars
memory_limit
都調整成大的數值,然后,在nginx.conf中設定
server {
listen 80;
listen [::]:80;
root /var/www/html/wordpress;
index index.php index.html index.htm;
server_name example.com www.example.com;
#注意這一行是關鍵
client_max_body_size 100M;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
#注意這幾行,謹慎設定,可能導致運行速度變慢,
fastcgi_connect_timeout 300s;
fastcgi_read_timeout 300s;
fastcgi_send_timeout 300s;
}
}
然后執行
sudo systemctl reload nginx.service
sudo systemctl reload php-fpm.service
就可以正常作業了,
phpMyAdmin無法正常被nginx決議
在etc/nginx/default.d/下面新建一個phpmyadmin.conf檔案
location /phpmyadmin {
root /usr/share/nginx/html;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/nginx/html/;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/nginx/html/;
}
}
重啟之后即可正常,
PHP無法被nginx加載,所有php網頁都提示404錯誤,
php -v命令顯示正常,服務也在正常運行,但是無法正常決議,提示找不到檔案(比如index.php),
檢查etc/nginx/default.d/php-fpm.conf檔案,fastcgi_pass可能設定的路徑不正確,正確應該為:
fastcgi_pass unix:/run/php-fpm/www.sock;
wordpress安裝插件時,提示連接FTP,要求提供FTP的資訊
設定/usr/share/nginx/html/wp-config.php,增加一項:
define('FS_METHOD', 'direct');
重啟php-fpm即可,
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/135347.html
標籤:Linux
