Howto: Apache met Mysql & PHP
Piethein Strengholt

----------------------

Hier staat een korte uitleg van hoe je mysql, php en apache op je linux bak kunt gooien. Apache is een webserver en Mysql is een database-systeem. PHP is de taal waamee je je webpagina's aan de database kunt koppelen en bepaalde bewerkingen op je pagina kunt doen.

Installeren van MySQL:

log in als root ( 'su root' )

haal de laatste versie van mysql neer van http://www.mysql.org ( versie 3.23.52 )

Voer nu de volgende commando's uit:

Gebruik van de Source ( let op ! deze staat onderaan de download pagina ! )

Download de de source en pak hem uit met:

tar -zxvf mysql-3.23.52

./configure \
--prefix=/usr/local/mysql \ ( installeert zich in /usr/local/mysql )
--enable-assembler \
--with-innodb

make
make install

Starten van Mysql:

Nu moet er de de group en user mysql worden aangemaakt. Doe dit met:

groupadd mysql
useradd -g mysql mysql

cd /usr/local/mysql/bin
./mysql_install_db

Rechten geven met:

chown -R root /usr/local/mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql

kopieer de config file:

cp share/mysql/support-files/my-medium.cnf /etc/my.cnf

gevens van mysql toevoegen aan /etc/ld.so.conf:

echo /usr/local/mysql/lib/mysql >> /etc/ld.so.conf

in het bestand /usr/local/mysql/bin/safe_mysqld moet je de volgende regel aanpassen user=root -> user=mysql
om mysql vervolgens te starten geef je het volgende commando:

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

Om de nodig links te maken en de shared libaries te chachen moet je het volgende commando geven:

ldconfig

Als je mysql automatisch wilt laten starten moet je /usr/local/mysql/share/mysql/mysql.server naar /etc/init.d/ kopieren.
Verder raad ik je aan om het root wachtwoord te wijzigen.. dit doe je met het volgende commando. (voer dit uit vanuit de bin directory van mysql (cd /user/local/mysql/bin)

./mysqladmin -u root password ********

Nu voeren we een test uit of Mysql goed werkt

mysqlshow -p

#mysql -u root -p
Enter password:********
#mysql> show databases;

+ -------------------- +
| Database |
+ -------------------- +
| mysql |
| test |
+ -------------------- +
2 rows in set (0.00 sec)
mysql> create database test2;
Query OK, 1 row affected (0.00 sec)

Gefeliciteerd. Mysql werkt ! en tot zo ver het Mysql gedeelte.

Installeren van Apache met php-support webserver:

Haal de laatste versie neer van apache van http://www.apache.org ( versie 1.3.26 )

zorg ervoor dat de service httpd draait ( 'ntsysv' onder redhat of 'httpd' )

Voer nu de volgende commando's uit:

tar -zxvf apache_1.3.26.tar.gz

cd apache_1.3.26

./configure \
--prefix=/usr/local/apache \
--enable-module=so

make && make install

Installeren van PHP:

Haal de laatste versie neer van PHP van http://www.php.net ( versie 4.2.3 )

ga in de php directory staan ( cd php-4.2.3 ) en log in als root ( su root )

Voer nu de volgende commando's uit:

Haal de laatste versie van php en pak deze uit in de /usr/local dir

tar -zxvf php-*.tar.gz ( php uitpakken )

cd php-dir

./configure \
--with-mysql=/usr/local/mysql \
--with-xml \
--enable-track-vars \
--enable-ftp
\
--with-apxs=/usr/local/apache/bin/apxs

make && make install


Ga terug naar waar je php gecompiled hebt en kopieer het volgende:

cp php.ini-dist /usr/local/lib/php.ini


( De ini file kopieren naar de /lib dir - tip: dit invoegen in ini bestand "max_execution_time = 60;", zonder quotes )

In /usr/local/apache/conf/httpd.conf moet het volgende staan:
pico /usr/local/apache/conf/httpd.conf

LoadModule php4_module libexec/libphp4.so
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php .php3

cd /usr/local/apache/bin
./apachectl configtest
# Syntax OK
./apachectl start
./apachectl start: httpd started

eventueel kan je dit bestand downloaden om php te testen op je systeem

De homedir van apache staat standaard ingesteld op /usr/local/apache/htdocs. Verander deze in de httpd.conf


------------------------------- extra info --------------------------

/usr/local/mysql/bin/mysql_safe & ( mocht je mysql.sock opeens weg zijn dan kan je het zo fixen )

/usr/local/apache/bin ( directory executables van apache )
./apachectl start ( apache starten )
./apachectl stop ( apache stoppen )
ps x | grep httpd ( controleren of apache draait )
/usr/local/apache/conf/httpd.conf ( bestand editen )
/usr/local/apache/bin/apachectl start ( zo start je apache, met stop er achter stop je apache )
evtueel nog httpd ( als dat nog niet draait, httpd moet namelijk wel draaien )
./home/httpd/html/index.html ( hier staat de index, oftewel hier zet je alle bestanden van je homepage )

in config file -> listen 3000 bv. om apache op port 3000 te laten draaien