A Bit of Slack Never Hurt Anyone

LAMP on Slackware. (Part 1)

How to configure Apache, MySQL and PHP on your Slackware machine...Next


Please don't blindly open your web-server (80,443/TCP) or database server (3306/TCP) to the Internet unless you really understand the risks involved. When learning to program a language such as PHP it's very easy to make some simple mistakes that can leave your application (and even your entire server) open to malicious attacks.

Please use your firewall and or host based restrictions to only allow access to the hosts you trust until such a time that you are confident that your code is secure and robust.

This tutorial will assume that you have done a Full Install (A full Slackware install has everything you need) and that you already have your network configured correctly.

Apache httpd server

Httpd is the webserver software, we'll make sure it's working first

The httpd server configuration files live in /etc/httpd/, the main config file is httpd.conf but there are also files in /etc/httpd/extra/.
Files in the extra directory are pulled into the main httpd.conf file by way of "Include" directives (extra/ is the equivalent of the conf.d/ directory you might find on other distributions).

Using your favourite text editor (don't use a word processor on config files) open up the file.vim /etc/httpd/httpd.conf Do read and take notice of the warnings at the top of the file.

Take note of the following Directives as you work your way down the file.

  • Listen (The IP address:port that the server will listen on)
  • User/Group (The user/group combo that the server will run as)
  • ServerAdmin (set this to your email address if you want it to appear in error messages)
  • DocumentRoot (this is the top level directory for your server and where the default files will be located)
  • ErrorLog (Location of the logfile to send errors)
  • CustomLog (Location of the logfile to send normal log output)
Continue down until you see this section<Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory> Notice the "Deny from all"? This sets the default policy for the server to deny requests from everyone unless specifically allowed by another Directive. Now keep going until you see the Directory block pertaining to your DocumentRoot<Directory "/srv/httpd/htdocs"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>Default should look like this (Comments are removed)
The "Allow from all" in this section overides the previous "Deny policy for this directory and everything below it. If you want to restrict it further, the "all" can be replaced with an IP address/hostmask.

Ok Now if you made any changes to the file be sure to save them. It's always best to make sure the syntax you used in the file was correct.
This can be done withapachectl -tIf you get any other message than "Syntax OK" go back and correct any errors before proceeding.

To start the httpd server and to be sure it starts each time at boot, we need to set the /etc/rc.d/rc.httpd file as executable and start it with the following commandschmod 0744 /etc/rc.d/rc.httpd /etc/rc.d/rc.httpd startWith luck you'll see a message telling you the server started. If so, open a web browser and point it at "http://localhost/" and you should be greeted with a blank page with the words "It Works!".

If you do not get to this page then check your error_log and access_log (You noted the location above). These two files are your best source of information when trouble-shooting your web server

Once you are happy with your results, continue on to LAMP on Slackware Part 2