setting up MacPorts apache2 with virtual hosts and PHP 5.6

I just needed an apache webserver with PHP 5.6 and some virtual hosts on my Mac running OSX El Capitan. The native OSX apache version comes with an older version of PHP which has no xdebug support, so I shut it down with

sudo apachectl stop

Installation

I installed the following ports:

sudo port install apache2 php56 php56-apache2handler php56-xdebug

Apache configuration

After installing the following commands are needed:

cd /opt/local/apache2/modules
sudo /opt/local/apache2/bin/apxs -a -e -n php5 mod_php56.so

After that, the following changes must be made to /opt/local/apache2/conf/httpd.conf:

# add the following line where the modules are loaded
LoadModule php5_module modules/mod_php56.so
#add the following line
Include conf/extra/mod_php56.conf
# set the ServerName
ServerName myhost.local
#uncomment the following line to have vhost configurations:
Include conf/extra/httpd-vhosts.conf

In the file /opt/local/apache2/conf/extra/httpd-vhosts.conf configure the virtual hosts:

<VirtualHost *:80>
  DocumentRoot "/path/to/where/the/docs/are"
  ServerName myvhost
  <Directory />
    DirectoryIndex index.html index.php
    AllowOverride All
    Options All
    Allow from all
  </Directory>
</VirtualHost>

And don’t forget to add the virtual host name (myvhost) as an alias to localhost in /etc/hosts.

The configuration can be checked with

/opt/local/apache2/bin/apachectl -t

Starting and stopping the server is done with:

sudo port load apache2
sudo port unload apache2

PHP configuration

in /opt/local/etc/php56 copy one of the provided sample files to php.ini and adjust it, especially the date.timezone setting. To configure xdebug, add the following section to php.ini (make sure the path to xdebug.so matches the installed version):

zend_extension="/opt/local/lib/php56/extensions/no-debug-non-zts-20131226/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port="9000" 
xdebug.profiler_enable=1
xdebug.profiler_output_dir="some/output/dir"

 

Apache VirtualHost on Mac OSX

note to self:

to set up a virtual host named viho for local web development testing on OSX El Capitan (and probably earlier):

  1. define an alias name in /etc/hosts:
    127.0.0.1       localhost viho
    ::1             localhost viho
    
  2. setup the virtual host configuration file /etc/apache2/other/viho.conf:
    <VirtualHost *:80>
      DocumentRoot "/path/to/where/the/files/are"
      ServerName viho
    </VirtualHost>

browse to http://viho/ and enjoy.

Apache on Mac OSX El Capitan

Note to self:

To start or stop the Apache webserver on Mac OSX El Capitan, use the terminal:

sudo apachectl start

sudo apachectl stop

sudo apachectl restart

The configuration is found in /etc/apache2/httpd.conf. The default DocumentRoot directory is /Library/WebServer/Documents. Additional configuration files should be put in _/etc/apache2/other/*.conf_ files.

Run IntelliJ IDEA with actual Java version on OS X

With every update of IntelliJ IDEA, I stumble over this: IDEA wants to run on Java Version 6. As I don’t have this buggy outdated version on my Mac anymore, I always have to patch the config. To do this, locate the file named Info.plist in the Contents folder of the IntelliJ IDEA 14 CE.app directory. Open the file with TextEdit or any text editor of your choice and change the line

<key>JVMVersion</key>
<string>1.6*</string>

to

<key>JVMVersion</key>
<string>1.6+</string>

After that IJ will start using your default – hopefully actual – java version.

2015-06-21 Update: IntelliJ IDEA 15 EAP has it’s own custom Java8 built in, and also has the possibility to select the JDK to use when starting up. Cool.

removing the quarantine attribute

Since OSX 1.05, programs downloaded by Safari and other programs like Mail.app get an extended quarantine attribute called com.apple.quarantine. This leads to the behaviour that when starting the program, the user is asked if she really wants to start the program together with the information where the program was loaded from.

This attribute is removed once the user who downloaded the file runs the program. Another way to remove the quarantine flag is the following command (the user running this command needs to be in the sudoers file):

sudo xattr -d com.apple.quarantine /path_to_programm

MacBook Pro 2010 Crash (Nvidia)

Sometimes my MacBook Pro 2010 crashes, the crash report show problems with the nvidia driver. Sometimes it happens after waking up the systems, nut I also had crashes after a reboot during normal operation.

In the net I found the following hint, which helped me up to now:

In the directory ~/Library/Preferences/ByHost/ delete all files, that have “windowserver” in their name and reboot the computer.

shrink a sparsebundle

To shrink a dynamically growing drive image (the parameter -stdinpass is need for encrypted images):

hdiutil compact -stdinpass file.sparseimage

On a laptop running on battery power the parameter -batteryallowed is needed, otherwise there will be an error “function not implemented”.

Growl 1.3 and Skype 2.8

If you are still using Skype 2.8 and switched to Growl 1.3, you need to update the Growl framework that Skype uses. Go to the Growl download page and get the Growl SDK (1.2.2 does work, at the moment there is no 1.3 version).

Open the downloaded dmg and change to the Frameworks folder. You need to copy the Growl.framework folder into your existing Skype installation (quit Skype if it’s running).

To do this, go to your Applications directory, ctrl-klick on Skype and chose „show package contents“. Then navigate into the Contents folder and replace the existing Growl.framework with the one from the Growl SDK.

Restart Skype and it should register with Growl.

[Update 12/01/2011] The Growl Version Detective, available from the Growl Download page, does this very trick for you and as well searches for other apps that use growl and might need an update.