Hello everyone!
Once, somewhere in summer 2011, I already configured FreeBSD 8 development server in our office. Then upgraded it to FreeBSD 9.0
And now new 2x2Tb disks ( for RAID0 ) and 1 SSD 100Gb arrived in case we have a lack of space on the current 500GB raid.
It’s time to install it again!
Main goal is to have more flexible server configuration and avoid of small errors which i had in first installation.
The main steps would be:
- FreeBSD 9.2-RELEASE installation
- Configuration and installation small utils like MC, Webmin, etc
- Apache 2.2 installation
- PHP 5.2, PHP 5.3, PHP 5.4 installation. All versions would be installed as FCGI
- Mysql server
- BIND DNS server
- Apache Virtual Hosts
- Samba 3.6
- Sendmail
1. FreeBSD 9.2-RELEASE installation
Diring the installation please refer this official manual: http://www.freebsd.org/doc/handbook/bsdinstall.html
Allocating Disk Space: http://www.freebsd.org/doc/handbook/bsdinstall-partitioning.html
2. Configuration and installation small utils like MC, Webmin, etc
2.1 Add “admin” user to the “wheel” group.
Login as the root user and add “admin” user to the “wheel” group. Then you will be able to operate as superuser.
pw user mod admin -G wheel
2.1 MC
cd /usr/ports/misc/mc make install clean
Uncheck “X11” support. All others may leave by default. MC installations is a really long process with a lot of dialog windows. Just press everywhere “Ok”.
2.2 Webmin
Install or update ports
portsnap fetch portsnap extract portsnap fetch update
Webmin installation
cd /usr/ports/sysutils/webmin make install clean
Add next line to “/etc/rc.conf” file.
webmin_enable="YES"
Configure Webmin by running.
/usr/local/lib/webmin/setup.sh
Start Webmin for the first time by running
/usr/local/etc/rc.d/webmin start
Open Webmin in browser
https://your-ip:10000/
3. Apache 2.2 installation
Navigate to the Apache server port and build it:
cd /usr/ports/www/apache24 make install clean
Add next line to “/etc/rc.conf” file.
apache24_enable="YES"
Now let’s start Apache to make sure it works:
/usr/local/etc/rc.d/apache24 start
If you are getting this error
Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Add next line to /usr/local/ect/apache24/httpd.conf file
ServerName localhost
4. PHP 5.2, PHP 5.3, PHP 5.4 installation. All versions as FCGI
Install mod_fcgid
cd /usr/ports/www/mod_fcgid make install clean
Add next line to /usr/local/ect/apache24/httpd.conf file
LoadModule fcgid_module libexec/apache24/mod_fcgid.so
4.1 Installing PHP5.4
cd /usr/ports/lang/php5 make config make PREFIX=/usr/local/php54 PHPBASE=/usr/local/php54 install clean
If you got this error
error: xml2-config not found. Please check your libxml2 installation.
Try this:
cd /usr/ports/textproc/libxml2/ make reinstall
Pre configure PHP54 to make sure it works.
Add next lines to to /usr/local/ect/apache24/httpd.conf file.
<Directory "/usr/local/www/apache24/data"> ... Options ExecCGI Options +Indexes Allow from all </Directory> <IfModule mime_module> ... AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps </IfModule>
Create new file /usr/local/ect/apache24/Includes/httpd-fcgid.conf with the next content:
<IfModule mod_fcgid.c> AddHandler fcgid-script .php FCGIWrapper /usr/local/php54/bin/php-cgi .php FcgidMaxRequestLen 134217728 </IfModule>
Change DirectoryIndex directive in file /usr/local/etc/apache24/httpd.conf
DirectoryIndex index.html index.htm index.php
4.2 Installing PHP5.3
cd /usr/ports/lang/php53 make config make PREFIX=/usr/local/php53 PHPBASE=/usr/local/php53 install clean DISABLE_CONFLICTS=1
4.3 Installing PHP5.2
cd /usr/ports/lang/php52 make config make PREFIX=/usr/local/php52 PHPBASE=/usr/local/php52 install clean
4.4 Configuration all PHP5.X
Create php.ini file for each php verson: /usr/local/php5X/etc/php.ini
user_ini.filename = "php.ini" date.timezone = Europe/Kiev
In this way you can override php_value and php_flag variables, because PHP installation as FCGI doesn’t allow to override these variables via htaccess ( cause 500 error ).
You can override php_value and php_flag per-directory level, just need to create php.ini in the directory where you want to override these variables.
P.S. user_ini.filename is not supported by PHP52, so you have to override these variables in the main php.ini file /usr/local/php52/etc/php.ini
date.timezone needed to avoid following Warning
Warning: phpinfo() [function.phpinfo]: It is not safe to rely on the system's timezone settings.
For using another FCGI Wrapper instead of default php54, just add into htaccess:
For php53
FCGIWrapper /usr/local/php53/bin/php-cgi .php
For php52
FCGIWrapper /usr/local/php52/bin/php-cgi .php
4.5 Installing PHP5.4 extensions
cd /usr/ports/lang/php5-extensions make PREFIX=/usr/local/php54 PHPBASE=/usr/local/php54 install clean
Select neccessary extensions which you need to have.
If you got this error
error: Please reinstall the libcurl distribution
Try this:
cd /usr/ports/ftp/curl make reinstall
If you got this error
Stop in /usr/ports/x11/libXau.
put the following in your /etc/make.conf:
WITHOUT_X11=yes
For each failed extension, try
cd /usr/ports/[portdir] make deinstall make clean make distclean make clean make rmconfig
And Then resintall it (with PREFIX if needed)
Reinstall libjpeg
cd /usr/ports/graphics/jpeg make reinstall
Reinstall freetype2
cd /usr/ports/print/freetype2 make reinstall
4.6 Installing PHP5.3 extensions
cd /usr/ports/lang/php53-extensions make PREFIX=/usr/local/php53 PHPBASE=/usr/local/php53 install clean
Select neccessary extensions which you need to have.
4.7 Installing PHP5.2 extensions
cd /usr/ports/lang/php52-extensions make PREFIX=/usr/local/php52 PHPBASE=/usr/local/php52 install clean
Select neccessary extensions which you need to have.
Please be sure you have instaled all these extensions for all PHP versions
CURL, GD, MYSQL, MYSQLI, PDO, PDO_MYSQL, MBSTRING, MCRYPT, ZLIB, ZIP, SOAP, LDAP, OPENSSL
5. Mysql Server
Build the MySQL server:
cd /usr/ports/databases/mysql56-server make install clean
Add the following line to /etc/rc.conf:
mysql_enable="YES"
Start the mysql server:
/usr/local/etc/rc.d/mysql-server start
Then set a password for the MySQL root user:
/usr/local/bin/mysqladmin -u root password 'your-password'
Add new user within the MySQL shell:
CREATE USER 'developer'@'localhost' IDENTIFIED BY 'developer'; GRANT ALL PRIVILEGES ON * . * TO 'developer'@'localhost'; FLUSH PRIVILEGES;
6. BIND DNS server
Usually BIND server is already installed in FreeBSD.
Add the following line to /etc/rc.conf:
named_enable="YES"
In the file /etc/namedb/named.conf make next configurations
options { ... listen-on { 192.168.1.200; 127.0.0.1; }; ... }; zone "dev" { type master; file "/etc/namedb/dev.zone"; }; zone "1.168.192.in-addr.arpa" { type master; file "/etc/namedb/dev-reverse.zone"; };
Then create zone file /etc/namedb/dev.zone
dev. IN SOA ns1.dev. n2.dev. ( 2009121101 86400 7200 8640000 86400 ) IN NS ns1.dev. ns1 IN A 192.168.1.200 ns2 IN A 192.168.1.200 vmserver IN A 192.168.1.200 php54 IN A 192.168.1.200
And for reverse zone /etc/namedb/dev-reverse.zone
$TTL 3600 @ IN SOA ns1.dev. ns2.dev. ( 2009121102 3600 900 3600000 3600 ) IN NS ns1.dev. IN NS ns2.dev. 200 IN PTR vmserver.dev. 200 IN PTR php54.dev.
At last configure /etc/resolv.conf properly
domain dev nameserver 192.168.1.200
7. Apache Virtual Hosts
Create /usr/local/ect/apache24/Includes/httpd-vhosts.conf
<VirtualHost *:80> DocumentRoot "/usr/local/www/apache24/data" ServerName vmserver.dev <Directory "/usr/local/www/apache24/data"> Require all granted Allow from all </Directory> </VirtualHost> <VirtualHost *:80> DocumentRoot "/usr/local/www/php54.dev" ServerName php54.dev <Directory "/usr/local/www/php54.dev"> Require all granted Allow from all </Directory> </VirtualHost>
8. Samba 3.6
Installation
cd /usr/ports/net/samba36 make install clean
Select: ACL_SUPPORT, AIO_SUPPORT, CUPS
Add the following line to /etc/rc.conf:
samba_enable="YES"
Configuration file /usr/local/etc/smb.conf should contain next lines
[global] workgroup = WEBCODING netbios name = VMSERVER server string = Virtual machine server security = SHARE [work] path = /usr/local/work public = yes browseable = yes writable = yes [www] path = /usr/local/www public = yes browseable = yes writable = yes
9. Sendmail
At the end, we need to to redirect all email to one on the local email boxes.
We need to create working macro configuration file.
cd /etc/mail make
Add next line to the created sendmail configuration file: /etc/mail/vmserver.dev.mc
define(`SMART_HOST',`local:catch-all')
Then add alias to the /etc/mail/aliases file
catch-all: qa
Generate the sendmail.cf by issuing the following commands:
make install
And then restart sendmail service
make restart service sendmail restart
Then all emails will be sent to the local mailbox of the QA user instead of spamming real clients mailboxes.
Finished! Now you can use server for development.
P.S. Please don’t use this configuration on the production servers.