本教程将指导您在 HestiaCP 上安装 WHMCS。WHMCS 是一款强大的自动化账单和客户管理系统,广泛用于 VPS 提供商和 Web 主机商。
系统要求
安装 WHMCS
在 HestiaCP 中新建网站,配置ssl,新建数据库的操作就不再赘述了。如果你是第一次看到 HestiaCP 系列教程,请点击下方链接,就能看到完整的一系列教程了。
下载安装包
我们在 /home/user/web/domain/public_html/
目录下放入下载好的安装包,然后解压。
安装 ionCube
执行以下命令安装 ionCube Loader:
wget https://raw.githubusercontent.com/jaapmarcus/ioncube-hestia-installer/main/install_ioncube.sh
chmod +x install_ioncube.sh
./install_ioncube.sh
💡
ioncube不支持php 8.0,但它支持php 8.1和php 8.2。
配置 Nginx
在 HestiaCP 中配置 Nginx 时,您需要使用 Nginx 配置模板。以下是我为您提供的两个常用模板,仅供参考:
.tpl
server {
listen %ip%:%proxy_port%;
server_name %domain_idn% %alias_idn%;
root %docroot%;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/%domain%.log combined;
access_log /var/log/nginx/domains/%domain%.bytes bytes;
error_log /var/log/nginx/domains/%domain%.error.log error;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
charset utf-8;
location ~ %docroot%/admin/(client!\.php|client/(.*)|table/(.*)|search!\.php|search/(.*)|apps|billing|setup|user|services|addons|domains|utilitiesemailmarketer!\.php|utilities/(.*)|logs|help!\.php|help/license|modules|image/(recent|upload)|validation_com/(.*))/?(.*)$ {
rewrite ^/(.*)$ %docroot%/admin/index.php?rp=/admin/$1/$2;
}
location ~ %docroot%/(images/em|invoice|login|password|account|store|download|knowledgebase|announcements|clientarea/ssl-certificates|user/(verification|accounts|profile|password|security|verify)|cart/(domain/renew)|domain/pricing|cart/order|images/kb)/?(.*)$ {
rewrite ^/(.*)$ %docroot%/index.php?rp=/$1/$2;
}
location ~ %docroot%/auth/manage/client/links/?(.*)$ {
rewrite ^/(.*)$ %docroot%/index.php?rp=/auth/manage/client/links$1;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
location ~ \.php$ {
fastcgi_pass %backend_lsnr%;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
location ^~ %docroot%/vendor/ {
deny all;
return 403;
}
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|svg|woff|woff2|ttf)\$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
location ~* \.(?:css|js)\$ {
expires 7d;
access_log off;
add_header Cache-Control "public";
}
location ~ /\.ht {
deny all;
}
}
.stpl
server {
listen %ip%:%proxy_ssl_port% ssl;
server_name %domain_idn% %alias_idn%;
root %docroot%;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/%domain%.log combined;
access_log /var/log/nginx/domains/%domain%.bytes bytes;
error_log /var/log/nginx/domains/%domain%.error.log error;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
charset utf-8;
ssl_certificate %ssl_pem%;
ssl_certificate_key %ssl_key%;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
ssl_prefer_server_ciphers on;
location ~ %docroot%/admin/(client!\.php|client/(.*)|table/(.*)|search!\.php|search/(.*)|apps|billing|setup|user|services|addons|domains|utilitiesemailmarketer!\.php|utilities/(.*)|logs|help!\.php|help/license|modules|image/(recent|upload)|validation_com/(.*))/?(.*)$ {
rewrite ^/(.*)$ %docroot%/admin/index.php?rp=/admin/$1/$2;
}
location ~ %docroot%/(images/em|invoice|login|password|account|store|download|knowledgebase|announcements|clientarea/ssl-certificates|user/(verification|accounts|profile|password|security|verify)|cart/(domain/renew)|domain/pricing|cart/order|images/kb)/?(.*)$ {
rewrite ^/(.*)$ %docroot%/index.php?rp=/$1/$2;
}
location ~ %docroot%/auth/manage/client/links/?(.*)$ {
rewrite ^/(.*)$ %docroot%/index.php?rp=/auth/manage/client/links$1;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
location ~ \.php$ {
fastcgi_pass %backend_lsnr%;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
location ^~ %docroot%/vendor/ {
deny all;
return 403;
}
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|svg|woff|woff2|ttf)\$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
location ~* \.(?:css|js)\$ {
expires 7d;
access_log off;
add_header Cache-Control "public";
}
location ~ /\.ht {
deny all;
}
}
配置 WHMCS
导航到安装脚本
在浏览器中,访问 WHMCS 安装脚本的 URL,格式如下:
http://www.example.com/whmcs/install/install.php
在浏览器中,按照 WHMCS 安装向导的提示进行操作:
- 接受《最终用户许可协议》
- 配置数据库
- 输入您的许可证密钥
- 创建管理员账户
删除安装文件夹
完成安装后,您将看到安装完成页面。此时,为了安全起见,您需要删除 install
文件夹。运行以下命令删除:
sudo rm -rf /home/user/web/domain/public_html/install/
检查文件和文件夹权限
确保 WHMCS 的重要文件和目录权限设置正确,以确保系统正常运行。特别是以下文件和文件夹:
/configuration.php
文件:应设置为CHMOD 400
(只读)。/attachments
目录:应设置为CHMOD 777
(可写)。/downloads
目录:应设置为CHMOD 777
(可写)。/templates_c
目录:应设置为CHMOD 777
(可写)。
注意:根据您的服务器配置,您可能需要调整权限。例如:
- 使用 suPHP 或 suEXEC 时,可能需要限制目录访问权限。
- 使用 DSO 时,配置文件可能需要设置为
CHMOD 644
。