|
SlackServer (or how to setup a slackware linux web server)
By Okibi
This guide will show you the fastest way to setup SlackServer. SlackServer is what I refer to as SLAMP (Slackware Linux, Apache, MySQL, PHP). If you follow this guide, you should have SlackServer up in 15 minutes. All you need done prior to this is install Slackware and have it connected to the web. Let's get started.
NOTE: Bold represents commands you have to enter, Italic represents a part of the code you need to change to suit the situation, and Underline represents the package we are working on and is not a command. We'll also be running these commands as root unless specified otherwise.
MySQL
First we want to setup MySQL, so get the slackware package from linuxpackages.net:
wget linktomysqlpackage
Now we need to install the MySQL package:
installpkg mysql-x.x.xx.tgz
Next we'll add the group called mysql for the daemon to run in:
groupadd mysql
Now let's add the user mysql to that group so he can run the daemon:
useradd -g mysql mysql
Now let's give the user access to mysql:
chown -R mysql.mysql /var/lib/mysql
We want to be the user mysql for this next step, so run this command:
su - mysql
Now we'll install the test database:
mysql_install_db
We need to go back to being root:
exit
Next we copy the my.cnf file to /etc:
cp /etc/my-medium.cnf /etc/my.cnf
Time to give execution rights to mysqld:
chmod +x /etc/rc.d/rc.mysqld
We want to be the user mysql to start mysql, so run this command again:
su - mysql
Now let's start it up:
/etc/rc.d/rc.mysqld start
MySQL should say it's running, so let's go back to being root:
exit
Next we set the root password for MySQL: (Keep in mind we never use the server's root password for this)
/usr/bin/mysqladmin -u root password 'new-password'
Now we open the MySQL terminal: (it'll ask you to enter the root password so do so)
mysql -u root -p
We are in the MySQL terminal, so let's give anonymous users a password:
UPDATE user SET Password = PASSWORD('new_password') WHERE User = '';
After changing a setting, we need to flush the privileges:
FLUSH PRIVILEGES;
Before we leave the terminal, let's setup a user to access the test database:
GRANT all on test.* to userid@localhost IDENTIFIED by 'password';
Leave the MySQL terminal:
quit
Let's open the terminal again as the user we just created: (it'll ask you to enter the user's password so do so)
mysql -u user -p
We want to tell MySQL to open the test database:
use test;
Now we verify that the database opened by showing the tables:
show tables;
Since we know it opened and was empty, let's leave the terminal again:
quit
MySQL is now up and running, so let's move on to Apache.
Apache
Next we want to setup Apache, so get the slackware package from linuxpackages.net:
wget linktoapachepackage
Now we need to install the Apache package:
installpkg apache2-x.x.xx.tgz
That's all for now, we'll come back and edit the config file later.
PHP
Now we want to setup PHP, so get the slackware package from linuxpackages.net:
wget linktophppackage
Now we need to install the PHP package:
installpkg php-apache2-x.x.x.tgz
We need t1lib, so let's get that next from linuxpackages.net:
wget linktot1libpackage
Next we'll install t1lib:
installpkg t1lib-x.x.x.tgz
Next we want to make sure the Apache config file includes the mod_php config file:
pico /etc/apache2/httpd.conf - search for the line "Include /etc/apache2/mod_php.conf". If it has a # in front of it, remove the #. If you don't see this line, add it with the other Includes. (you don't need the quotes)
(press ctrl+o to save the file, and then ctrl+x to close it)
Now we need to open that mod_php config file and edit it:
pico /etc/apache2/mod_php.conf - make sure this file contains the line "LoadModule php5_module lib/apache2/libphp5.so". If it doesn't add it. (you don't need the quotes)
(press ctrl+o to save the file, and then ctrl+x to close it)
We need to setup PHP's configurations file now, so move to the htdocs directory:
cd /var/www/htdocs
Create the new PHP configurations file:
pico config.php - add the line " phpinfo(); ?>" to this file. No quotes.
(press ctrl+o to save the file, and then ctrl+x to close it)
Now let's edit the php.ini file to include support for MySQL:
pico /etc/apache2/php.ini - search for the line "extension=mysql.so". If it has a ; in front of it, remove the ; (no quotes on the line).
Next we can start Apache:
apachectl start
Now we need to test Apache, MySQL, and PHP, so open a web browser on the server and go to the following url:
http://localhost/config.php
You should see a list of all the PHP configurations including MySQL.
Finishing Up
That's it! SlackServer is now up and running! The home directory for your web files should be /var/www/htdocs. You'll need to copy all your files over there for viewing. Now anyone who accesses our public IP address should see our site. In the next guide titled "SlackServer Plus", we'll cover settting up Apache VHosts, DNS, POP3, SMTP, Disk Space and Bandwidth Limiting, and more! Thanks for reading and good luck with your site!
|