Install Apache in FreeBSD
Installing and configuring the Apache 2.2.x web server in FreeBSD.
To begin the Apache installation process, log in like the superuser and enter the following commands:
cd /usr/ports/www/apache22 make install clean
A menu should appear to show options for Apache. Here you may leave default options, but If you need to build and install Apache with special modules then you have to choose them now. For example if you want your Apache to support the working with MySQL databases then you need to select it in the menu by pressing 'space'. After choosing needed options you can start to install Apache by pressing 'tab' and 'enter'.
We are going to configure Apache to start automatically at boot time. To do so, edit the /etc/rc.conf file and add the following line to the end of file:
After this we will make base configuration which is enough to run Apache. Open the file /usr/local/etc/apache22/httpd.conf. In this file you need to find and set values for two options:
ServerAdmin firstname.lastname@example.org ServerName host.example.com:80
- ServerAdmin is email address of the person who will be maintaining the server.
- ServerName is hostname of your server
If you don't have hostname which pointed to server's IP then you may set any hostname, but then you will need to set this hostname and IP in your local PC which you use for browsing current server.
You need to add following line to file:
- for Windows C:\WINDOWS\system32\drivers\etc\hosts
- for Linux /etc/hosts
Where 192.168.0.100 is IP for your server where you are installing Apache.
After you completed configuring Apache you can check your config file for syntax errors by running this command:
If it returns "Syntax OK", continue below. If it finds a problem, it will list the filename, line number, and possible reasons for the error. Be sure to resolve any issues prior to continuing below.
After these you can run Apache by command:
Now you can open any browser and check how it works. For this example "host.example.com".
- /var/log/httpd-access.log contains a log of IP addresses, times, and activity on the HTTP server
- /var/log/httpd-error.log contains a log of error messages produced by the HTTP server