Starting Apache for the First Time

If you have installed apache2 and its default dependencies apache2-prefork and apache2-utils, you can start the server immediately with the command rcapache2 start. The command rcapache2 status should now confirm that the web server is running. You can also confirm that Apache is listening on port 80 by typing the command telnet localhost 80. You should see something like this:

Trying 127.0.0.1... Connected to localhost. Escape character is '"]'.

If you then point a browser at the local Apache server (use http://localhost/ in the location bar), you may see something that resembles Figure 16-1. Although the server is running, there is no content in the root directory of the web server, and the default Apache configuration on SUSE refuses to display a directory listing in the absence of an index file for security reasons.

FIGURE 16-1

Browsing the local Apache server immediately after installation

FIGURE 16-1

Browsing the local Apache server immediately after installation

But if the package apache2-example-pages is installed, you will see the informative page in Figure 16-2.

FIGURE 16-2

Apache telling us that it's working

FIGURE 16-2

Apache telling us that it's working

The page that we are seeing here can be found in the root directory of the web server, which is at /srv/www/htdocs by default. (This location is one of the many things that can be changed in the Apache configuration files). The file that we are seeing is /srv/www/htdocs/index.html, which is the minimal HTML page:

<html><body><h1>It works!</h1></body></html>

Now you know that you have a basic working Apache configuration, and you can replace the current contents of /var/www/htdocs/ by a set of static web pages. Then anyone who can reach the server with a browser by its IP address or DNS name will see the content.

Was this article helpful?

0 0

Post a comment