Saturday, October 25, 2014

Set up Web server on Mavericks

Apache

1. Enable PHP by opening /etc/apache2/httpd.conf and uncommenting the line 

LoadModule php5_module libexec/apache2/libphp5.so

2. By default, the web root directory is at /Library/WebServer/Documents.  To
use your own directory, say ~/Sites/,  create it with 
mkdir ~/Sites
and then create /etc/apache2/users/your_username.conf and put the following information:

<Directory "/Users/your_username/Sites/">
  Options Indexes MultiViews FollowSymLinks
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>

3. Start the web server 

sudo apachectl start

Now you can test that Apache is running by opening http://localhost in a browser. You should see the text “It works!”.

To test that PHP is now working, create a PHP test file in your web directory with 

printf "<?php phpinfo(); ?>" > ~/Sites/phpinfo.php

Then, open http://localhost/~your_username/phpinfo.php

4. To host the web directory in Dropbox, do

chmod a+rx ~/Dropbox 
mv ~/Sites ~/Dropbox/
ln -s ~/Dropbox/Sites ~/Sites

All files under ~/Dropbox/Sites must have a+rx permission. Make sure to change the file permissions.
Otherwise, the web server will not be able to read them. You can test if the configuration files are valid by using the command
httpd -t 

Friday, October 17, 2014

Prevent MBP retina WiFi to turn off when display sleeps

The command

sudo pmset -b sleep 60

set the sleep timer on battery mode to 60 minutes.
See man pmset and man caffeinate for more information