Pages

Thursday, July 26, 2012

OSX Mountain Lion workaround to enable web sharing

I have just upgraded to Mountain Lion. But I feel very disappointed that the web sharing feature is missing. I cannot access my local site, but somehow I still can get the default apache page when accessing http://localhost/.

Here is the workaround that I did to re-enable my own site. To make it safe, make sure to make a copy of /etc/apache2/httpd.conf before modifying anything.

(1) Open terminal, switch to root:
$ sudo su -
(2) Go to /etc/apache2/users/:
$ cd /etc/apache2/users $ ls
(3) I found one file Guest.conf. I copy the file into another file (in this case I am using my own user name: chn.conf), and edit the directory location to my Site location in "/Users/chn/Sites":
$ cp Guest.conf chn.conf $ vi chn.conf
It looks like this after the modification:
<Directory "/Users/chn/Sites/">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
(4) Let apache load PHP module, by editing the httpd.conf:
$ vi /etc/apache2/httpd.conf
Search for the following line:
#LoadModule php5_module libexec/apache2/libphp5.so
and remove the remark "#" in the beginning of the line so it looks like this:
LoadModule php5_module libexec/apache2/libphp5.so
(5) Restart the apache service by the following command:
$ apachectl restart
Now I can access my own homepage again.

That's all :)

Monday, July 16, 2012

How to do screen capture in MacOSX in JPG instead of PNG

In MacOSX, we can easily do screen capture and save the image in PNG format to the desktop by the following keyboard shortcuts:
  • Comand+Shift+3 : capture the whole screen.
  • Comand+Shift+4 : capture a particular area by specifying the area using mouse, or by pressing spacebar to select a window.
Nevertheless, we may want to save the screen capture file in a different file format, such as JPG or maybe PDF. To do so, apply the following command in the terminal (the example is using JPG format):
$ default write com.apple.screencapture type jpg $ killall SystemUIServer

That's all :)