To set up/Install PHP, MySQL, Apache, Mod_SSL on a FreeBSD box.
1. Install Mysql
# cd /usr/ports/databases/mysql323-server/
or
# cd /usr/ports/databases/mysql40-server
# make install
Optional:
# cd /usr/ports/databases/mysql323-client/
# make install
2. Configure MySQL and launch it (still working on this part for docs).
If you wish to limit MySQL to localhost connections, copy /usr/local/share/mysql/my-large.cnf to /etc/my.cnf then edit /etc/my.cnf and add the following line under [mysqld]:
bind-address = 127.0.0.1
Start My SQL:
# cd /usr/local ; /usr/local/bin/safe_mysqld & [for 3.2.3]
or
Add the following lines to /etc/rc.conf [for 4.0]
# MYSQL
mysql_enable=YES
mysql_limits=YES
mysql_dbdir=/var/db/mysql
# /usr/local/etc/rc.d/mysql-server.sh start
Set Root Password for MySQL:
# /usr/local/bin/mysqladmin -u root password <new-password>
# /usr/local/bin/mysqladmin -u root -h localhost password <new-password>
Add the following if you plan to allow external connections
# /usr/local/bin/mysqladmin -u root -h <hostname> password <new-password>
Notes:
To stop sql (You will be prompted for a password):
# /usr/local/bin/mysqladmin -u root -h zone -p shutdown
To create a database (You will be prompted for a password):
# /usr/local/bin/mysqladmin -u root -p create <database name>
To create a user for a database (You will be prompted for a password):
# /usr/local/bin/mysqlaccess -u <username> -p <password> -d <database> -U root -P <Root's MySql Password>
To check rights to a database:
# /usr/local/bin/mysqlaccess <user> <database> -U root -P <Root's MySql Password>
3. Download source code and extract
# cd /usr/local/src
# fetch http://apache.cs.utah.edu/httpd/httpd-2.2.3.tar.gz
# fetch http://www.openssl.org/source/openssl-0.9.8b.tar.gz
# fetch http://us2.php.net/get/php-4.4.4.tar.gz/from/us3.php.net/mirror
# fetch ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
# fetch http://prdownloads.sourceforge.net/mhash/mhash-0.9.2.tar.gz
# fetch ftp://ftp.gnu.org/gnu/aspell/aspell-0.60.2.tar.gz
# fetch http://curl.haxx.se/download/curl-7.15.1.tar.gz
# fetch http://superb.dl.sourceforge.net/sourceforge/pcre/pcre-6.3.tar.gz
# mv mirror php-4.4.4.tar.gz
# gzip -d -c httpd-2.0.55.tar.gz | tar xvf -
# gzip -d -c openssl-0.9.8b.tar.gz | tar xvf -
# gzip -d -c php-4.4.4.tar.gz | tar xvf -
# gzip -d -c libmcrypt-2.5.7.tar.gz | tar xvf -
# gzip -d -c mhash-0.9.2.tar.gz | tar xvf -
# gzip -d -c aspell-0.60.2.tar.gz | tar xvf -
# gzip -d -c curl-7.15.1.tar.gz | tar xvf -
# gzip -d -c pcre-6.3.tar.gz | tar xvf -
4. Make OpenSSL
# cd /usr/local/src/openssl-0.9.8b
# ./config
# make
# make test
5. Compile/Configure Apache
# cd /usr/local/src/httpd-2.2.3
# ./configure \
--prefix=/usr/local/apache2 \
--enable-so \
--enable-cgi \
--enable-info \
--enable-rewrite \
--enable-speling \
--enable-usertrack \
--enable-deflate \
--enable-ssl \
--enable-mime-magic \
--with-ssl=../openssl-0.9.8b/lib/ \
--enable-auth-digest
# make
Continue with install
# make install
6. Install LIBMCRYPT
# cd /usr/local/src/libmcrypt-2.5.7
# ./configure
# make
# make install
7. Install LIBMHASH
# cd /usr/local/src/mhash-0.9.2
# ./configure
# make
# make install
8. Install Aspell
# cd /usr/local/src/aspell-0.60.2
# ./configure
# make
# make install
If this fails, install the port:
# cd /usr/ports/textproc/aspell
# make
# make install
9. Install PCRE
# cd /usr/local/src/pcre-6.3
# ./configure
# make
# make install
10. Install cURL
# cd /usr/local/src/curl-7.15.1
# ./configure
# make
# make install
11. Compile Mod_PHP
Note: You'll want to add/remove any additional options to your php configure command before continuing. In this case, I had already added the necessary libraries for zlib, jpeg, and gd before running the configure command below.
# cd /usr/local/src/php-4.4.2/
# ./configure \
--prefix=/usr/local\
--enable-module=so\
--with-mcrypt\
--with-mhash\
--with-pspell\
--with-mysql\
--with-pcre-regex\
--with-openssl\
--with-curl\
--with-zlib\
--with-jpeg-dir=/usr/local/lib\
--with-gd\
--disable-posix-threads\
--with-apxs2=/usr/local/apache2/bin/apxs
# make
# make install
12. Configure PHP in Apache
# vi /usr/local/apache/conf/httpd.conf
Add/verify the following line under the LoadModule section:
LoadModule php4_module libexec/libphp4.so
or
AddModule mod_php4.c
Add/verify the following line under the AddType section:
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
Find the following line:
DirectoryIndex index.html
And change it to:
DirectoryIndex index.html index.htm index.php