Ask a Question
Advertise on boostr.in
Is your Web Server Running?
Now that you are sure your server is installed, is it running?
There are plenty of ways of finding out if the service is running or not. One method that is fairly cross-platform is to use the netstat command.
This will tell you all of the processes that are using ports on the server. We can then grep for the name of the process we are looking for:
sudo netstat -plunt | grep apache2
tcp6 ¬†¬†¬†¬†¬†¬†0 ¬†¬†¬†¬†¬†0 :::80 ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†:::* ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†LISTEN ¬†¬†¬†¬†¬†2000/apache2
You should change "apache2" to the name of the web server process on your server. If you see a line like the one above, it means your process is up and running. If you don't get any output back, it means you queried for the wrong process or that your web server is not running.
If this is the case, you can start it using your distribution's preferred method. For instance, on Ubuntu, you could start the Apache2 service by typing:
sudo service apache2 start
On CentOS you might type something like this:
sudo /etc/init.d/httpd start
If your web server starts, you can check with netstat again to verify that everything is correct.
Is the Syntax of your Web Server Configuration File Correct?
If your web server refused to start, often this is an indication that your configuration files need some attention. Both Apache and Nginx require strict adherence to their directive syntax in order for the files to be read.
The configuration files for these services are usually located within a subdirectory of the /etc/ directory named after the process itself.
Thus, we could get to the main configuration directory of Apache on Ubuntu by typing:
In a similar way, the Apache configuration directory on CentOS also mirrors the CentOS name for that process:
The configuration will be spread out among many different files. If your service failed to start, it will usually point you to the configuration file and the line where the problem was first found. Check that file for errors.
Each of these web servers also provide you with the ability to check the configuration syntax of your files.
If you are using Apache, you can use the apache2ctl or apachectl command to check your configuration files for syntax errors:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
As you can see above, we've received an informational message about a detail in our configuration, but there were no errors. This is good.
If you have an Nginx web server, you can run a similar test by typing:
sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
As you can see, this process checks your syntax as well. If we remove an ending semi-colon from a line in the file (a common error for Nginx configurations), you would get a message like this:
sudo nginx -t
nginx: [emerg] invalid number of arguments in "tcp_nopush" directive in /etc/nginx/nginx.conf:18
nginx: configuration file /etc/nginx/nginx.conf test failed
There is an invalid number of arguments because Nginx looks for a semi-colon to end statements. If it doesn't find one, it drops down to the next line and interpret that as further arguments for the last line.
You can run these tests in order to find syntax problems in your files. Fix the problems that it references until you can get the files to pass the test.
Jun 9, 2015
to add a comment.
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
To avoid this verification in future, please