|
Slackware Linux Installation:
Installing Slackware is not very hard. Most semi-current systems will allow you to boot from the installation CD, rather than having to use "rawrite" to make a boot disk and root disk, like in the old days. If you cannot boot from your CD try hitting the escape key when your system boots and get into your PC's BIOS setup. You should be able to chose the boot order in there, choose CD first. The default is probably the a: floppy drive.
After you fdisk the drive, which I normally make just a 64MB or 128MB swap partition and a main partition with the rest, you should install everything from the CD unless you're more knowledgable about Linux and want to taper it down a bit for security reasons. Since there is already lots of online help on the basic Linux system install we'll skip it here.
MySQL/PHP/Apache Installation:
Shutting Down The Current Web Server
You'll want to shut down the currently installed web server before continuing on with the installation proccess.
You should be able to run the following command to properly shut down the web server and all of it's processes that might be running:
apachectl stop
To catch any processes that might not have been shut down you can run this command, which will display the <pid>'s to the left:
ps -axf | grep httpd
If there are any httpd processes still running you can kill their 's with this command:
kill -9 <pid>
Fetching The Source Code And Packages We'll Need
Note: These download URLs are no longer valid. I left them in just because I didn't want to alter the document, it's just a static archive page and is no longer updated. If you decide to follow this tutorial (for the most part it should still be useful) you should use the main site links for each of the products at the top of this document and download the latest versions of each software package..
If you copy and paste the following "wget" commands you will get a "file not found" error..
We will be placing all of the packages into the /usr/src directory. Get in there with this command:
cd /usr/src
Now we'll need to fetch the packages we'll need. We'll start by using the wget to get the Apache web server source code. Type this command at the prompt to do so:
wget http://www.rocketry.org/~tim/downloads/apache_1.3.20.tar.gz
(or you can download it from the official Apache web server site)
Then you will repeat this process to get the PHP4 source code too by entering this command:
wget http://www.rocketry.org/~tim/downloads/php-4.0.6.tar.gz
(or you can download it from the official PHP.net download site)
Uncompressing the source .tar.gz files
Now we need to uncompress and un-tar the files that we just downloaded into /usr/src using these commands, one at a time, will uncompress the files and you will see lots of stuff scroll up your screen. This is normal. Execute these two commands:
tar -zxvf apache_1.3.20.tar.gz
tar -zxvf php-4.0.6.tar.gz
To make life easier we will make symbolic links to these directories with names that are easier to remember. We'll call them 'apache' and 'php'. Use these commands, one at a time, to create the links:
ln -s /usr/src/apache_1.3.20 apache
ln -s /usr/src/php-4.0.6 php
I usually clean up and remove any unnecessary files, so now that the files have been expanded into their own subdirectories issue this command to remove the gzipped tarball files:
rm *.gz
Now we will change directories again to where we will be installing MySQL. Use this command:
cd /usr/local
We will fetch the MySQL binary package the same way we did with Apache and PHP using wget. Do so with this command:
wget http://www.rocketry.org/~tim/downloads/mysql-3.23.43-pc-linux-gnu-i686.tar.gz
(or you can download it from the official MySQL download site)
Installing the MySQL binaries
Now we will need to uncompress and un-tar the MySQL archive we just downloaded. The following command will uncompress the files into their own directory and you will see lots of stuff scroll up your screen. This is normal.
tar -zxvf mysql-3.23.43-pc-linux-gnu-i686.tar.gz
While we are at it, let's make a symbolic link to this new directory with a friendlier name, we'll call it 'mysql':
ln -s /usr/local/mysql-3.23.43-pc-linux-gnu-i686 mysql
Next we will need to set the ownership and change the group of the newly created MySQL directories. We will give ownership to the user 'mysql' you created earlier and change the group to 'root'.
If you haven't already created a user called 'mysql' on your system, create one now and give it a password with the following command:
adduser mysql
Once you have a mysql user, proceed with assigning the ownership and group:
chown -R mysql:users mysql-3.23.43-pc-linux-gnu-i686
Now we will need to become the user 'mysql' for a bit. Change to that user with this command:
su mysql
You will notice that your prompt has changed from a # to a $ sign. Then get into the new mysql directory with this command:
cd mysql
We will execute the script that sets up MySQL for the first time now like this:
scripts/mysql_install_db
We no longer need to be the mysql user anymore. Return to the root user by exiting.
exit
We are going to start the MySQL server up now. First we will need to make the script that does this executable, using the first command. Then we will actually start up MySQL with the second command:
chmod 755 /usr/local/mysql/support-files/mysql.server
/usr/local/mysql/support-files/mysql.server start
You will want to set a password for MySQL now. Do this by typing the following and substituting whatever password you want where you see <password>:
/usr/local/mysql/bin/mysqladmin -u root password <password>
MySQL should now be installed and running! We will now get into MySQL and set up a test database, a table in that test database, and throw in a record too. YAY. To begin, type the following command and it should prompt you for a password as shown:
/usr/local/mysql/bin/mysql -u root -p
~# Enter password:
You should now be in the MySQL database and see the following prompt:
mysql>
Creating a test MySQL database
Type the following command to create a database called "test_database", then the second command to get into and use the new database. Always use the ; semi-colon after any SQL statements.
CREATE DATABASE test_db;
USE test_db;
Now we will create a table called "test_table", and create some room for data:
CREATE TABLE test_table (
first_name varchar(30),
last_name varchar(30),
phone_number varchar(12));
Now we'll want to throw some data, a record, into our new table within our new database.
INSERT INTO test_table VALUES ("John", "Doe", "602-555-1212");
You can use the SQL "SELECT" statement to locate and see data from within a table. The * (asterisk) is a "wild card" that will pull out all of the data. Try this:
SELECT * FROM test_table;
You should now see the record you just entered show up. Cool, eh? We're done with MySQL for now. You can get out of it by exiting now.
exit
Now on to setting up PHP and the Apache web server. We will return to our source directory like this:
cd /usr/src
Starting the Apache web server configuration
Get into the Apache directory first:
cd apache
We will run the configuration script and specify an install directory with the "--prefix" command because PHP will need to know the location of the Apache config files to compile correctly and work with Apache later on. I chose to install it in /usr/local/apache out of habit. To make this tutorial easier, install yours there too.
./configure --prefix=/usr/local/apache
Configuring and Installing PHP4
Once the Apache configuration script has run we will change to the PHP directory like this:
cd ../php
You are now in the PHP directory. First run the configuration script using the following command. The \ character allows you to hit return but still enter more data without starting the script yet.
./configure --with-mysql=/usr/local/mysql \
--with-apache=/usr/src/apache \
--enable-track-vars \
--with-pdflib=no \
--with-zlib
If all went well with the configuration, hopefully it did, you need to start compiling. We do this with these commands, run one at a time. This may take some time depending on the speed of your machine. On my older AMD K6-2 400mhz with 128mb of RAM it was fairly quick and painless.
make
make install
Finishing the Apache web server configuration and installation
If there were no compiler errors PHP should be done and we will move on to configuring and building the Apache web server. Change directories into Apache to begin:
cd ../apache
We need to first run the configuration script. We are also configuring Apache to load PHP as a loadable module. There are cool reasons for this that we won't get into now though.
./configure --prefix=/usr/local/apache \
--activate-module=src/modules/php4/libphp4.module
As with PHP we will now need to compile and make the Apache web server. Use these commands, one at a time:
make
make install
Possible Error: If the 'make' sequence above failed and gave you an error (which it probably did), that is normal. For some unknown reason the Makefiles that apache creates calls "libphp4.a" instead of "libphp4.module" like they should be doing.. You'll be glad to know this can be fixed though with the following:
If you get into the '/usr/src/apache' directory and run this command:
grep -r libphp4.a *
..you will notice that the erroneous file "libphp4.a" (instead of the required and expected "libphp4.module") shows up probably 5 times. It will show up in these files:
src/modules/php4/Makefile.tmpl
src/modules/php4/Makefile
src/Makefile
If you simply edit those files and replace the instances of 'libphp4.a' with the correct 'libphp4.module' you will fix the problem. You can open the files in the Pico editor (pico -w ), or you can use the search/replace function in the vi editor.
If you encountered the above error, and fixed the files noted above, you need only re-run the following commands to proceed:
make
make install
Hopefully Apache compiled with no problems. If so, we need to copy a PHP file with this command:
cd ../php
cp php.ini-dist /usr/local/lib/php/php.ini
You will probably also want to change the init script that runs when your server boots or reboots to start up this new version of Apache, instead of the one that installed with the OS. Do this to get into the init script directory:
cd /etc/rc.d
Once you're in there run this command to open the web server start shell script:
pico -w rc.httpd
Where it shows the old location of the 'apachectl', change them to "/usr/local/apache/bin/apachectl" (without quotes of course) and you should be good to go.
Configuring the httpd.conf file to use .php pages
Next we will make a couple of minor adjustments to the Apache configuration file so that it knows to send any web pages with a .php extension to be processed by PHP. Change directories with the first command and get into httpd.conf with the editor of your choice, I used the 'pico' editor for simplicity but you could always use 'vi' or 'emacs' too. Note: The -w switch used below keeps the lines from wrapping when editing the file.
cd /usr/local/apache/conf
pico -w httpd.conf
Now that you are in the httpd.conf file you will want to uncomment the following lines by removing the # (pound sign) from the front of them. You can initiate a search in 'pico' by hitting '<ctrl> w' to easily find where these lines are located in the file:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
You will probably want to also add 'index.php' to the list of Index files on this line like so:
DirectoryIndex index.html index.php
Once you've done that hit '<ctrl> x' to save the httpd.conf file. We then want to start up Apache! Use this command to do so:
/usr/local/apache/bin/apachectl start
Note: You'll probably also want to change the Apache start line in the startup script in /etc/rc.d/rc.httpd to reflect the new location of Apache so that the next time you reboot your machine the correct Apache will start up. |