前提
- 支持系统:Centos7.x,Python 2.7,512MB or above Ram,10GB Disk Space
- 资源:
- 登录服务器软件(mac_zoc,win_xshell/putty)、
- FTP软件(mac_Yummy FTP,win_xftp)
- CyberPanel
一、安装
手动安装
wget http://cyberpanel.net/install.tar.gz
tar zxf install.tar.gz
cd install
chmod +x install.py
python install.py [IP Address] # [IP Address]是服务器的IP地址
一键脚本
- 国内服务器请使用以下命令,已经替换MariaDB为阿里云源。
sh <(curl https://cn.cyberpanel.net/download/install-cn.sh || wget -O - https://cn.cyberpanel.net/download/install-cn.sh)
- 国外服务器请使用以下命令,MariaDB官方源。
sh <(curl https://cn.cyberpanel.net/download/install.sh || wget -O - https://cn.cyberpanel.net/download/install.sh)
安装完毕后,默认参数
https: IP Address:8090
Username: admin
Password: 1234567
二、迁移wordpress后的相关问题
- 1、固定链接404错误(Apache或Litespeed)
- 进入设置好的网站,选择文件管理器(filemanager),进入网站文件夹,编辑.htaccess,添加如下代码,并重启litespeed
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
小福利,迁移到nginx出现固定连接404,在网站的nginx配置文件里添加
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
- 2、网站备份文件上传问题
- 因为面板自带文件管理器(filemanager)不能上传大文件,所以得需要FTP软件
- 在网站账户下,新建FTP用户
- 用此用户名+密码登录ftp,上传备份压缩文件(zip)
- 3、数据库链接问题
- 修改网站文件夹里的wp-config.php(A)
- 如果使用面板自带一键安装wordpress,则查看新建的数据库名字、用户名名字、密码(B)
- 以上 A和B 保持一致便可
- 完成以上后,使用面板自带的phpadmin登录数据库,导入备份的数据库
下文为转载:https://vps.group/cyberpanel-ols-rewrite-20171124.html
CyberPanel使用了OpenLiteSpeed(OLS)为web服务器,OLS可以兼容apache的.htaccess文件,但是略有不同,主要差别为OLS需要添加一个斜杆(/),比如WordPress自带的.htaccess内容为
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
然而这份规则并不完全兼容OLS,开启固定链接后会导致404错误,此时应当修改规则为
RewriteEngine On
RewriteBase /
RewriteRule ^/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
注意第三行的代码
原代码为:RewriteRule ^index.php$ - [L] ,修改为 RewriteRule ^/index\.php$ - [L]
唯一的差别就是那个红色的斜杆/注意修改后需要重启OLS以生效。
附Opencart 2.3.0.2的伪静态规则。
RewriteRule ^/.*\.(log|ini|tpl|txt)$ - [F,L,NC]
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^/([^?]*) index.php?_route_=$1 [L,QSA]
对比一下OC2.3.0.2的原始规则,在最后一行你会发现 多了一个斜杆。。。
其中第一行的RewriteRule ^/.*.(log|ini|tpl|txt)$ - [F,L,NC]规则解释为:直接返回403,禁止访问任何后缀为log,ini,tpl和txt的文件。
第2种方法
vhost编辑文件内的伪静态规则,cyberpanel面板中直接编辑vhost配置文件。
在配置文件中找到
rewrite {
enable 1
rules <<<END_rules
rewriteFile /home/你的域名/public_html/.htaccess
END_rules
}
将其中的rewriteFile /home/你的域名/public_html/.htaccess 直接替换为你的伪静态,以WP的伪静态为例,修改后的代码为:
rewrite {
enable 1
rules <<<END_rules
RewriteEngine On
RewriteBase /
RewriteRule ^/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
END_rules
}
这样就可以通过无需.htaccess文件实现伪静态了。
需要注意的是,在vhost配置文件中的伪静态,并不支持 rewrite base ,需要进行修改。比如你的WP在/wordpress子目录下,那么 .htaccess内的伪静态为:
RewriteEngine On
RewriteBase /wordpress
RewriteRule ^/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
如果需要添加到vhost配置文件中,那么需要修改为:
RewriteEngine On
RewriteBase /
RewriteRule ^/wordpress/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
注意第三行内容, 将 第一行的wordpress,移动到了 index前面,这就是唯一需要修改的地方。