====== MySQL, Apache+PHP static howto ======
===== Download Sources =====
download [[http://httpd.apache.org/download.cgi|apache]], [[http://www.php.net/downloads.php|php]], [[http://dev.mysql.com/downloads/|mysql]] and [[http://www.modssl.org/source/|mod_ssl]] to /usr/local/src directory.
tar zxf apache_1.3.41.tar.bz2
tar jxf php-4.4.9.tar.bz2
tar zxf mysql-5.0.67.tar.gz
tar zxf mod_ssl-2.8.31-1.3.41.tar.gz
mv apache_1.3.41 apache-1.3.41
**Last step is important!** if you skip it you'll have to adjust all commands that comtain apache directory.
===== Start with mysql (php needs mysql) =====
cd /usr/local/src/mysql-4.1.21
./configure --prefix=/usr/local/mysql --without-debug \
--localstatedir=/home/mysql/data \
--with-unix-socket-path=/tmp/mysql.sock \
--with-mysqld-user=mysql \
--without-docs \
--without-debug \
--without-bench \
--with-charset=utf8 \
--with-extra-charsets=cp1251,latin1,utf8 \
--with-isam \
--with-innodb \
--enable-thread-safe-client \
--enable-assembler \
--with-archive-storage-engine \
--with-federated-storage-engine \
--with-berkeley-db
make
make install
groupadd mysql
useradd mysql -g mysql
cd /usr/local/mysql
chown root . -R
chgrp mysql . -R
chown mysql ./data -R
./bin/mysql_install_db
echo 'delete from mysql.user where user="" '|mysql
./bin/mysqladmin -u root password 'new-password'
You may want to change **--with-unix-socket-path** to **/var/lib/mysql/mysql.sock** or **/var/run/mysql.sock** - default location for mysql socket for some systems.
Choose a charset with **--with-charset=**. Good choise is utf8.
One more thing to finish mysql installation. copy **/usr/local/mysql/share/mysql/mysql.server** script to right place in your system.
For redhat/fedora:
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chkconfig --level 345 mysqld on
service mysqld start
For Slackware:
cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/rc.mysqld
/etc/rc.d/rc.mysqld start
===== Install PHP =====
To proceed with php you need to run configure on apache:
cd /usr/local/src/apache-1.3.41
./configure --prefix=/usr/local/apache
Then compile and install PHP:
cd /usr/local/src/php-4.4.4
./configure --with-apache=../apache-1.3.37/ \
--with-mysql=/usr/local/mysql \
--with-mysql-sock=/tmp/mysql.sock \
--disable-all \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php \
--enable-magic-quotes \
--with-gd=/usr \
--with-freetype-dir \
--with-ttf \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-zlib \
--enable-session \
--enable-sockets \
--with-pcre-regex \
--with-pear=/usr/local/php/lib/pear \
--enable-mbstring \
--disable-mbregex \
--enable-zend-multibyte \
--with-iconv \
--with-curl \
--with-ncurses \
--enable-xml
make
make install
__**Notes on PHP:**__
**-with-ncurses** is optional and most of the time is not required. Also you must have include files for ncurses (devel package). You can safely skip this.
**--enable-mbstring** and **--with-iconv** are needed to convert between character encodings. If you plan to use only one encoding you can skip it. However soon or later you may need them. Also some open source PHP products uses them. mbstring functions start with mb_ and iconv start with iconv_. See php documentation for more information.
**--with-ttf** and **--enable-gd-native-ttf** require freetype library.
===== Install MODSSL =====
You need to configure ssl before you compile apache:
cd /usr/local/src/mod_ssl-2.8.28-1.3.37
./configure --with-apache=../apache-1.3.37 \
--prefix=/usr/local/apache
===== Compile and install apache =====
cd /usr/local/src/apache-1.3.37
./configure --prefix=/usr/local/apache \
--activate-module=src/modules/php4/libphp4.a \
--enable-module=rewrite --enable-shared=rewrite \
--enable-module=proxy --enable-shared=proxy \
--enable-module=auth_digest --enable-shared=auth_digest \
--enable-module=proxy --enable-shared=proxy \
--enable-module=usertrack --enable-shared=usertrack \
--enable-module=asis --enable-shared=asis \
--enable-module=cgi --enable-shared=cgi \
--enable-module=log_agent --enable-shared=log_agent \
--enable-module=log_referer --enable-shared=log_referer \
--enable-module=unique_id --enable-shared=unique_id \
--enable-module=usertrack --enable-shared=usertrack \
--enable-module=userdir --enable-shared=userdir \
--enable-module=setenvif --enable-shared=setenvif \
--enable-module=vhost_alias --disable-shared=vhost_alias \
--enable-module=so --disable-shared=so \
--enable-module=info --disable-shared=info \
--enable-module=ssl --disable-shared=ssl \
--enable-module=status --disable-shared=status
make
make certificate
make install
groupadd apache
useradd apache -g apache
__**Notes on Apache**__
**--enable-shared** and **--disable-shared** specify if module will be built as shared(first) or it'll be included into apache executable. If you use specific module frequently it is recommended to build it as static module (vhost_alias for example).
**proxy** module is dangerous. If you don't know how to use it I recommend you to turn it off into your httpd.conf
Edit your httpd.conf located in /usr/local/apache/conf directory. Find user and group tags and set user and group to apache:
User apache
Group apache
Other tags you need to change are:
ServerAdmin email@server.com
ServerName www.example.com
# changing document rood directory is not a must, but I use more friendly dir:
DocumentRoot "/webroot"
# or alternatively you can put link to apache's docs directory:
# ln -s /usr/local/apache/htdocs /webroot
Find this in apache config file:
DirectoryIndex index.html index.php
And replace DirectoryIndex directive with:
DirectoryIndex index.php index.html index.htm
This will allow you to use .php index file as well as .html
Find "" in httpd.conf file and locate AddType entries like:
AddType application/x-tar .tgz
Put this above it in order php to work:
AddType application/x-httpd-php .php .php3
AddType application/x-httpd-php-source .phps
===== Needed libraries that are not installed by default on some systems =====
* libjpeg-devel-xxx
* libpng-devel-xxx
* freetype-devel-xxx
* gd-devel-xxx
(where xxx represents package version)
These packages are contain mostly include files. It is possible linux distribution you are using to contain source files instead includes. In this case packages may be called - package-source-xxx or package-xxx.src.tar.gz
if you do not have them you can you can skip corresponding options (mostly in php configuration):
--with-freetype-dir \
--with-ttf \
--with-ncurses \
...