Andrew J. Nelson
12 April 2013
This how-to will demonstrate quickly setting up a SLAMP (Slackware Apache MySQL PHP) server with minimal fuss. We won't delve into the full configuration options; rather this is a quick "cheat sheet" for quickly getting a full feature web server up and running with the least effort.
You should have a fresh installation of Slackware Linux which has been fully updated. This how-to was defined using Slackware64 14.0, but the principles are the same for most recent versions. You can refer to the slackpkg how-to for help with updating your installation. You should be familiar with basic shell commands and navigation.
The first step is modifying the Apache web server configuration file. Open your shell and navigate to /etc/httpd and open httpd.conf with your favorite text editor. The two changes we must make to this file in order to get PHP working are to edit the DirectoryIndex and include the mod_php.conf. Before making any changes to your httpd.conf I highly recommend backing it up.
Find the section of httpd.conf that looks like this:
Append index.php after index.html, separated by a single space, so that it looks like this:
DirectoryIndex index.html index.php
Next, find the section that looks like this, and remove the # so that it is uncommented.
Now that the config file is (minimally) prepared, we can start the service. Navigate to /etc/rc.d, chmod rc.httpd to be executable, and fire it up.
chmod 755 rc.httpd
To test that the server is running, open a web browser and navigate to localhost. You should see an, "It Works!" page like the one in the screenshot to the right.
The final step in this section is to test that PHP is working. Once again, open your favorite text editor, and create a file in your root web directory (default /var/www/htdocs) called test.php. Add the following code to it.
Then open your browser again and navigate to localhost/test.php. The screenshot to the left shows what should be displayed in your browser window. If this is what you get, then your PHP module has successfully loaded, and it is time to move on to the MySQL setup.
The first step in getting the "M" in SLAMP running is to set the permissions on rc.mysqld so that it is executable. Then, we need to run mysql_install_db, which "initializes the MySQL data directory and creates the system tables that it contains, if they do not exist." You can read more about the mysql_install_db command at the MySQL reference pages.
chmod 755 rc.mysqld
We then make sure that the user mysql is the owner and group for mysql and start the service. Next, we log into mysqladmin and run the secure installation script. When executing the script, which hardens your MySQL installation, just follow the prompts.
chown -R mysql:mysql /var/lib/mysql
mysqladmin -u root password 'yourpasswordhere'
Once you have completed your mysql_secure_installation, you can log into MySQL using the password you established and do a "show databases;" to confirm that it is running. Last, restart the httpd service.
The barebones of a SLAMP server should now be up and running. I would highly encourage the reader to become familiar with httpd.conf and php.conf, so that you can intelligently configure your server based on your needs.
If you have any questions, concerns, suggestions, or constructive criticism, please email me.