Macports based local MAMP :: useful commands

E-mail Print PDF

Important MAMP commands & Setup Tips

There are often times that a developer - using MacPorts MAMP - needs to make quick adjustments. In those cases the command line or terminal is the way to go. Here Imagewize will share some commands it uses very often and thinks is useful for all OSXers who use MacPorts


Going to htdocs the easy way

Every time you need to go to MacPort's htdocs you have to fill in

cd /opt/local/apache2/htdocs
. This can be made way easier using a unix style symbolic link. Open a terminal window and enter the following command:

ln -s /opt/local/apache2/htdocs htdocs
Et voila, from now on
cd htdocs
will lead directly to your LAMP htdocs folder!

Starting Apache

If you do not have MAMP running from startup like I do on my MacBookPro you can startup Apache manually using the following command:

sudo /opt/local/apache2/bin/ apachectl start

PHP.INI Adjustment && Restarting Apache

Restarting Apache on your local server is a very important command since you might want to plauy around with your LAMP Server settings from time to time. Today I wanted to turn off the display of errors in PHP so I could make a small video tutorial. So I went into my PHP.ini . To find out where your php.ini is you can type:

$ which php
/opt/local/bin/php
But you then get the Mac's standard PHP location. In there there is a config file in which you can find the location of the php.ini :

$ cat php-config | grep php5
configure_options=" '--prefix=/opt/local' '--mandir=/opt/local/share/man' '--infodir=/opt/local/share/info' '--with-config-file-path=/opt/local/etc/php5' '--with-config-file-scan-dir=/opt/local/var/db/php5' '--disable-all' '--enable-bcmath' '--enable-ctype' '--enable-dom' '--enable-fileinfo' '--enable-filter' '--enable-hash' '--enable-json' '--enable-libxml' '--enable-pdo' '--enable-phar' '--enable-session' '--enable-simplexml' '--enable-tokenizer' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-bz2=/opt/local' '--with-mhash=/opt/local' '--with-pcre-regex=/opt/local' '--with-readline=/opt/local' '--with-libxml-dir=/opt/local' '--with-zlib=/opt/local' '--without-pear' '--disable-cgi' '--with-ldap=/usr' '--with-apxs2=/opt/local/apache2/bin/apxs'"
The config file path is the path to the .ini. The you open the php.ini using Vim:

sudo vim /opt/local/etc/php5/php.ini

and turned it off:

display_errors = Off
Afterwards I had to restart Apache for the change to take effect so I entered the folllowing command:

sudo /opt/local/apache2/bin/ apachectl -k restart

You have to add the path to the command unless you have created an alias.

Creating an alias

You can add an alias to your profile to start, stop and restart Apache easier by editing the profile file, in this case a command to restart Apache2 as I needed that:

sudo vim ~/.profile
and add

# Apache alias
alias apacherestart='sudo /opt/local/apache2/bin/apachectl -k restart'

from that moment on you can restart Apache2 using

apacherestart
from the command line.

NB Vim should be preinstalled on OSX 10.6.x

 

MAP Installation using MacPorts

To install MAMP on MacPorts see this link.

Last Updated ( Sunday, 04 July 2010 20:27 )  

Add comment


Security code
Refresh

You are here: Home Web Development Macports based local MAMP :: useful commands