Home Linux & Systems Cybersecurity Cloud & DevOps Networks & Infrastructure SIEM & Monitoring DFIR & Threat Intel Development & Other All categories Projects About Tools

Install web server on FreeBSD 8.1

Leer en espanol
Install web server on FreeBSD 8.1

Table of contents

First of all, let's change the IP addressing, it will ===

Servidorweb freebsd red orbita

In this article we are going to try to install (and I say try because it is my first server on FreeBSD) a web server, using apache22.

First of all, we are going to change the IP addressing, we are going to give it a static address.

To configure a static ip we have to modify the file:

text
# ee /etc/rc.conf

and we add at the end:

Bash
ifconfig_em0=»inet 192.168.1.105 netmask 255.255.255.0″

defaultrouter=»192.168.1.1″

To save: ESC : Leave editor : Save change

Restart network services to update the changes.

text
# /etc/netstart

We verify that the changes have been made:

text
# ifconfig em0

*Note: If we have uncommented: ifconfig_em0″DHCP» We discuss it.

We install Apache.
We access the ports, configure and install.

text
# cd /usr/port/www/apache22
# make install clean

One of the main advantages of using ports to install software is the ability to adjust installation options. For example, it is possible to activate mod_ldap inside your Apache 2.2 during installation by using the variable WITH_LDAP of make(1):

text
cd /usr/ports/www/apache22

## make WITH_LDAP=»YES» install clean

A Menu appearsOptions of gettext” *Situate yourself in “OK" and press enter.

In my case. It gave me a dependency error in perl and I had to install it.

text
# cd /usr/ports/lang/perl15.19/
#make install clean

Although for my taste... it takes a... little... to download and compile the packages...
be patient...

Once the installation is finished, we are going to edit the file: /etc/rc.conf so that when you start the PC it starts apache

We access the file

text
#ee /etc/rc.conf

and we add at the end:

text
apache22_enable=”YES”

To save: ESC : Leave editor : Save change

We configure httpd.conf

text
#ee /usr/local/etc/apache22/httpd.conf

We check that it is uncommented:

text
ServerRoot «/usr/local»

DocumentRoot «/usr/local/www/data»

we start Apache

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

We open a browser and access our web server. If everything has gone well, the index should appear.

Servidorweb freebsd red orbita1

In case this is not the case, and you get an error. access again httpd.conf

text
# ee /usr/local/etc/apache22/httpd.conf

Find the line and comment on it. :

text
#LoadModule unique_id_module libexec/apache22/mod_unique_id.so

Install and Configure PHP

text
# cd /usr/ports/lang/php5

We configure PHP

We select the packages we want to install.

text
# make configure

Servidorweb freebsd red orbita2

we install

text
# make install clean

We configure httpd.conf

text
# ee /usr/local/etc/apache22/httpd.conf

we add:

text
AddType application/x-httpd-php .php

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

We go to the line: DirectoryIndex

and we add:

text
DirectoryIndex index.htm index.html index.php

In the loaded Apache modules it must already exist. If not, something has gone wrong... haha

text
LoadModule php5_module libexec/apache22/libphp5.so

We modify: loader.conf

text
# ee /boot/loader.conf

and we add:

text
accf_http_load=»YES»

We restart the service

We also install:

text
/usr/ports/lang/php5-extensions

/usr/ports/databases/php5-mysql

/usr/ports/www/php5-session

/usr/ports/graphics/php5-gd

We check if we really have a php service, for this we are going to create a file called: test.php

text
# ee /usr/local/www/apache22/data/test.php

In the file we put the following code:

php
<?php phpinfo(); ?>

To save: ESC : Leave editor : Save change



We open a browser and access the saved file: http://192.168.1.121/test.php

If everything has gone well, it will show us a screen like this:


Servidorweb freebsd red orbita3



Install MySQL-Server

We are going to install mysql5.1-server, because although I do a search and it is: mysql60-server I don't know...because it won't let me access the folder...

We access the folder:

text
cd /usr/port/databases/mysql51-server

We install

text
make install clean

We generate the permissions tables for MySQL:

text
# /usr/local/bin/mysql_install_db

We change the owner and group of the data directory:

text
# chown -R mysql:mysql /var/db/mysql/

And once this is finished, we edit the rc.conf file to make mysql automatically

text
# ee /etc/rc.conf

We add:

text
mysql_enable=»YES»

To save: ESC : Leave editor : Save change

We set the root password.

text
# /usr/local/bin/mysqladmin -u root password tupassword

Install phpmyadmin

We access the directory.

text
cd /usr/port/databases/phpmyadmin

We install

text
# make install clean

We configure phpmyadmin

first let's edit the file httpd.conf

text
# ee /usr/local/etc/apache22/httpd.conf

At the end of the file we add:

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

Now we are going to configure the file: config.ini.php

text
# ee /usr/local/www/phpMyAdmin/config.inc.php

inside this file we add the following:

text
>$cfg[‘Servers’][$i][‘user’]	= ‘root’;

$cfg[‘Servers’][$i][‘password’]	= ‘tu password’;

We restart and if everything went well, a window like this should appear:

Servidorweb freebsd red orbita4

In the next chapter…. hahaha, we will implement Cacti

Regards, rokitoh

Sources:

http://www.forat.info

http://www.diariobsd.com

http://cachorroyayo.wordpress.com

http://www.freebsdmadeeasy.com

Comments