- blog.up-link.ro - https://blog.up-link.ro -

Apache HTTP Server + PHP 5 + MySQL Installation in FreeBSD

1. Install Apache HTTP Server
Go to apache22 port:
# cd /usr/ports/www/apache22
and type:
# make config

Now you can choose the options from the menu.
# make install clean

To enable apache on boot, add the following line to /etc/rc.conf
apache22_enable="YES"

To start apache http server, type
# /usr/local/etc/rc.d/apache22 start

2. Install PHP 5
Go to php port:
# cd /usr/ports/lang/php5
and type:
# make config
Now you can choose the options from the menu (make sure you enable 'Build Apache Module').
# make install clean

3. Install MySQL Server
Go to:
# cd /usr/ports/databases/mysql51-server
and run:
# make install clean

This command will download required files from the internet and will install MySQL server.

Once the install is finished, we install the database
# mysql_install_db –user=mysql
and we set up the directory permissions
# chown -R mysql /var/db/mysql/
# chgrp -R mysql /var/db/mysql/

Make sure MySQL server start automatically whenever FreeBSD comes up after reboot.
FreeBSD provide this facility via system configuration information. This file lists which services should be started up at system initial boot time.
The file contains the global system configuration information referenced by the start up scripts and is stored in /etc/rc.conf.

Configure FreeBSD to start MySQL at start up
Open /etc/rc.conf file using a text editor ( I use vi but you can use your preferred editor )
# vi /etc/rc.conf
and append following line which will enable MySQL server automatically after each reboot:
mysql_enable=”YES”
Save file and exit to shell prompt.

Starting MySQL server
To Start MySQL server under FreeBSD type following command (use script):
# /usr/local/etc/rc.d/mysql-server start

Note: This will work only if you have mysql_enable=”YES” in rc.conf. If you don’t, use the following command:
# /usr/local/etc/rc.d/mysql-server forcestart

MySQL Password
By default, MySQL super user account has no password. So it’s important to assign the administrator account password. To change the root password, enter the following command:
mysqladmin -u root password newpass

Replace newpass with your own desired password.

Optionally, copy either my-huge.cnf, my-large.cnf, my-medim.cnf or my-small.cnf (depending on the usage and utilization of your MySQL server) as my.cnf to /etc/ or /var/db/mysql which will enable you to tweak and change the configuration of server-specific MySQL server options by editing the file.

4. Install php5-mysql module
Go to ports:
# cd /usr/ports/databases/php5-mysql
and type the following command:
# make install clean

5. Restart the services
- restart apache22:
# /usr/local/etc/rc.d/apache22 restart
- restart mysql:
# /usr/local/etc/rc.d/mysql-server restart