Find DB Version
When your running your own lamp on vps having a cheatsheet like this for Apache may come in handy. Especially when the rubber hits the road.
Stop your web server
1
| sudo systemctl stop apache2
|
Start the web server when it is stopped, type:
1
| sudo systemctl start apache2
|
Stop and then start the service again, type:
1
| sudo systemctl restart apache2
|
Reload without dropping connections.
1
| sudo systemctl reload apache2
|
Re-enable the service to start up at boot, type:
1
| sudo systemctl enable apache2
|
1
| sudo a2ensite your_domain.conf
|
Disable the default site defined in 000-default.conf:
1
| sudo a2dissite 000-default.conf
|
Test for configuration errors:
1
| sudo apache2ctl configtest
|
REBOOT reboot a server from the command line, run:
1
| sudo systemctl disable apache2
|
Query the state of apache processes
1
| sudo systemctl status apache2.service -l --no-pager
|
Check apache for config errors
1
| sudo apachectl configtest
|
Search apache error log
This will only search 2 lines
1
| sudo tail -n 2 /var/log/apache2/error.log
|
View apache error log
1
| vim /var/log/apache2/error.log
|
Troubleshooting
Apache not starting
Find out what the problem is:
1
| sudo apachectl configtest
|
Whenever i delete certificates and then restart the server. then apache fails to start up because some of the certificate files still need to be deleted. All the details for this are output in the configtest log.
UFW
It’s so satisfying and much cheaper to host your own websites on a self managed barebones vps. But if you’re going to host your own websites then you will need to have a firewall running to protect your website from hackers.
Luckily UFW, the default firewall on Linux distributions makes the process of enabling a firewall simple.
What is a website firewall?
A website firewall is a security solution designed to monitor, filter, and block malicious traffic to a website. It helps protect against various online threats, such as hacking attempts, DDoS attacks, and other types of cyber threats by analyzing and filtering incoming web traffic.
What is UFW?
Uncomplicated Firewall (UFW) is a user-friendly command-line interface for managing iptables, which is the default firewall management tool in many Linux distributions. UFW is designed to simplify the process of configuring a firewall by providing a straightforward syntax.
Enable Firewall
Disable Firewall
Status
See what rules are in place
1
| sudo ufw status verbose
|
Allow range of ip’s
1
| sudo ufw allow proto tcp from 104.245.210.224/28 to any port 22
|
Allow range of ip’s with a dry run
1
| sudo ufw --dry-run allow proto tcp from 104.245.210.224/28 to any port 22
|
Reset all UFW rules
Start from the default ufw configuring your rules
allow access to special port
1
| ufw allow from 1.2.3.4 to any port 7080
|
To view all blocked threats using Uncomplicated Firewall (ufw), you can check the firewall logs. Use the following command in the terminal:
1
2
| sudo ufw status | grep BLOCK
|
This command filters the status output to show only the blocked entries, providing information about blocked threats or unauthorized access attempts.