Saturday, September 5, 2009

Mac Ports Apacha - Perl CGI

After getting macbook, it has been a learning experience. So far, its been very good.
Documenting here is how I got my environment setup for MAMP (MAC,APACHE,Mysql,Perl/PHP)

first things first.. (before we begin)
setting your mac with basic structure:
http://developer.apple.com/technology/Xcode.html
Download the latest xcode and install that.

Get the Mac Ports
http://www.macports.org/install.php
install that.

we have setup the basic infrastructure. If you have worked with ubuntu apt-get, or gentoo emerge, then mac port is quite a similar tool.
run the following
#>sudo port selfupdate
#>sudo port update outdated
#>sudo port install apache2 mysql5 mysql5-server php5 perl5.8 p5-dbd-mysql

the above installs all that we require.

now remember to change the path on your .profile/.bashrc etc (whatever shell you are running) so as to pick the binaries from mac ports path.

export PATH=/opt/local/bin:/opt/local/sbin:$PATH

Noticed! that $PATH is at the end, because perl, apache etc are there on mac and we dont want them :)

---

configuring apache
we want the apache to be run as nobody - hence change the permissions whereever necessary.
this is what I have done:
sudo chown -R nobody:nobody /opt/local/apache2/cgi-bin/
sudo chown -R nobody:nobody /opt/local/apache2/htdocs/
sudo chown -R nobody:nobody /opt/local/apache2/logs


apache configs:
edit /opt/local/apache2/conf/httpd.conf
for correct ServerAdmin and ServerName
uncomment Include conf/extra/httpd-vhosts.conf ( right at the bottom)

edit Include conf/extra/httpd-vhosts.conf ( which is our own virtual Host config )

--
<VirtualHost *:80>
    ServerAdmin sanjayu@queenself-lm
    DocumentRoot "/Users/apache2/htdocs"
    ServerName queenself-lm
    ServerAlias    queenself-lm
    ErrorLog "logs/queenself-lm-error_log"
    CustomLog "logs/queenself-lm-access_log" common
    ScriptAlias /cgi-bin/ /Users/apache2/htdocs/cgi-bin/

    <Directory /Users/apache2/htdocs>
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
      
    <Directory /Users/apache2/htdocs/cgi-bin>
         AddHandler cgi-script .cgi .pl
         Options +ExecCGI
         AllowOverride None
         Order allow,deny
         Allow from all   
   </Directory>

</VirtualHost>
--

No comments:

VIM issues with powerline

What to do if you get this annoying issue - vi requirements.txt ...