Troubleshooting methods for Web Servers and background services running on Linux Cloud Servers

2022-06-06 By Nathan 664 Views linux troubleshooting web server
0 reviews

This tutorial explains troubleshooting methods and strategies in the events about Linux Cloud Server is not able to connect to your web server, database, or other services running on the Linux Cloud Servers.


Before beginning this tutorial, the Cloud Server's root access is the prerequisite for this. In other words, the server's root password must be available, so as to perform operations.


Checking the Service Status

During the process of troubleshooting, it is quite normal to check the status of the service running in the background/foreground. This can be done through the below command.

# systemctl status <service-name>


Examples:

troubleshootingwebserver1

troubleshootingwebserver2

troubleshootingwebserver3


Restarting the Service

If the process is not running you may try to restart the process using the command.

#  systemctl restart <service-name>


Example:

troubleshootingwebserver4


Enabling the Service

If you wish to have the process to survive a server reboot, i.e you would like to start the service automatically when a server reboot is performed, you would require to use the command.

# systemctl enable <service-name>


Examples:

troubleshootingwebserver5

troubleshootingwebserver6


Disabling the Service

Firstly if the service is running, it can be stopped.

# systemctl stop <service-name>

And then disable the service.

# systemctl disable <service-name>


Examples:

troubleshootingwebserver7

troubleshootingwebserver8

troubleshootingwebserver9


Checking the IP address and ports

While performing troubleshooting, it may require checking if any process is listening to any ports or it may be bound by a public IP address, you can use the ss command also called socket statistics command which provides the lists that are currently accessing, Classic example is given below:

# ss -atpu

troubleshootingwebserver10


Analyzing Server logs

For any system/service-related issues it is always recommended to check the server logs to find out more about the issues. If any services don’t start normally, for more insights check the server logs.

  1. To check the contents of the system, use the command journalctl.

  2. The server log location for Ubuntu/Debian will be on /var/log/syslog.

  3. CentOS streams log location will be on /var/log/messages.


A typical Journalctl output will be described as below:

# journalctl -xe

troubleshootingwebserver11


Here are some examples of how to verify the logs:

# tail –f /var/log/syslog

troubleshootingwebserver12


# tail –f /var/log/messages

troubleshootingwebserver13


Checking the Firewall Status

When the service is running without any issues, and still having trouble regarding the connectivity, it is likely the firewall may be interfering with the connections. The below command will help you list the relevant rules.

# iptables -L

troubleshootingwebserver14


To check if it is firewalld or ufw, you would be able to view it by the following commands:

# ufw status

OR

# firewall-cmd --state

troubleshootingwebserver15

troubleshootingwebserver16


For troubleshooting, you can also temporarily disable your firewall to test if it is interfering with your connections.


Troubleshooting the Web Server

Since the webserver troubleshooting is complicated, a standard troubleshooting policy needs to be adopted. This has to identify the correct server problem. Therefore, follow the steps:

  1. Check if the services are running correctly and proceed.

  2. If the webserver is returning a specific error code, some of the HTTP status codes are given.


    The five classes include:

    1xxs: Webserver status code indicating browser request still on

    2xxs: Success server status code

    3xxs: Server redirection status codes indicated

    4xxs: Client error codes citing the problem with the request.

    5xxs: Server error codes citing requests were accepted, but an error on the server prevented the fulfillment of the request.


When the webserver returns with an error code, the troubleshooting steps will vary according to the code returned. Further details will be available from the web server logs. Here are commands that help you find the web server logs:


For Ubuntu/Debian:

# grep ErrorLog -r /etc/apache2

troubleshootingwebserver17

For Centos/Fedora/RHEL:

# grep ErrorLog -r /etc/httpd

troubleshootingwebserver18

For Nginx:

# grep error_log -r /etc/nginx

troubleshootingwebserver19


Troubleshooting the Database

Common issues that may encounter upon that the database process may not start because of the disk reaching full occupancy. The below command shows the storage status:

# df -Th


Once it is checked, as a part of freeing the disk space it will require removing the files that may not be required.

Further, upgrading the Layerstack Cloud server plan is recommendable if most of the storage files are required and essential.


Now, in case of Database running is experiencing some delay and it is affecting the Cloud Server performance, as a part of troubleshooting MySQL can be tuned up or optimized using scripts. The script is given repo:

https://github.com/major/MySQLTuner-perl

Thus with the help of a database administrator, the configuration can be tweaked and tuned up.


Related Tutorials

What do you think about this article?

Rate this article
Need assistance?

Try this guide to receive free bundled services at signup on a new free account.

Sign Up

Your Feedback Is Important

We hope you’ll give the new products and updates a try. If you have an idea for improving our products or want to vote on other user ideas so they get prioritized, please submit your feedback on our Community platform. And if you have any questions, please feel free to ask in the Community or contact our Technical Support team.