The running environment requires MySQL, Redis, ElasticSearch, and JDK to be installed and configured manually.
Open the command tool, navigate to the root directory of the project, and execute the following packaging commands:
mvn clean package -Dmaven.test.skip=true
- The code identifier, version number, numbers, and original meaning should be retained. Using PowerShell in the Windows system may cause errors. Please enclose maven.test.skip in quotes.
- Ensure that the database, Redis, and other configurations specified in the application-prod.yml configuration file are correct.
Address of the packaged jar file: ChestnutCMS
{Project Root Directory}/chestnut-admin/target/chestnut-admin.jar
Upload the packaged file to the server, thereby terminating the running server process.
Check whether there is an active application process running. If so, use kill -5 to terminate it. If termination is not possible, use kill -9 to destroy the process.
# View process number
ps aux|grep java
# End the process.
kill -5 PID
# Check if it still exists.
ps aux|grep java
# Forced termination may result in data loss.
kill -9 PID
Confirm that the server process no longer exists. Execute the following command to start the server.
nohup java -jar chestnut-admin.jar --file.encoding=utf-8 --spring.profiles.active=prod
Open the command tool, navigate to the root directory of the project, and execute the following packaging commands:
# Enter the front-end project directory
cd chestnut-ui
# Install dependencies
npm install --registry=https://registry.npmmirror.com
# Build
npm run build:prod
Build results directory: {project_root}/chestnut-ui/dist/
{PROJECT_ROOT}/chestnut-ui/dist/ Upload to the serverThis example uploads
{PROJECT_ROOT}/chestnut-ui/dist/to/home/app/chestnut-uibefore configuring Nginx.
# Create a backup directory
/home/bak/
# Enter the application directory
cd /home/app
# Backup chestnut-ui
mv /chestnut-ui ../bak/chestnut-ui-bak/
# Rename the dist directory
mv dist chestnut-ui
# Install
yum install -y nginx
# Launch
nginx
cd /etc/nginx/conf.d/
vi admin.conf
Modify the contents of admin.conf as follows:
server {
listen 81;
server_name 192.168.1.5;
charset utf-8;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Connection close;
location / {
root /home/app/chestnut-ui;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /prod-api/ {
client_max_body_size 200m;
proxy_pass http://localhost:8090/;
}
location /upload/ {
root /home/app/uploadPath;
expires 1d;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# Please verify whether the configuration is correct.
nginx -t
# Restart nginx
nginx -s reload
The configuration for the access address in the above example is as follows:http://192.168.1.5:81/
Common problems: - The verification code cannot be displayed. The server reports an error: Fontconfig head is null. Please check your fonts or font configuration. Solution: There is a lack of font files required for processing. Please execute the following command:
yum install -y fontconfig
If it is necessary to use something similar to this…
http://192.168.1.5:81/To access the backend via the subpath, it is necessary to modify the build environment configuration and nginx configuration as follows:
Modify the configuration file. ChestnutCMS/chestnut-ui/.env.production
# Production environment configuration
ENV = 'production'
# ChestnutCMS Production Environment
VUE_APP_BASE_API = '/prod-api'
# Access address
VUE_APP_PATH = '/admin/'
2. Modifying the Nginx configuration file
server {
listen 81;
server_name 192.168.1.5;
charset utf-8;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Connection close;
location /admin/ {
alias /home/app/chestnut-ui;
try_files $uri $uri/ /admin/index.html;
index index.html index.htm;
}
location /prod-api/ {
client_max_body_size 200m;
# Note the slash at the end of the URI string. The original URI will be replaced with: /prod-api/user → /user
# Without a trailing slash, the request URI will be preserved: /prod-api/user → /prod-api/user
proxy_pass http://localhost:8090/;
}
location /upload/ {
root /home/app/uploadPath;
expires 1d;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
1. Modifying Nginx configuration settings
cd /etc/nginx/conf.d/
vi site.conf
Modify the content of site.conf as follows:
server {
listen 80;
server_name 192.168.1.5; # Site domain configured for the publishing channel
charset utf-8;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Connection close;
location / {
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
root /home/app/wwwroot_release/site_pc;
index index.shtml index.html index.htm;
}
location ~ ^/(images|img|fonts|assets|js|css)/ {
root /home/app/wwwroot_release/site_pc;
expires 1d;
}
# User resource access configuration
location ~ ^/(resources)/ {
root /home/app/wwwroot_release/site;
expires 1d;
}
# Configuration for API interface access
location ~ ^/(api)/ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods *;
add_header Access-Control-Allow-Headers *;
proxy_buffers 32 8k;
add_after_body "";
proxy_cookie_path / /;
proxy_pass http://localhost:8090;
}
# Configuration for accessing site/category/content dynamic templates
location ^~ /cms/view/ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods *;
add_header Access-Control-Allow-Headers *;
ssi on;
ssi_silent_errors on;
proxy_buffers 32 8k;
add_after_body "";
proxy_cookie_path / /;
proxy_pass http://localhost:8090;
}
# Search page dynamic template access configuration
location = /_search {
# To hide the sid and pp parameters, you can use a rewrite configuration.
# rewrite /_search?(.*) /_search?sid={site_id}&pp={release_channel_code}&$1 break;
ssi on;
ssi_silent_errors on;
proxy_buffers 32 8k;
add_after_body "";
proxy_cookie_path / /;
proxy_pass http://localhost:8090;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Execute the command nginx -s reload Restart nginx. Access:http://server_name/
The configuration for the access address in the above example is as follows:http://192.168.1.5/
chestnut-cms-media Select the JAVA native dependencies through the Maven profile. Please choose according to the target deployment platform, regardless of the build system on which Maven is running.
| Profile | Target Platforms | Original dependencies that are packaged |
|---|---|---|
media-linux64 | Linux x86_64 | jave-nativebin-linux64 |
media-win64 | Windows x86_64 | jave-nativebin-win64 |
media-osxm1 | MacOS Apple Silicon (M Series, aarch64 JDK) | jave-nativebin-osxm1 |
media-osx64 | macOS Intel(x86_64 JDK) | jave-nativebin-osx64 |
media-all(Default setting) | All the above platforms | Include all four dependencies mentioned above |
Execute in the root directory of the project:
# Linux x86_64 Deployment Package
mvn clean package -pl chestnut-admin -am -Pmedia-linux64 -Dmaven.test.skip=true
# Windows x86_64 Deployment Package
mvn clean package -pl chestnut-admin -am -Pmedia-win64 -Dmaven.test.skip=true
# Local build for macOS with Apple Silicon technology
mvn clean package -pl chestnut-admin -am -Pmedia-osxm1 -Dmaven.test.skip=true
# Build locally on macOS Intel
mvn clean package -pl chestnut-admin -am -Pmedia-osx64 -Dmaven.test.skip=true
# When the Profile is not specified, it includes native dependencies for all four platforms, compatible with local development.
mvn clean package -pl chestnut-admin -am -Dmaven.test.skip=true
Only one media profile can be selected at a time. When selecting a profile for a specific platform, the default value will be used. media-all Automatic disactivation.jave-core Always keep it preserved; the native dependencies remain intact. runtime The scope is passed to the application, and packaged by Spring Boot.
When developing locally on macOS, simply reload the Maven project in the IDE to use the default settings. media-all No need to select a profile separately. You can simply check the corresponding option in the Maven profiles of the IDE. media-osxm1 or media-osx64 Reduce local dependencies. Follow the JDK architecture used to run the application: When using aarch64 JDK for Apple Silicon, choose accordingly. media-osxm1 When using the x86_64 JDK under Rosetta, please make the appropriate selection. media-osx64 Still using the same method for building Linux deployment packages on Macs. -Pmedia-linux64 It does not include any native dependencies related to macOS.
Available jar tf chestnut-admin/target/chestnut-admin.jar Inspection BOOT-INF/lib/ down jave- Dependency. Linux platform-specific packages should only contain… jave-core and jave-nativebin-linux64 Linux and Windows profiles are compatible with x86_64 architectures. For other platforms such as Linux ARM64, additional configuration is required to ensure that the necessary native dependencies are properly configured.