Learning Apache

Installing Apache

I already had Apache installed, but to install it use command:
sudo apt-get update && sudo apt-get install apache2

I checked localhost on my web browser and Apache is working and operational.

Next I did an example web page using nano.

example_page

Surfing my Web pages

I made a number of example web pages and surfed through them. Everything went smoothly.
I then wrote an address I knew didn’t exist on my web server and got an error message.
The existing pages load up without a hitch because the server has access to the files,
where as the page I made up and doesn’t exist can’t be found and thus the error message
in the access log.

apache_log

Error in the code

Next I made a simple page using php and html to force some code errors to appear on my logs.
I made a deliberate syntax error into my code (pictured below) to force the 500 internal server error.
The code has fatal errors, and therefore the page does not load correctly, leading to error message in the log.

faulty_codephp_error

Error in Apache config file

To cause an error in Apache, I edited the main apache2.conf file and added a path to a directory that did not exist.
I then restarted the server and went to see if I could access any of my example pages. I got the 403 status code, because I now did not have access to the server. The faulty directory path did the trick.

apache_conf_error

HTTP status codes

While doing my assignments I ran into the following status codes.

I got the 200 status code for every succesfull download of a web page.
404 error for a page that could not be found, meaning there was not such a page on the web server.

403 error ‘Forbidden’, because I did not have permission to access the server, thanks to tampering with the directory path.
The web server now believes that the new path doesn’t have credentials, which of course it doesn’t because it doesn’t exist.

500 internal server error for .php file with fatal syntax errors in the code, meaning the server could not load the page properly.

Sources:

Linux course by Tero Karvinen

HTML tutorials

PHP tutorials

Apache misconfigurations

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s