Manually Deploy Community Edition on Linux
Manual Linux deployment is suitable for scenarios where technically proficient users maintain servers, requiring self-installation of Java and database initialization in the /setup page.
Use Cases
- You do not want to use Docker or aaPanel.
- Your server environment requires you to have control, such as existing MySQL or existing operations management practices.
- You can connect to the server via SSH and execute commands.
If you lack technical expertise, we recommend using aaPanel One-Click Deployment or Docker Compose Deployment.
Prepare Files
You only need to prepare one file:
| File | Download URL | Purpose |
|---|---|---|
surveyking.jar | https://download.surveyking.cn/files/surveyking.jar | SurveyKing application |
Acquire using:
curl -L -o surveyking.jar https://download.surveyking.cn/files/surveyking.jar
v1.12.0 does not require manual import of init-mysql.sql. When selecting MySQL, the system automatically initializes the database in the /setup page.
Operation Steps
1. Install Java
SurveyKing requires Java 8 or Java 11.
Ubuntu / Debian:
sudo apt update
sudo apt install -y openjdk-8-jdk
CentOS / RHEL:
sudo yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
Check if Java is installed correctly:
java -version
Seeing the Java version number is sufficient.
2. If Using MySQL, First Create an Empty Database
If you are only trying it out, you can skip this step and choose H2 embedded database later in the /setup page.
For production use, we recommend installing MySQL. MySQL recommends using 5.7 or 8.0.
Ubuntu / Debian:
sudo apt install -y mysql-server
sudo systemctl enable --now mysql
CentOS / RHEL:
sudo yum install -y mysql-server
sudo systemctl enable --now mysqld
Log in to MySQL:
mysql -u root -p
If Ubuntu prompts that root cannot log in directly, use:
sudo mysql
Execute the following SQL. Change your MySQL password to a more complex password and save it securely.
CREATE DATABASE surveyking DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'surveyking'@'localhost' IDENTIFIED BY 'your_mysql_password';
GRANT ALL PRIVILEGES ON surveyking.* TO 'surveyking'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Only create an empty database here, do not manually import the SQL.
3. Download jar and Start SurveyKing
Create application directory:
sudo mkdir -p /opt/surveyking/files /opt/surveyking/logs
sudo chown -R $USER:$USER /opt/surveyking
Download backend jar:
cd /opt/surveyking
curl -L -o surveyking.jar https://download.surveyking.cn/files/surveyking.jar
Start SurveyKing:
nohup java -Xms512m -Xmx1024m -jar /opt/surveyking/surveyking.jar \
--spring.profiles.active=h2 \
--server.port=1991 \
--file-storage.local.root-path=/opt/surveyking/files \
> /opt/surveyking/logs/surveyking.log 2>&1 &
View startup log:
tail -f /opt/surveyking/logs/surveyking.log
Seeing Started SurveyServerApplication indicates successful startup.
4. Open /setup to Complete Initialization
Browse to:
http://server_public_ip:1991
The first time you open it, you will enter the /setup page.
- Trial: Select H2 embedded database.
- Use MySQL: Select MySQL Database, and choose Other MySQL Service for deployment method.
Fill in the MySQL information as follows:
| Configuration Item | Fill in Content |
|---|---|
| Database address | localhost |
| Port number | 3306 |
| Database name | surveyking |
| Username | surveyking |
| Password | The password you set in step 2 |
Then proceed as described in Initialization, Backup and Upgrade to fill in system information and complete initialization. If you choose MySQL, the system will write /opt/surveyking/application.properties and automatically restart.
5. Log In and Change Password
After initialization is complete, log in using the default account as described in Initialization, Backup and Upgrade and immediately change your password.
Set Auto Startup
If you want SurveyKing to start automatically after server restarts, create a systemd service.
1. Create Service File
sudo vim /etc/systemd/system/surveyking.service
Write the following content:
[Unit]
Description=SurveyKing
After=network.target mysql.service mysqld.service
[Service]
Type=simple
WorkingDirectory=/opt/surveyking
ExecStart=/usr/bin/java -Xms512m -Xmx1024m -jar /opt/surveyking/surveyking.jar --spring.profiles.active=h2 --server.port=1991 --file-storage.local.root-path=/opt/surveyking/files
Restart=always
RestartSec=10
StandardOutput=append:/opt/surveyking/logs/surveyking.log
StandardError=append:/opt/surveyking/logs/surveyking.log
[Install]
WantedBy=multi-user.target
If you choose MySQL in the /setup page, the system will automatically generate /opt/surveyking/application.properties. The systemd startup will read this file, so you do not need to manually write the database password into the service file.
2. Start Service
sudo systemctl daemon-reload
sudo systemctl enable surveyking
sudo systemctl start surveyking
sudo systemctl status surveyking
Common commands:
| What You Want To Do | Command |
|---|---|
| Start | sudo systemctl start surveyking |
| Stop | sudo systemctl stop surveyking |
| Restart | sudo systemctl restart surveyking |
| Check Status | sudo systemctl status surveyking |
| View Log | tail -f /opt/surveyking/logs/surveyking.log |
Allow Port
If the browser cannot open, first confirm that the server's system firewall and cloud service provider security group allow port 1991.
Ubuntu / Debian:
sudo ufw allow 1991/tcp
sudo ufw status
CentOS / RHEL:
sudo firewall-cmd --permanent --add-port=1991/tcp
sudo firewall-cmd --reload
sudo firewall-cmd --list-ports
Cloud servers also need to go to the cloud service provider control panel to allow security group. Only allowing ports in the system does not necessarily mean that the public network can access it.
Backup and Upgrade
Daily backup, import restore, and upgrade steps are unified as described in: Initialization, Backup and Upgrade.
If you are familiar with Linux services, you can also export a backup and then replace the jar file in place:
sudo systemctl stop surveyking
cd /opt/surveyking
cp surveyking.jar surveyking.jar.bak
curl -L -o surveyking.jar.new https://download.surveyking.cn/files/surveyking.jar
mv surveyking.jar.new surveyking.jar
sudo systemctl start surveyking
Common Questions
Why do I enter /setup instead of the login page?
This is the initial initialization page for v1.12.0. The system needs to confirm whether you are using H2 or MySQL.
Proceed as described in Initialization, Backup and Upgrade to complete initialization before accessing the system again, which will then enter the login page.
Why can't my mobile device access localhost:1991?
localhost only represents the current device. localhost on a mobile device is itself, not the server.
When a mobile device accesses a Linux server, enter:
http://server_public_ip:1991
If the server is on a local area network, enter the server's LAN IP address, such as:
http://192.168.1.23:1991
How do I resolve MySQL connection test failure?
Check in order:
- Whether MySQL is running:
sudo systemctl status mysqlorsudo systemctl status mysqld. - Whether the database name is
surveyking. - Whether the database address in
/setupis filled withlocalhost. - Whether the username and password are correct.
- Whether the MySQL user is allowed to log in from
localhost.
Do not manually import init-mysql.sql. The system will automatically initialize table structures and default data during /setup.
Port 1991 is already in use, what should I do?
Check port usage:
sudo lsof -i :1991
If you want to change it to 8080, change the startup command or systemd file:
--server.port=1991
to:
--server.port=8080
Then restart the service and access http://your public IP address:8080.
How can I confirm that SurveyKing is running?
If using systemd to start:
sudo systemctl status surveyking
If using nohup to start:
ps aux | grep surveyking.jar
View the log:
tail -f /opt/surveyking/logs/surveyking.log