安裝寶塔: 購買雲伺服器,選擇帶寶塔面闆的執行個體
安裝環境:登入寶塔安裝Nginx、Redis
建nginx站點:網站->添加站點
生成的站點,點選設定
nginx設定:域名管理
nginx設定:網站目錄
nginx設定:配置檔案
server
{
listen 80;
server_name deepcube.top www.deepcube.top;
index index.php index.html index.htm default.php default.htm default.html;
root /mnt/webapp/shop/dist;
#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-00.conf;
#PHP-INFO-END
#REWRITE-START URL重寫規則引用,修改後将導緻面闆設定的僞靜态規則失效
include /www/server/panel/vhost/rewrite/deepcube.top.conf;
#REWRITE-END
#禁止通路的檔案或目錄
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
#一鍵申請SSL證書驗證目錄相關設定
location ~ \.well-known{
allow all;
}
location / {
try_files $uri /index.html;
}
location /api {
proxy_pass http://localhost:8001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection ‘upgrade’;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /auth {
proxy_pass http://localhost:8001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection ‘upgrade’;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log off;
access_log /dev/null;
}
location ~ .*\.(js|css)?$
{
expires 12h;
error_log off;
access_log /dev/null;
}
access_log /www/wwwlogs/deepcube.top.log;
error_log /www/wwwlogs/deepcube.top.error.log;
}
mysql資料庫配置
檔案上傳至步驟6指定的目錄
啟動後端項目
cd /mnt/webapp/shop
./nohup java -jar demo.jar > ./demo.log 2>&1 &
demo換成你的包名
重新開機nginx 大功告成!!