How to install FreeBSD 8 for WordPress. It’s a basic LAMP install but since we’re not using linux it should be called BAMP or maybe FAMP? Who cares.. here are the steps to install FreeBSD 8 with apache, mySQL, PHP then install wordpress.
I’ll be using ports of course for this entire install. I’m assuming that you have the proper hardware for this type installation.
Start with a minimal installation of freeBSD 8
Bypass the headache and host on VPS or dedicated servers with Pre-Installed LAMP.
Update the server ports – freebsd guide on ports
First update your port tree
[bash]portsnap fetch update *if this is the first time do a portsnap fetch extract[/bash]
List available update
[bash]pkg_version -vIL=[/bash]
Once you have updated your Ports Collection, before attempting a port upgrade, you should check /usr/ports/UPDATING. This file describes various issues and additional steps users may encounter and need to perform when updating a port, including such things as file format changes, changes in locations of configuration files, or other such incompatibilities with previous versions.
Upgrade your ports with
[bash]portupgrade -rR[/bash]
Okay now that your freeBSD server ports are updates lets do Binary updates freebsd-update.
[bash]freebsd-update fetch[/bash]
[bash]freebsd-update install[/bash]
Then reboot
[bash]shutdown -r now[/bash]
Verify update took place
[bash]uname -a[/bash]
Rollback if necessary
[bash]freebsd-update rollback[/bash]
Now lets install Apache, PHP, mysql and phpMyAdmin on your freeBSD 8 web server.
First install the latest apache from ports.
[bash]cd /usr/ports/www/apache22/
make config install clean
echo ‘apache22_enable="YES"’ << /etc/rc.conf
echo ‘apache22ssl_enable="YES"’ << /etc/rc.conf
echo ‘accf_http_ready="YES"’ << /etc/rc.conf && kldload accf_http[/bash]
Now install PHP
[bash]cd /usr/ports/lang/php5
make config install clean
cd /usr/ports/lang/php5-extensions ** enable <strong>mysql </strong>extensions **
make config install clean[/bash]
Now modify your httpd.conf – Add the following entries to /usr/local/etc/apache22/httpd.conf directly after all the LoadModule lines
[bash]AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps[/bash]
now locate IfModule mod_dir.c and add index.php
[bash]DirectoryIndex index.php index.html index.htm[/bash]
Last but not least get a good php.ini file setup
[bash]cp /usr/local/etc/php.ini-recommended /usr/local/etc/php.ini[/bash]
Restart apache and
[bash]/usr/local/etc/rc.d/apache22 start[/bash]
Now its time for mySQL installation, configuration and setup
[bash]cd /usr/ports/databases/mysql50-server
make install WITH_OPENSSL=yes
make distclean
echo ‘mysql_enable="YES"’ << /etc/rc.conf[/bash]
Start mysql server and change root password
[bash]/usr/local/etc/rc.d/mysql-server start
mysqladmin -u root password sumcrazypaswrd
mysql -u root -p *make sure you can log in*
rm /root/.history *remove history so password isn’t exposed*[/bash]
Create a configuration file for mysql in /etc/my.cnf
[bash][client]
port=29912
[mysqld]
port=29912
bind-address=127.0.0.1[/bash]
Now lets install configure and setup phpMyAdmin
[bash]cd /usr/ports/databases/phpmyadmin
make config install clean
cd /usr/local/www/phpMyAdmin && cp config.sample.inc.php
config.inc.php
vi config.inc.php
$cfg[‘blowfish_secret’] = ‘sdf934sdfgHijh98Y’;[/bash]
open httpd.conf and Alias
[bash]Alias /phpmyadmin /usr/local/www/phpMyAdmin[/bash]
Now allow who you want to access it
[bash] <Directory "/usr/local/www/phpmyadmin'<
Order allow,deny
Allow from all *or allow from 222.114.123.0/12*</pre>
you’ll want https when you connect to phpmyadmin so lets enable https and make some httpd.conf changes
<strong>Create your certificate</strong>
In order to access phpmyadmin of ssl you need to get https going on apache. You can buy an SSL certificate generated by a trusted CA such as Thwate or Verisign, or you can generate one yourself using OpenSSL. I borrowed a ton of infor from <a href="http://www.freebsdmadeeasy.com/tutorials/freebsd/create-a-ca-with-openssl.php">freebsdmadeeasy.com</a>
lets get the openssl.cnf file ready
[bash]vi /etc/ssl/openssl.cnf
dir = /root/sslCA
default_days = 3650[/bash]
Now set up the directories
[bash]cd ~root/
mkdir sslCA
chmod 700 sslCA
mkdir certs private newcerts
echo 1000 < serial
touch index.txt
cd ~root/sslCA
openssl req -new -x509 -days 3650 -extensions v3_ca -keyout private/cakey.pem -out cacert.pem -config /etc/ssl/openssl.cnf[/bash]
The CA should now be all set.. test with more;
[bash]more ~root/sslCA/cacert.pem
more ~root/sslCA/private/cakey.pem[/bash]
Now lets generate an SSL certificate for apache
[bash]cd ~root/sslCA
openssl req -new -nodes -out yourhostname-req.pem -keyout private/yourhostname-key.pem -config /etc/ssl/openssl.cnf
openssl ca -config /etc/ssl/openssl.cnf -out yourhostname-cert.pem -infiles yourhostname-req.pem[/bash]
Lets put everything where it needs to be.
[bash]mkdir /etc/ssl/crt
mkdir /etc/ssl/key
cp ~root/sslCA/yourhostname-cert.pem /etc/ssl/crt
cp ~root/sslCA/private/yourhostname-key.pem /etc/ssl/key[/bash]
And finally add the SSL virtual host
Find the below line in your httpd.conf and take the comment hash out.
[bash]# Secure (SSL/TLS) connections
Include etc/apache22/extra/httpd-ssl.conf[/bash]
Now modify your httpd-ssl.conf
[bash]ServerName ssl.yourhostname.com
SSLCertificateFile /etc/ssl/crt/yourhostname-cert.pem
SSLCertificateKeyFile /etc/ssl/key/yourhostname-key.pem
DocumentRoot "/etc/www/apache22/data" ** whatever your location is**
ErrorLog "/var/log/httpd-error.log"
TransferLog "/var/log/httpd-access.log"[/bash]
In /usr/local/etc/apache22/extra/httpd-default.conf, disable ServerSignature to prevent the server from showing more information than it has to. Make sure the server-status and the server-info sections in /usr/local/etc/apache22/extra/httpd-info.conf are commented out.
Finally restart apache
[bash]/usr/local/etc/rc.d/apache22 restart[/bash]
Now install wordpress
[bash]cd /usr/ports/wordpress
make install clean[/bash]
do a locate wordpress and move file to web root
[bash]locate wordpress
cp /usr/local/www/data/wordpress/* /usr/local/whatever web root is[/bash]
go into web root and copy wp-config-sample.php to wp-config.php
navigate to https://hostname/phpmyadmin and create wordpress db – add that name to wp-config.php
surlyjake says
Thanks. very helpful.
Your “greater than” symbols are getting mangled by wordpress.
one typo:
“cp /usr/local/etc/php-ini-recommended /usr/local/etc/php.ini”
should be:
“cp /usr/local/etc/php.ini-recommended /usr/local/etc/php.ini”
Kurt says
@surlyjake
Thanks Surly
I’ve made the correction to the typo – still trying to find a good plugin to properly display code in my post.
cleroy61 says
Hi everybody !
Can you help me, please ?
I set make install clean in the mysql installation ;
In which file can I set WITH_OPENSSL=yes ?
/etc/rc.conf or another ?
kurt says
@cleroy61
Dude follow the guide line for line =)
Its copy paste baby
echo ‘mysql_enable=”YES”‘ << /etc/rc.conf
cleroy61 says
Thanks for your answer
I even read the freebsd guide (29 chapitres) but nothing about Mysql so I looked for other FAMP tuto and found them.
Other thing :
for mysql :
/usr/local/bin/mysqladmin -u root password ‘monpassword’
and not :
/usr/local/bin/mysqladmin -u root password monpassword
Kurt says
@cleroy61
Above I list the sql password command as:
mysqladmin -u root password sumcrazypaswrdV
Which is 100 percent correct.
Joel says
I know this is a little late, but i also noticed in the SSL section you have “chmod 700 sslCA” twice where i believe one of them is sposed to be “cd sslCA”.
Kurt says
thanks Joel, it wasn’t hurting anything but ya one of them can be removed.