一. 安装宝塔
$ yum install -y wget
$ wget -O install.sh http://download.bt.cn/install/install_6.0.sh
$ sh install.sh ed8484bec
二. 安装LNMP
Nginx 1.22.0
MySQL 5.7.39
PHP-7.4.30
三. 安装数据库
3.1 导出表结构
3.2 导出dict\system_field\system_right
3.3 导出customer_rule_config id:1-6
3.4 导出system_role id:1
3.5 导出system_role_right role_id:1
3.6 导出system_user id:1
3.7 导出system_user_role id:1
四. nginx配置
log_format main '{ "@timestamp": "$time_local", '
'"remote_addr": "$remote_addr", '
'"domain": "$host", '
'"referer": "$http_referer", '
'"request": "$request", '
'"status": $status, '
'"bytes": $body_bytes_sent, '
'"agent": "$http_user_agent", '
'"x_forwarded": "$http_x_forwarded_for", '
'"up_addr": "$upstream_addr",'
'"up_host": "$upstream_http_host",'
'"up_resp_time": "$upstream_response_time",'
'"request_time": "$request_time"'
' }';
server
{
listen 80;
server_name #ip#;
index index.html index.php;
root /www/wwwroot/crm/public;
#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
#SSL-END
#ERROR-PAGE-START 错误页配置,可以注释、删除或修改
#error_page 404 /404.html;
#error_page 502 /502.html;
#ERROR-PAGE-END
#PHP-INFO-START PHP引用配置,可以注释或修改
include enable-php-74.conf;
#PHP-INFO-END
client_max_body_size 50m;
location ~ /api/app/ws {
proxy_pass http://127.0.0.1:2346;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location ~ /api {
rewrite ^(.*)$ /index.php break;
fastcgi_pass unix:/tmp/php-cgi-74.sock;
fastcgi_param SCRIPT_FILENAME /www/wwwroot/crm/public/index.php;
include fastcgi.conf;
}
location ~ /resource {
root /www/wwwroot/crm/public;
}
location / {
rewrite ^(.*)$ /index.html break;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
#一键申请SSL证书验证目录相关设置
location ~ \.well-known{
allow all;
}
#禁止在证书验证目录放入敏感文件
if ( $uri ~ "^/\.well-known/.*\.(php|jsp|py|js|css|lua|ts|go|zip|tar\.gz|rar|7z|sql|bak)$" ) {
return 403;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log /dev/null;
access_log /dev/null;
}
location ~ .*\.(js|css)?$
{
expires 12h;
error_log /dev/null;
access_log /dev/null;
}
access_log /www/wwwlogs/crm.log main;
error_log /www/wwwlogs/crm.error.log;
}
五. 增加发布脚本
$ cp -R c1 cx
六. 整理对方的服务器
6.1 建目录
mkdir /www/wwwroot/backup
mkdir /www/session
chmod -R 777 /www/session
6.2 发布脚本:
d=`date '+%s'`
tar xvf crm.tar.gz
mv crm backup/crm_bak_$d
mv crm4 crm
mv crm.tar.gz backup
六. 定时脚本
数据库备份
日志切割
/www/wwwlogs/*.log
定时分配
$ php /www/wwwroot/crm/artisan assign >> /www/wwwlogs/crm.cron.assign.log
七. 注意事项
开启opcache
配置mysql缓存