Installing LAMP


Installing Linux

I'm running Fedora Core 3. For the installation described in the kickstart file below, I only needed discs 1, 2, and 3.

Kickstart file

This is a kickstart file you can use to install FC3, or just use it as a guide while running the interactive installer. (Instructions for using the file directly are here, but I haven't tried doing that yet.) My original file is in the commented-out parts. I've changed some options slightly in the non-commented-out lines. Change the "network" line below. At least the IP address and hostname. Remove "--startxonboot" from the "xconfig" section.

[root@achilles ~]# cat anaconda-ks.cfg # Kickstart file automatically generated by anaconda. install cdrom lang en_US.UTF-8 langsupport --default=en_US.UTF-8 en_US.UTF-8 keyboard us xconfig --card "NVIDIA GeForce 4 MX (generic)" --videoram 65536 --hsync 31.5-37.9 --vsync 50-70 --resolution 800x600 --depth 16 --defaultdesktop kde #xconfig --card "NVIDIA GeForce 4 MX (generic)" --videoram 65536 --hsync 31.5-37.9 --vsync 50-70 --resolution 800x600 --depth 16 --startxonboot --defaultdesktop gnome network --device eth0 --bootproto static --ip 192.168.1. --netmask 255.255.255.0 --gateway 192.168.1.1 --nameserver 24.221.192.5,24.221.208.5 --hostname #network --device eth0 --bootproto static --ip 192.168.1.11 --netmask 255.255.255.0 --gateway 192.168.1.1 --nameserver 24.221.192.5,24.221.208.5 --hostname achilles rootpw --iscrypted $1$.58Ka3U2$cyWbET53wZOj82zGDnz60/ firewall --disabled selinux --enforcing authconfig --enableshadow --enablemd5 timezone America/Denver bootloader --location=mbr --append="rhgb quiet" # The following is the partition information you requested # Note that any partitions you deleted are not expressed # here so unless you clear all partitions first, this is # not guaranteed to work #clearpart --all #part /boot --fstype "ext3" --onpart hda1 #part swap --onpart hda2 #part / --fstype "ext3" --onpart hda3 clearpart --all part /boot --fstype "ext3" --size 100 part swap --recommended part / --fstype "ext3" --size 100 --grow # If partitioning fails for any reason, diagnostic messages will appear on # virtual console 3. #%packages %packages --resolvedeps @ editors @ text-internet @ gnome-desktop @ dialup @ base-x @ printing @ kde-desktop @ server-cfg @ admin-tools @ development-tools kernel e2fsprogs grub %post

After installation

Fix the RPM-GPG key thingy:

rpm --import /usr/share/rhn/RPM-GPG-KEY rpm --import /usr/share/rhn/RPM-GPG-KEY-fedora

Apache

Remove any previously-installed httpd and its dependencies.

rpm -q httpd rpm -q --whatrequires httpd

I had httpd-suexec and system-config-httpd that depended on httpd. But httpd also depended on httpd-suexec. To remove both at once

rpm -e httpd-suexec -e httpd

Download and unpack (tar xzf [filename]) httpd (I got the latest 2.0 version). Here's my conf-httpd file:

./configure \ --enable-so \ --enable-rewrite \ --enable-setenvif \ --enable-mime \ --enable-mime-magic \ --enable-dir \ --enable-auth \ --enable-access \ --enable-alias \ --enable-status \ --enable-userdir \ --enable-vhost-alias \ --enable-env \ --enable-log-referer \ --enable-log-config \ --enable-log-agent \ --enable-headers

Make the script executable:

chmod +x conf-httpd

Build and install

conf-httpd make make install

Link to apachectl from the system bin directories.

ln -s /usr/local/apache2/bin/apachectl /usr/bin/apachectl ln -s /usr/local/apache2/bin/apachectl /usr/sbin/apachectl

MySQL

If you have installed an older version of MySQL from source and want to remove it before installing the new version, go to the old version's source directory (where you built it) and execute the following commands, replacing the path in the third step with the path to your current MySQL install directory.

make -n uninstall make distclean rm -rf /usr/local/mysql

Download and unpack (tar xzf [filename]) the source. Go here for a different version of MySQL than 5.0.16. (I used 5.0.16.)

Update: 5.0.16 had a source packaging bug where the help tables were not populated. So, there was no help available from the client, which isn't terribly useful. So, I'd suggest getting version 5.0.17. (Actually, 5.0.17 had the same problem, so I don't know what to do about that.)

Here's my conf-mysql file:

CFLAGS="-03" CXX=gcc CXXFLAGS="-03 \ -mpentiumpro \ -mstack-align-double \ -felide-constructors \ -fno-exceptions \ -fno-rtti" ./configure \ --prefix=/usr/local/mysql \ --with-extra-charsets=complex \ --with-mysql-ldflag=-rdynamic \ --enable-thread-safe-client \ --enable-local-infile \ --enable-assembler

The option "--with-mysql-ldflag=-rdynamic" is described in the online docs for version 5.0, section 24.2.3. It allows UDFs in dynamic modules.

Make the script executable:

chmod +x conf-mysql

Check for previous installations:

rpm -qa | grep -i MySQL

Create mysql user:

groupadd mysql useradd -g mysql mysql

Build and install

conf-mysql make make install

Install the databases, and change the file permissions.

[src_dir]/scripts/mysql_install_db chown -R root /usr/local/mysql chown -R mysql /usr/local/mysql/var chgrp -R mysql /usr/local/mysql

Start the server

/usr/local/mysql/bin/mysqld_safe --user=mysql &

If it doesn't start, make sure there isn't another mysql process already running and using the server port. If there is, stop or kill the other process first.

Then, after starting the server, change the root password:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password' /usr/local/mysql/bin/mysqladmin -u root -h [hostname] password 'new-password'

If the second version doesn't work, include the "-p" argument, and it will ask for your password. Use the password from the first step. (To include special characters in the password, enclose it in single quotes.)

Config files:

/etc/my.cnf

[client] port=3306 socket=/tmp/mysql.sock [mysqld] port=3306 socket=/tmp/mysql.sock key_buffer_size=16M max_allowed_packet=1M [mysqldump] quick

~/.my.cnf

[client] user="[username]" password="[password]" [mysql] no-auto-rehash set-variable = connect_timeout=2 [mysqlhotcopy] interactive-timeout

Copy the start script to the /etc directory

cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d chkconfig --add mysql.server

Also, update ~/.bash_profile to include /usr/local/mysql/bin in PATH. Then source it.

cd vi .bash_profile . .bash_profile

If you want to copy data from an old MySQL installation to this new one, you can find instructions here.


php

These packages are required for using GD from PHP.

yum install libpng-devel yum install zlib-devel yum install libjpeg-devel

After installing the packages, make sure they're installed. If not, try installing again.

rpm -q libpng-devel rpm -q zlib-devel rpm -q libjpeg-devel

Download and unpack (tar xzf [filename]) archive. I got 5.1.1.

Here's my conf-php file:

./configure \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-mysql=/usr/local/mysql \ --with-mysqli=/usr/local/mysql/bin/mysql_config \ --with-gd \ --with-jpeg-dir=/usr/lib \ --with-zlib-dir=/usr/local/lib \ --with-png-dir=/usr/local/lib

Make the script executable:

chmod +x conf-php

Build and install.

conf-php make make install cp php.ini-dist /usr/local/lib/php.ini

In /usr/local/apache2/conf/httpd.conf, at the very end, add

AddType application/x-httpd-php .php .php3

Find the DirectoryIndex line and add index.php (if you want that file served by default):

DirectoryIndex index.html index.html.var index.php

Also, I change my DocumentRoot: (comment out the old one)

DocumentRoot "/var/www/html"

Restart apache:

apachectl restart