Skip to content

Instantly share code, notes, and snippets.

@vaichidrewar
Created October 30, 2013 23:48
Show Gist options
  • Save vaichidrewar/7242293 to your computer and use it in GitHub Desktop.
Save vaichidrewar/7242293 to your computer and use it in GitHub Desktop.
Apache installation
FreeBSD Install and Configure Apache Web Server
by NIXCRAFT on JUNE 13, 2008 · 7 COMMENTS· LAST UPDATED OCTOBER 8, 2008
in APACHE, FREEBSD, NETWORKING
Q. How do I install and configure Apache web server under FreeBSD 7.x operating systems?
A. FreeBSD comes with various versions of Apache web servers:
=> Apache 1.3
=> Apache 2.0
=> Apache 2.1
=> Apache 2.2
Step # 1: Update FreeBSD ports collection
Type the following command to update FreeBSD ports collection:
# portsnap fetch update
Step # 2: Install Apache Web Server
Type the following commands:
# cd /usr/ports/www/apache22/
# make install clean
Select required options:
Fig.01: FreeBSD Apache v2.2 Config Options
Fig.01: FreeBSD Apache v2.2 Config Options
Step 3: FreeBSD Configure Apache
Quick facts about Apache version 2.2 under FreeBSD:
Default HTTP port: 80
Default HTTPS (SSL) port: 443
Default DocumentRoot directory: /usr/local/www/apache22/data/
Default cgi-bin directory: /usr/local/www/apache22/cgi-bin/
Default Error Log File: /var/log/httpd-error.log
Default Access Log File: /var/log/httpd-access.log
Default suexec log (if compiled with suexec): /var/log/httpd-suexec.log
Default configuration file directory:/usr/local/etc/apache22/ and /usr/local/etc/apache22/extra/
Default configuration file: /usr/local/etc/apache22/httpd.conf
Turn on Apache service
Type the following command to turn on Apache22 service:
echo 'apache22_enable="YES"' >> /etc/rc.conf
Configure httpd.conf
Open httpd.conf file:
# cp /usr/local/etc/apache22/httpd.conf /root/httpd.conf.bak
# vi /usr/local/etc/apache22/httpd.conf
Bind Apache to specific IP addresses and/or ports, instead of the default. Let us bind to IP address called 202.4.2.1 and port 80:
Listen 202.4.2.1:80
Set your email address:
ServerAdmin vivek@nixcraft.com
Set servername (FQDN) such as www.nixcraft.com:
ServerName www.nixcraft.com
Save and close the file.
Start Apache server
To start Apache server v2.2, enter:
# /usr/local/etc/rc.d/apache22 start
Verify that port 80 is opened:
# sockstat -4 | grep :80
Open port 80 using PF firewall
Warning examples may block access to FreeBSD computerWARNING! These examples may block access to your computer if not executed properly. If you are configuring FreeBSD and Apache first time, I strongly recommend skipping this step.
PF is OpenBSD firewall and available under FreeBSD. You need to configure pf using /etc/pf.conf file. Add following line to your /etc/pf.conf file:
pass in on $ext_if proto tcp from any to 202.4.2.1 port 80 flags S/SA synproxy state
Save and close the file. Reload pf firewall:
# /etc/rc.d/pf reload
Apache
how to see if apache server is running or not
[root@freebsd-vai ~]# ps -A | grep htt
645 ?? Ss 0:12.50 /usr/local/sbin/httpd -DNOHTTPACCEPT
729 ?? IW 0:00.00 /usr/local/sbin/httpd -DNOHTTPACCEPT
[vaibhavc@freebsd-vai ~]$ /usr/local/etc/rc.d/apache22 start
apache22 already running? (pid=645).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment