LabstaffWeb Macintosh Resources

Table of Contents

Apache via macOS Server

The Macintosh Server App is an inexpensive and very useful front end for Apache (and other services), especially for anyone who wants to create a website and test it locally before publishing. However, some of the more subtle capabilities of Apache are masked by this front-end. Here is some more info regarding administering a web server with the Macintosh Server app.

Where are the .conf files for Server configured sites?

/Library/Server/Web/Config/apache2/sites

How to set Apache to parse .html files with server side includes

Open the .conf file associated with your site in a text editor. Add the following within the block:
AddOutputFilter Includes shtml html htm php ssi
Any changes to a site's configuration through the Server app will undo this change in the conf file.


Setup Postgresql via macOS Server

Initializing psql

Postgresql binaries are located /Applications/Server.app/Contents/ServerRoot/usr/bin/

  1. Create data and log directories for Postgresql. Using your own account profile space makes it easy with filesystem permissions to create auto backup scripts using rsync.
    mkdir ~/psql/data
    mkdir ~/psql/logs
  2. Start Macintosh Automator.
  3. Choose to create an application.
  4. On left, under "Library", choose Utilities -> Run Shell Script.
  5. On right, choose "/bin/bash" for shell and "to stdin" to pass input. The script should be as follows:
    Applications/Server.app/Contents/ServerRoot/usr/bin/pg_ctl -D /Users/{user account}/psql/data -l /Users/{user account}/psql/logs/PostgreSQL.log -o "-k /var/pgsql_socket/" start
  6. Export to save an .app of this script.
  7. Add the created .app as a login item in your account profile (System Preferences -> Users & Groups) so that the script will be automatically run when you login. This way, Postgresql is up and running as soon as you login.
  8. Fix permissions to the socket lockfile folder.
    cd /var
    sudo chmod o+rw pgsql_socket
  9. Create the database hive.
    Applications/Server.app/Contents/ServerRoot/usr/bin/initdb -D /Users/{user account}/psql/data
  10. Start Postgresql with the script command mentioned in step #4. This can be done on the command line.

Postgresql extension for PHP

PHP included with macOS does not have the requisite extension to communicate with Postgresql provided by server.app. These instructions will install the extension using Macports, which is easier than recompiling PHP.
  1. On Yosemite (10.10) or later, turn off System Integrity Protection.
    • Reboot into the system recovery (CMD-R during bootup).
    • In a terminal type:
      csrutil disable
      reboot
    • Don't forget to re-enable System Integrity Protection after the pgsql extension is fully installed.
  2. Determine what major version of PHP that your Mac has. e.g. macOS Sierra (10.12) ships with PHP 5.6.
    php --version
  3. Using Macports, install the pgsql extension that matches your PHP version. Assuming PHP 5.6:
    sudo port install php56-postgresql
  4. After the extension is installed by Macports, first locate where the extension files.
    • There should be a php folder in /opt/local/lib matching your PHP version. e.g. /opt/local/lib/php56/
    • Next, there should be an extensions folder, and that contains a folder named no-debug-non-zts-yyyymmdd
    • The yyyymmdd portion refers to the date release of PHP. e.g. PHP 5.6 should have no-debug-non-zts-20131226.
    • Note this location and the two files pgsql.so and pdo_pgsql.so. You will create softlinks to these two files.
  5. macOS's shipped PHP will have a similar no-debug-non-zts-yyyymmdd folder in /usr/lib/php/extensions/
  6. in Terminal, create the softlinks to the Macport installed files. Still assuming PHP 5.6:
    sudo bash
    cd /usr/lib/php/extensions/no-debug-non-zts-20131226
    ln -s /opt/local/lib/php56/extensions/no_debug-non-zts-20131226/pgsql.so .
    ln -s /opt/local/lib/php56/extensions/no_debug-non-zts-20131226/pdo_pgsql.so .
  7. Activate the extensions in php.ini
    • php.ini is located in /etc.
      cd /etc
      sudo nano php.ini
    • Add the following lines to the ini file (they can go right at the top)
      extension=pgsql.so
      extension=pdo_pgsql.so
  8. Restart apache
    apachectl restart
  9. Don't forget to re-enable Systems Integrity Protection as referenced in step #1.


Discontinued Security Updates OS X / macOS

Apple has discontinued issuing security updates for all versions of OS X 10.9 Mavericks and older. Anyone still using any of these older operating systems remains exposed to unpatched digital threats, and should consider updating to a newer macOS. macOS 10.12 Sierra is free from the Macintosh App Store. Check here for minimum system requirements.

64-bit EFI

The latest macOS requires a 64-bit EFI. To check if your EFI is EFI32 or EFI64, run this command in the terminal:

ioreg -l -p IODeviceTree | grep firmware-abi

Should you have a (very) old Macintosh that reports EFI32, the latest operating system you can run is OS X 10.7 Lion, and therefore you should consider buying a new Macintosh computer as soon as possible. Yosemite, El Capitan, and Sierra must have a 64-bit EFI.


X11 / Matlab by Remote

If you want to use remote applications with X forwarding (e.g. ssh -Y user@server), such as Matlab, you need X11 software installed.
See below for link.


Useful Software

Software Location Notes
X11 https://xquartz.macosforge.org/landing Required for X forwarding via SSH (i.e. Matlab)
VirtualBox https://www.virtualbox.org/wiki/Downloads Free to use Virtual Machine software
The Gimp http://gimp.lisanet.de/Website/Download.html Image editing software
Audacity http://audacity.sourceforge.net/ Audio editing software
Latex, Mactex http://www.tug.org/mactex Latex for Mac
Libre Office https://www.libreoffice.org/download/libreoffice-fresh Fork of Open Office that is well maintained
Text Wrangler http://www.barebones.com/products/textwrangler/download.html Excellent light-weight text/code editor
The Unarchiver http://wakaba.c3.cx/s/apps/unarchiver Extract files from compressed formats not natively supported by Mac, like RAR and 7z
Mac Ports http://www.macports.org Command line tool to retrieve/compile open source software (requires Xcode*)
0xED http://www.suavetech.com/0xed/0xed.html Hex editor

*Xcode is available from the Macintosh app store.


-- JoeyArmstrong - 28 Apr 2009
-- PeterBailie - 21 Nov 2016
Topic revision: r15 - 21 Nov 2016, PeterBailie
 

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback