Monday, February 6, 2012

Let's Get NAPP'y With A NetBSD "LAMP" Server

My good chum Andy has a new post he would like to share.  How to setup a NetBSD version of the perennial LAMP (Linux, Apache, MySQL, PHP).


NetBSD + Apache + PHP + PostgreSQL
My NetBSD version of "LAMP".
Or, as I call it, "NAPP" (NetBSD, Apache, PHP, PostgreSQL)
This all assumes NetBSD and pkgsrc are set up and configured.
Apache
To install Apache (2.x in this case),
# cd /usr/pkgsrc/www/apache22 
# make install clean clean-depends
To start Apache at boot,
# cp /usr/pkg/share/examples/rc.d/apache /etc/rc.d 
# echo 'apache=YES' >> /etc/rc.conf
To start Apache,
# apachectl start
Default httpd.conf location
/usr/pkg/etc/httpd
Default DocumentRoot
/usr/pkg/share/httpd/htdocs
PHP
To install PHP,
# cd /usr/pkgsrc/www/ap-php 
# make install clean clean-depends
For Apache 1.x, add the following to httpd.conf
LoadModule php5_module lib/httpd/mod_php5.so 
AddType application/x-httpd-php .php
For Apache 2.x, add the following to httpd.conf
LoadModule php5_module lib/httpd/mod_php5.so 
AddHandler application/x-httpd-php .php
Restart Apache if it is running.
# apachectl stop 
# apachectl start
For some reason, I had to do stop/start instead of graceful. 
Default location of php.ini
/usr/pkg/etc
PostgreSQL
To install PostgreSQL (9.1 in this case),
# cd /usr/pkgsrc/databases/postgresql91 
# make install clean clean-depends
This may take a while, depending on your system... 
To enable PostgreSQL and start at boot,
# cp /usr/pkg/share/examples/rc.d/pgsql /etc/rc.d/pgsql 
# echo 'pgsql=YES' >> /etc/rc.conf
You can now start PostgreSQL,
# /etc/rc.d/pgsql start
If you try starting PostgreSQL and get a message that "$pgsql is not set properly", it means you didn't edit /etc/rc.conf correctly.
PostgreSQL PHP module
To install the PostegreSQL module for PHP,
# cd /usr/pkgsrc/databases/php-pgsql 
# make install clean clean-depends
To enable the module, add the following line to php.ini,
extension=pgsql.so
Then restart Apache.
And that's it! Enjoy your new NAPP server.


Be sure to check out this post on his site.....

http://level256.net/tech/napp/

If you have no idea of what NetBSD is and you want to learn more click the link below.

http://www.netbsd.org/docs/guide/en/chap-intro.html

Thanks for reading!

No comments:

Post a Comment