# cd /usr/ports/www/apache22 # make config # make install
Then, add the lines:
In the file:
And then, run the service:
Verify if the server is running:
And check if port 80 is open, then:
#telnet localhost 80
If the connections is successful your server is running.
When you want to install any package, just go to the port directory and install it. In this case is under www directory, /usr/ports/www/apache13-modperl. It will download from ftp.freebsd.org and start make. The progress took a while since the connection in Seneca is slow. When I install at home it took about 30 minutes to finish 'make' in my VM. And I waited about 3 hours for the make at seneca and it never finished.
I personally prefer yum and apt-get instead of FreeBSD "port" method. Because they have a great search function that let you search by keyword. Of course you can do the simulatr thing in FreeBSD with some ls command. It's just much more easier in Linux.
2009/04/11 As I mentioned in previous lab, it seems better to install step by step. First, install the latest Apache, it should be 2.2.9 now, and 2.2.11 is coming soon. Then install mod_perl. It seems that the latest perl5.8 or apache2.2 dosen't including mod_perl even if you do 'make config'. So, again, the best way is install apache first, make sure it's running, then go to mod_perl directory to make it. It would be better, if you're using vbox, because 'make' crashes all the time. It's better to install one by one.
# vim /usr/local/etc/apache22/httpd.conf
replace the line "ServerAdmin" firstname.lastname@example.org" with the systems administrators e-mail address.
replace "ServerName host.example.com:80" line with hostname of your server accordingly
# echo "apache22_enable="YES" >> /etc/rc.conf
# echo "apache22_http_accept_enable="YES" >> /etc/rc.conf
# apachectl configtest
# /usr/local/etc/rc.d/apache22 start
Upon first attempting to install Apache, I chose Apache 2.2. This worked fine, and the installation of itself went alright - problems only occured when I attempted to build mod_python. It appears the version of mod_python included in the ports collection expects Apache 1.3. So, I went back, removed 2.2, and installed 2.1
After this, the next hurdle was that mod_python expects a single-threaded Python runtime, however, the default in FreeBSD is a threaded runtime. So, it was necessary to deinstall the Python 2.5 port, set the WITHOUT_THREADS environment variable to 1, and rebuild/reinstall Python, after which mod_python will happily build and install.
mod_perl, on the otherhand, was a relatively smooth install, and required nothing beyond just the standard 'make install distclean'. All it's dependencies were present and in a working state by default.
After the software is installed, it is necessary to set the server's name, both by adding the line 'ServerName "fbsd"' to the Apache configuration file at /usr/local/etc/apache/httpd.conf, as well as the line '127.0.0.1 fbsd' into /etc/hosts. After this, the Apache server starts succesfully.
The final hurdle was correcting the provided CGI scripts to behave properly in the CGI environment. It was neccesary to add the line: 'print "Content-Type: text/html\n\n";' to the Perl script and the line 'print "Content-Type: text/html\n"' to the Python script. After these changes, both scripts ran as expected, producing correct output.
It would be nice to have a version of mod_python in ports that works properly with Apache 2.2.
For Apche2.0 or Apache2.2 we need to install a mod_python3.3.1. By deafult it is not in the ports. So we have to down load the tar.tz and install from there.
Step how i did it.
1. Install the text based web browser lynx/elinks
#pkg_add -r elinks
2. Visit the web site http://www.modpython.org/
Downloaded the tar http://east.unified.net/apache/httpd/modpython/mod_python-3.3.1.tgz
3. tar -xvjf mod_python-3.3.1.tgz 4. cd mod_python-3.3.1 5. less README file
then according to instruction.
to check weather it is installed?
- pkg_info | grep python
python25-2.5-2_3 An interpreted object-oriented programing language.
Installation of mod_perl2 for Apache22
Apache is running Ok. But the python script is not working I checked the error log for Apache in /var/log/httpd-error.log
"malformed header from script BAD header=Hello World: hello.py"
Oh Finally works. Have put the line header in CGI/Python script the following line after the #!/usr/bin/python line.
print "Content-Type: text/html\n"
now its working fine.
Installing mod_perl is easy, I just use command "pkg_add -r mod_perl". But I cannot use this method to install mod_python. The steps as below are my installing mod_pyhton method:
Firstly, I installed python.
make install clean
The second, I installed mod_python
tar zxvf mod_python-3.2.10.tgz
./configure --with-apxs=/usr/local/sbin/apxs --with-python=/usr/local/bin/python2.5
The third step, modified httpd.conf file and added the following line into group LoadModule
LoadModule python_module libexec/apache22/mod_python.so
Finally, I tested it, and it is OK.