Mandrake 10.1 - MySQL + Apache 2 + PHP 4 Howto
Author: Stephen Khoo
Updated: 11 March 2005
MySQL
MySQL should be installed from RPMs. We initially had problems getting hold of the development libraries as you only get CDs 1-3 on the non-club membership of Marndrake and I think the development libraries and related files are on CD4 which you get with a silver or above membership of Mandrakesoft. When we originally tried to download libmysql12-devel from the mirror sites we got all kinds of nasty dependency messages about zlib libraries missing. So in short, when you install Mandrake 10.1, opt for installing all 4 distribution CDs.
You can check what is installed using:
|
rpm -qa | grep -i mysql | sort
|
Here is the set we installed using drakconf and the list we get from the above command:
|
libmysql12-4.0.20-3.2.101mdk
libmysql14-4.1.5-0.1mdk
libmysql14-devel-4.1.5-0.1mdk
MySQL41-client-4.1.5-0.1mdk
MySQL41-common-4.1.5-0.1mdk
MySQL41-Max-4.1.5-0.1mdk
perl-Mysql-1.22_19-9mdk
php-mysql-4.3.8-1mdk
|
Here we are using the max version of MySQL. We use a configuration file based on the huge version supplied: my.cnf.
|
/etc/rc.d/init.d/mysql-max start
#set root password on the MySQL server
mysqladmin -uroot password 'new-password'
#if using MySQL 4.1 you have to use old style passwords or else you won't be able to log in:
mysqladmin -uroot old-password 'new-password'
|
Note that in MySQL 4.1 you have to set compatibility for PHP4 with old-style passwords. Add the line 'old_passwords' to your /etc/my.cnf file.
Ok.. MySQL installed and running. (You can check with ps -A | grep mysql).
Now you can enter MySQL, and create the users and databases using :
|
mysql -u root -p
# type 'exit;' to leave...
|
Ok great, we have MySQL running!
Apache 2
Apache is a great web server for simple appliances. I'm using version 2 of this web server which is now deemed to be safe and stable. Here is the set of files we installed using drakconf:
|
rpm -qa | grep -i apache | sort
|
|
apache2-2.0.50-7.2.101mdk
apache2-common-2.0.50-7.2.101mdk
apache2-manual-2.0.50-7.2.101mdk
apache2-mod_auth_mysql-2.0.50_1.11-3mdk
apache2-mod_cache-2.0.50-7.2.101mdk
apache2-mod_dav-2.0.50-7.2.101mdk
apache2-mod_deflate-2.0.50-7.2.101mdk
apache2-mod_disk_cache-2.0.50-7.2.101mdk
apache2-mod_file_cache-2.0.50-7.2.101mdk
apache2-mod_mem_cache-2.0.50-7.2.101mdk
apache2-mod_perl-2.0.50_1.99_16-1mdk
apache2-mod_php-2.0.50_4.3.8-2mdk
apache2-mod_proxy-2.0.50-7.2.101mdk
apache2-mod_ssl-2.0.50-4.1.101mdk
apache2-mod_suexec-2.0.50-3mdk
apache2-modules-2.0.50-7.2.101mdk
apache-conf-2.0.50-4mdk
|
Apache installed, now for
PHP4
To install PHP4 you will need to uninstall all php4 rpms first. Otherwise the rpm dependencies will complain about things. Here is the set of PHP files we installed using
drakconf:
Note: we have tried using PHP5, but unfortunately found that to be too much at the bleeding edge! We found that some of the other RPMs we will be installing assume PHP4 and so it is simply too much grief at this time to use PHP5. Unless there is really a compelling reason to use it, we suggest sticking with PHP4 for now.
|
rpm -qa | grep -i php | sort
|
|
apache2-mod_php-2.0.50_4.3.8-2mdk
libc-client-php0-2004-2.3.101mdk
libphp_common432-4.3.8-3.2.101mdk
php-calendar-4.3.8-1mdk
php-cgi-4.3.8-3.2.101mdk
php-cli-4.3.8-3.2.101mdk
php-curl-4.3.8-1mdk
php-gd-4.3.8-2mdk
php-imagick-4.3.8_0.9.11-2mdk
php-imap-4.3.8-1mdk
php-ini-4.3.8-1mdk
php-mailparse-4.3.8_2.0b-1mdk
php-mbstring-4.3.8-1mdk
php-mcrypt-4.3.8-1mdk
php-mmcache-4.3.8_2.4.7-0.20040822.1mdk
php-mmcache-admin-4.3.8_2.4.7-0.20040822.1mdk
phpMyAdmin-2.6.0-1mdk
php-mysql-4.3.8-1mdk
php-pear-4.3.8-1mdk
php-pear-Date-1.4-4mdk
php-pspell-4.3.8-1mdk
php-readline-4.3.8-1mdk
phpSysInfo-2.3-1mdk
php-xml-4.3.8-1mdk
php-xmlrpc-4.3.8-1mdk
php-zip-4.3.8-1mdk
|
Note that you shouldn't need to add lines for loading the module or adding types as these are in /etc/httpd/conf.d in the XX_mod_php.conf file.
You should now check, after restarting, Apache and MySQL that all are running fine using ps -A.
Configuring Apache for Virtual Hosting
We use Apache's rewrite module with a virtual hosting map file 'vhost.map' to provide virtual hosting of multiple domains using a single log file. We split the log file using the supplied utilities on a weekly basis and then use Webalizer to process the weblogs on a domain basis.
The Apache configuration in Mandrake is split over several files in /etc/httpd - specifically the 'conf' subdirectory. You only really need to modify:
- commonhttpd.conf
- httpd2.conf
- vhosts/Vhosts.conf
- vhosts/vhost.map
commonhttpd.conf
Locate the lines and make these changes:
|
UseCanonicalName Off
#add a combined log format
LogFormat "%{Host}i %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vcombined
# Important entry to ensure IE on PC caches images and pages
BrowserMatch MSIE force-no-vary
# and if you want to serve sites from /home allowing users to use their own access files etc. add:
<Directory /home>
Options -Indexes FollowSymLinks
AllowOverride All
<IfModule mod_access.c>
Allow from all
</IfModule>
</Directory>
|
httpd.conf
Locate the lines and make these changes:
|
# we don't want automatic user directories (all users are virtual on FTP anywa) - so we turn off:
usertrack_module, autoindex_module, userdir_module
# we don't like directory listing either...
|
Vhosts.conf
We use mod_rewrite to provide virtual hosting, so we also have this at the end of Vhosts.conf:
|
# enable the rewriting engine in the main server
<VirtualHost ..yourvirtualhost_ip..>
RewriteEngine on
RewriteCond %{THE_REQUEST} _vti_bin [NC,OR]
RewriteCond %{THE_REQUEST} MSOffice [NC]
RewriteRule ^/(.*)$ blankpage.htm [L]
RewriteMap lowercase int:tolower
RewriteMap vhost txt:/etc/httpd/conf/vhosts/vhost.map
# do not rewrite cgi-bin - leave for ScriptAlias
RewriteCond %{REQUEST_URI} !^/cgi-bin/.*
RewriteCond %{REQUEST_URI} !^/hterror_docs/.*
RewriteCond %{HTTP_HOST} !^$
RewriteCond ${lowercase:%{HTTP_HOST}|NONE} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1 [E=VHOST:${lowercase:%{HTTP_HOST}}]
</VirtualHost>
|
Where vhost.map is a file containing pairs of domains and folders to serve from. e.g.
|
##
## vhost.map
##
www.businesswebpages.biz /home/www/ipages.biz/html
... and so on
|
Restart apache and hopefully all should be well.
/etc/rc.d/init.d/httpd restart
|