Alwina's open source efforts

|

Specialized in FreeBSD and CentOS

Perfect FAMP server for 7.x

May 7th, 2010 at 16:22

Introduction
This article describes how to setup Apache, MySQL PHP and phpMyAdmin on a server running FreeBSD. This version is based on FreeBSD 7.3. It is likely to work on newer version without too much difficulty.

Before you begin

1. Standard installation of FreeBSD
This articles asumes you have a working install of FreeBSD 7.3 for i386 logged in as root with the ports collection installed. You can use sysinstall, portsnap or similar to install the ports collections. A standard installation of FreeBSD is described in this article.

2. Update /usr/ports

# portsnap fetch
# portsnap extract

Procedure

1. Installing MySQL

a. Build MySQL from the ports

# cd /usr/ports/databases/mysql51-server
# make install clean -DBATCH

This may take a while. Please relax and enjoy life!

b. Edit /etc/rc.conf

Add the following line to /etc/rc.conf:

mysql_enable=”YES”

This line will enable mysql and start mysql on boot.

c. Start MySQL manually

Now we will start mysql manually with the following command:

# /usr/local/etc/rc.d/mysql-server start

d. Set password for MySQL

Set the passwor for MySQL with the followingcommand (substitute your own password for ‘your-password’:

# rehash
# mysqladmin -uroot password ‘your-password’

Step 1 completed with success: MySQL is installed!

2. Installing Apache

a. Build Apache from the ports

# cd /usr/ports/www/apache22
# make install clean -DBATCH

b. Edit /etc/rc.conf

Add the following line:

apache22_enable=”YES”

3. Installing PHP

a. Build PHP from the ports

# cd /usr/ports/lang/php5
# make install clean

Make sure the APACHE option (Build apache module) option is ticked when configuring the build. All other options should not be changed. This take a lot of time, another coffee!

b. Install the php5-extensions

# cd /usr/ports/lang/php5-extensions
# make install clean -DBATCH

c. Install the php.ini file

# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

You could also take the development version php.ini-development if you prefer.

d. Edit your Apache configuration file httpd.conf

# vi /usr/local/etc/apache22/httpd.conf

Add the following lines to the end of the file, just before the include statement:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Search for the line that reads:

DirectoryIndex index.html

and add index.php so it reads

DirectoryIndex index.php index.html

Enable language settings by searching for the line

#Include etc/apache22/extra/httpd-languages.conf

and removing the # comment mark so it reads:

Include etc/apache22/extra/httpd-languages.conf

e. Edit your Apache configuration file httpd-languages.conf

# vi /usr/local/etc/apache22/extra/httpd-languages.conf

Add the following line to the end of the file:

AddDefaultCharset On

f. Add you hostname to /etc/hosts

# vi /etc/hosts

Add your ‘hostname’ and your ‘hostname’.localdomain this file, so it maps to the IP of your machine.
After the modification the file /etc/host should look like this:

g. Start Apache

# /usr/local/etc/rc.d/apache22 start

If there are no errors: you’re done. Apache with PHP is installed!

4. Installing phpMyAdmin

a. Build phpMyAdmin from the ports

# cd /usr/ports/databases/phpmyadmin
# make install clean -DBATCH

b. Edit Apache configuration file httpd.conf

# vi /usr/local/etc/apache22/httpd.conf

Add the following line to the <IfModule alias_module> section (just search where the other Alias commands are.)

Alias /phpmyadmin /usr/local/www/phpMyAdmin

Add the following <Directory> entry to the configuration:

<Directory “/usr/local/www/phpMyAdmin”>
Order allow,deny
Allow from all
</Directory>

Note: You may prefer to ut the Alias entry inside a <VirtualHost> entry if you are hosting multiple sites using name based virtual hosting and do not wish to enable phpMyAdmin on all the sites.

c. Fix ownership and access rights:

# cd /usr/local/www
# chown -R www:www phpMyAdmin
# chmod +x phpMyAdmin

d. Visit http://<yourip>/phpmyadmin and do the setup

You should get the configuration dialogue of PhpMyAdmin and follow the instructions.

e. Finish configuration of phpMyAdmin

# cd /usr/local/www/phpMyAdmin/config
# cp config.inc.php ..
# cd ..
# \rm -r config
# chown www:www config.inc.php
# chmod 444 config.inc.php

f. Restart Apache

# /usr/local/etc/rc.d/apache22 restart

g. Configure phpMyAdmin

Now you can visit http://<yourip>/phpmyadmin and continue the configuration of  phpMyAdmin.
The page you see should look like this:

And after logging in it should look like this:

Congratulations. Your perfect FAMP server is up and running!

Tags: , , , , ,

17 Responses to “Perfect FAMP server for 7.x”

  1. Julian Kiekbusch Says:

    Terrific do the job! This may be the sort of details that must be shared around the internet. Shame around the search engines for not positioning this write-up higher!

  2. Raye Drawe Says:

    I’ve to say, I enjoy reading this internet site. Maybe you could let me know how I can subscribing with it.

  3. admin Says:

    Hi Ray, thanks for your reaction. Perhaps you want to subscribe to the feed?

    http://feeds.feedburner.com/Alwina

    Regards, Alwina

  4. Quinn Manista Says:

    Hello I’d like to know wherever you got this weblog template from I adore it!

  5. admin Says:

    Hi Quinn,

    Thnx!. It is based on the following theme:
    http://blog.rcg-pt.net/temas-para-wordpress/rcg-forest/

    Regards, Alwina

  6. online travel agency Says:

    Hello webmaster, If I can use some of the information from this post, I’ll provide a link back to your website.

  7. Alonzo Minrod Says:

    Hi – very great site you have established. I enjoyed reading this posting. I did want to publish a comment to tell you that the design of this site is very aesthetically pleasing. I used to be a graphic designer, now I am a copy editor in chief. I have always enjoyed functioning with computing machines and am attempting to learn computer code in my free time.

  8. Douglas Roland Says:

    Thanks for the insight!

  9. walter Says:

    trying to install famp on a pcbsd 8.1 machine.
    was wondering if someone could help me with the following:
    Step 3. Installing PHP
    f. Add you hostname to /etc/hosts
    -followed instructions, afterwards the following error shows after
    /usr/local/etc/rc.d/apache22 start –

    Performing sanity check on apache22 configuration:
    httpd: apr_sockaddr_info_get() failed for pcbsd-6667
    httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
    Syntax OK
    Starting apache22.
    httpd: apr_sockaddr_info_get() failed for pcbsd-6667
    httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
    /usr/local/etc/rc.d/apache22: WARNING: failed to start apache22

    ‘pcbsd-6667′ was replaced with the example given in section f.

    any idea on what should be done?

    kind thanks

  10. admin Says:

    Hi Walter,

    It seems the name pcbsd-6667 is not recognized.
    You could try the command
    ping pcbsd-6667
    to check if the hostname is recognized.

    If not, check your /etc/hosts file.

    Perhaps you should also include the name
    pcbsd-6667.localdomain
    in your /etc/hosts file.

    Please let me know if it works.

    Regards,
    Alwina

  11. walter Says:

    Thank you Alwina,

    followed your instructions and included the following:
    #hostname
    pcbsd-6667
    edited the /etc/hosts file and made these changes
    192.168.1.2 pcbsd-6667.localdomain

    opened up browser and entered localhost – now it works

    there are some other differences between version 7.3 and 8.1 that are causing some install problems.

    example under section:
    1. Installing MySQL

    a. Build MySQL from the ports

    # cd /usr/ports/databases/mysql51-server
    # make install clean -DBATCH

    to avoid problems under FreeBSD 8.1 one would enter

    #cd /usr/ports/databases/mysql51-server
    #make install clean
    #make config

    because of these difference would like to know if there is an interest to write and post an installation guide for 8.1?

  12. admin Says:

    Hi Walter,

    Your additions will add usability of this walkthrough for 8.1. Thanks. I’m interested in writing a specialized version for 8.x but …I hope I can find time.

    Regards, Alwina

  13. walter Says:

    Hi Alwina,

    what would be your impression if the work were done on my part? The install hasn’t been completed because of issues with part:
    4. Installing phpMyAdmin
    c. Fix ownership and access rights:
    chown -R http://www.www phpMyAdmin
    -chown -R doesn’t know how to work with http://www.www

    as of right now don’t know how to modify this. if only a few more tips are provided, the install and documentation for it will be completed.

    kind thanks, walter

  14. admin Says:

    Hi Walter,

    I changed the blog, so you can register (homepage: Meta – register).
    After your registration, I will make a copy of the publication available to you, so you can modify the posting for 8.1. Thanx a lot for your help and looking forward to the result!

    Regards, Alwina

  15. admin Says:

    Hi Walter,

    You should go to the parent directory of phpMyAdmin and try:
    # chown -R www:www phpMyAdmin
    This will change the owner (the first www) and the group to (the second www) to “www” for phpMyAdmin and all files and dirs underneath. The options -R is needed to recurse to all the underlying files and directories.

    Good luck and hope you can finish the installation!

    Regards, Alwina

  16. admin Says:

    Hi Walter,

    Good to know you completed the installation!
    Can you login and modify the article “Perfect FAMP server for 8.x” (it is available in “Posts”)
    and submit it? It now contains a copy of the old article for 7.x.
    After you login it should be available to you in “posts”.

    Regards Alwina

  17. Homepage Says:

    … [Trackback]…

    [...] Read More here: alwina.org/?p=229 [...]…