基于OpenLiteSpeed 安装配置 WordPress
By Admin
## 1. 安装OpenLiteSpeed ```shell wget https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh && chmod +x ols1clk.sh ./ols1clk.sh --lsphp 80 --wordpressplus www.xxxx.com --wplang zh_CN...
1. 安装OpenLiteSpeed
wget https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh && chmod +x ols1clk.sh ./ols1clk.sh --lsphp 80 --wordpressplus www.xxxx.com --wplang zh_CN #一定要记录屏幕上提示的的密码 或安装后在 /usr/local/lsws/password 中查看 #安装模块 yum install -y lsphp80-pecl-redis.x86_64 lsphp80-pecl-memcached.x86_64 lsphp80-opcache yum install lsphp80-pecl-imagick.x86_64 #重启 pkill lsphp systemctl restart lshttpd
2. 安装redis
使用oneinstack安装或其它方式安装,安装后设置bind地址为127.0.0.1
sudo yum install epel-release yum-utils sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm sudo yum-config-manager --enable remi sudo yum install redis sudo systemctl start redis sudo systemctl enable redis sudo systemctl status redis
3. 登录7080端口的控制台
Server Configuration > General
找到 Rewrite Control 修改为yes,右上角reload,然后再改回not set ,再reload
Virtual Host wordpress > Log
**配置 access 日志 **
Virtual Host wordpress > General
配置自定义的404页面
Access Log
| Log Control | File Name | Log Format | Rolling Size (bytes) | Actions |
|---|---|---|---|---|
| Own Log File | /usr/local/lsws/logs/my_access.log | Not Set | 10M |
4. 登录WP管理后台
设置固定链接格式为 文章名
**添加插件 **WebP Converter for Media ,模式用Pass Thru (without rewrites in .htaccess files or Nginx configuration)
或者 将./wp-content/.htaccess的内容添加到vhost的自定义rewrite里
# 跳转https RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.xxxxx.com/$1 [R,L] # BEGIN WebP Converter # ! --- DO NOT EDIT PREVIOUS LINE --- ! <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.jpg.webp -f RewriteCond %{HTTP_HOST}@@%{HTTP_REFERER} ^([^@]*)@@https?://\1/.* RewriteRule (.+)\.jpg$ /wp-content/uploads-webpc/$1.jpg.webp [NC,T=image/webp,L] RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.jpeg.webp -f RewriteCond %{HTTP_HOST}@@%{HTTP_REFERER} ^([^@]*)@@https?://\1/.* RewriteRule (.+)\.jpeg$ /wp-content/uploads-webpc/$1.jpeg.webp [NC,T=image/webp,L] RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads-webpc/$1.png.webp -f RewriteCond %{HTTP_HOST}@@%{HTTP_REFERER} ^([^@]*)@@https?://\1/.* RewriteRule (.+)\.png$ /wp-content/uploads-webpc/$1.png.webp [NC,T=image/webp,L] </IfModule> <IfModule mod_headers.c> <FilesMatch "(?i)\.(jpg|jpeg|png)(\.(webp|avif))?$"> Header always set Cache-Control "private" Header append Vary "Accept" </FilesMatch> </IfModule> # ! --- DO NOT EDIT NEXT LINE --- ! # END WebP Converter
配置后 在 LiteSpeed缓存工具箱 中 清除缓存,自己测试清哪个生效
**LiteSpeed缓存 **中配置对象缓存,选 redis 缓存,另外不要开启图像优化
5. Wordfence防火墙
Virtual Hosts > wordpress > General
手动输入php.ini Override 规则,不然扫描会失败
php_value auto_prepend_file /usr/local/lsws/wordpress/wordfence-waf.php
右上角reload
6.修改 php.ini
找到php.ini配置文件,找到upload_max_filesize,将其改为upload_max_filesize = 20M
pkill lsphp #强制生效
7.可能遇到的问题
https://docs.litespeedtech.com/cloud/images/wordpress/
https://openlitespeed.org/kb/lets-encrypt-ssl-on-openlitespeed/#Before_Installing_SSL
https://blog.csdn.net/wzl505/article/details/103432639
https://403.ie/solved-broken-sitemap-xml-error-line-2-at-column-6/
https://medium.com/@asce4s/fix-wordpress-sitemap-error-error-on-line-2-at-column-6-636dc5d534df