Ubuntu Server Management: Real-World Service Automation, Logging, and Backup Strategies

Stable Operations Are More Important Than Server Setup
Hello.
You've now installed Ubuntu Server and configured Nginx, PHP, MySQL, HTTPS, Reverse Proxy, and security settings.
Your server is ready to run actual services.
However, there's something just as important as setting up your server:
Operation and management.
Sudden service termination, server errors, or accidental data deletion can happen to anyone.
In this lesson, we'll explore essential real-world techniques for managing services, analyzing logs, backing up data, and recovering from failures.
What Is systemd?
On Ubuntu, most programs run as services.
The program that manages these services is called systemd.
With systemd, you can easily manage:
Starting services
Stopping services
Restarting services
Setting up automatic startup
Checking service status
It's one of the most commonly used features when operating Ubuntu.
Checking Running Services
To check currently running services, use this command:
systemctl list-units --type=service
This shows a list of all services currently active on your Ubuntu system.
With many services available, it's best to search for the specific ones you need.
Checking Service Status
To check Nginx status, for example:
sudo systemctl status nginx
For MySQL:
sudo systemctl status mysql
And for PHP-FPM:
sudo systemctl status php8.3-fpm
If running normally, you'll see the active (running) status.
Starting and Stopping Services
You can start or stop services directly:
Start service
sudo systemctl start nginx
Stop service
sudo systemctl stop nginx
Restart service
sudo systemctl restart nginx
Reload configuration (without full restart)
sudo systemctl reload nginx
In real operations, reload is often preferred over restart.
Setting Up Automatic Startup
You can configure services to start automatically after reboot:
sudo systemctl enable nginx
To disable automatic startup:
sudo systemctl disable nginx
It's recommended to set up Nginx, MySQL, and PHP-FPM for automatic startup.
What Are Logs?
Most server activities are recorded in logs.
For example:
Login failures
Program errors
Web access
Service startup
Service shutdown
Logs are the first thing to check when problems occur.
Checking systemd Logs
You can view systemd logs using:
journalctl
To check logs for a specific service, use:
journalctl -u nginx
You can also view recent logs only:
journalctl -xe
This command is frequently used when troubleshooting errors.
Checking Nginx Logs
Nginx also provides separate log files:
Access logs
/var/log/nginx/access.log
Error logs
/var/log/nginx/error.log
For real-time monitoring, run:
tail -f /var/log/nginx/error.log
MySQL Logs
MySQL also provides various logs.
The location may vary by environment, but check:
/var/log/mysql/
This is the first place to check when database errors occur.
Checking Disk Space
It's important to regularly monitor storage space during operation.
df -h
This shows:
Total capacity
Used capacity
<Available space
If the disk is full, web services may encounter issues.
Checking Memory Usage
You can check current memory status with:
free -h
Or use the top command to monitor CPU and memory usage in real time.
Backing Up Databases
Databases contain the most critical information on your server.
In MySQL, you can easily back up using:
mysqldump
For example:
mysqldump -u root -p blogdb > blogdb.sql
This saves the database as an SQL file.
It's recommended to establish a regular backup habit.
Restoring Databases
You can restore from your backup SQL file at any time:
mysql -u root -p blogdb < blogdb.sql
This is a very useful feature when failures occur.
Backing Up Website Files
In addition to databases, website files should also be backed up.
For example, compress or copy the /var/www folder to another server.
It's also recommended to back up configuration files in /etc/nginx.
Checklist for When Service Failures Occur
If your website suddenly becomes inaccessible, check in this order:
① Is the server running?
② Is Nginx running?
③ Is PHP-FPM running?
④ Is MySQL running?
⑤ Are there errors in the logs?
⑥ Is disk space sufficient?
Most issues can be resolved by following this sequence.
Monitoring is Also Important
For production servers, it's important to regularly monitor server status.
Check:
CPU usage
Memory usage
Disk space
Traffic
Regular monitoring helps prevent failures before they occur.
As systems grow larger, tools like Grafana or Prometheus are commonly used for monitoring.
What You Learned in This Lesson
In this lesson, we explored practical management techniques for stable Ubuntu server operation.
We learned about systemd service management, log analysis, and backup/recovery procedures—common tasks used in real production environments.
You've now gained knowledge on not just setting up servers but also operating them reliably.
Key Takeaways
systemd is the program that manages services on Ubuntu.
Use
systemctlcommands to start, stop, and restart services.journalctlis used for checking system logs.Nginx and MySQL provide separate log files.
Use
df -handfree -hto check server status.Back up databases using
mysqldump.When failures occur, first check service status and logs.
Next Lesson Preview
12th Lesson (Finale). Running Multiple Websites on One Ubuntu Server (Real-World Nginx + Reverse Proxy + HTTPS Integration)
In the next lesson, we'll combine all previously learned concepts to create a practical project where multiple websites and services run simultaneously on one Ubuntu server, concluding our course.
FAQ
Why is stable operation more important than server setup?
While setting up a server is crucial, ongoing maintenance and monitoring prevent downtime and data loss in real-world scenarios.
How do I check if my Nginx service is running?
Use the command 'sudo systemctl status nginx' to see if it shows 'active (running)'.
What's the best way to back up a MySQL database?
Use 'mysqldump -u root -p [database_name] > backup.sql' to create an SQL file backup.
Korean Source
This article is an English localization of a Korean-language report from BlogScore. Original: [Ubuntu 서버 구축] 11강. 서비스 자동 실행(systemd), 로그 분석, 백업과 장애 대응 실무