This site is a static archive of the Aegir community site. Documentation has moved to http://docs.aegirproject.org. Other community resources can be found on the Contacting the community page.
Skip navigation

Revision of nginx / MariaDB / PHP / Aegir (MEMPÆ) from Mon, 08/12/2013 - 23:20

Help

nginx / MariaDB / PHP / Aegir (MEMPÆ)

The instructions that used to be here are using zsh, update .zshrc instead

$ nano ~/.bash_profile  
or
$ nano ~/.zshrc
  • Paste the following into editor then Ctrl+X and Y to save
    export PATH=~/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/local/git/bin:/opt/local/bin
  • Set up email sending

    • First test if you are able to email yourself
      $ date | mail -s test you@youremail.com
    • If you are on Mountain Lion you need to create and set the permissions for these directories first (for DP4 at least)

      $ sudo mkdir /Library/Server /Library/Server/Mail /Library/Server/Mail/Data /Library/Server/Mail/Data/spool /Library/Server/Mail/Data/spool/maildrop
      $ sudo chown _postfix:_postdrop /Library/Server/Mail/Data/spool/maildrop
    • I chose to set up gmail as my email relay (this may not be required for you though)
      http://realityloop.com/blog/2011/06/05/os-x-ditching-mamp-pro-part-2-gmail-email-relay
    • Mountain Lion appears to have a few bugs around this at the moment, I have to launch postfix on reboot

      $ sudo postfix start

    Step 2: Setting up dnsmasq for local wildcard DNS

    • Install dnsmasq via homebrew

      $ brew install dnsmasq
    • Copy and edit the default conf example

      $ mkdir /usr/local/etc
      $ cp /usr/local/Cellar/dnsmasq/2.61/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
      $ nano /usr/local/etc/dnsmasq.conf
    • Update the following values as shown

      resolv-file=/etc/resolv.dnsmasq.conf
      address=/.ld/127.0.0.1
      listen-address=127.0.0.1
    • Set up downstream DNS resolver

      $ sudo nano /etc/resolv.dnsmasq.conf
    • Paste the following and save using CTRL + X then Y

      # OpenDNS IPv6:
      nameserver 2620:0:ccd::2
      nameserver 2620:0:ccc::2
      # Google IPv6:
      nameserver 2001:4860:4860::8888
      nameserver 2001:4860:4860::8844
      # OpenDNS:
      nameserver 208.67.222.222
      nameserver 208.67.220.220
      # Google:
      nameserver 8.8.8.8
      nameserver 8.8.4.4
    • Copy the launch daemon so dnsmasq runs on startup, and launch it now

      $ outdated, instead of rl but it needs to end in .ld

      $ sudo scutil --set HostName rl.ld
    • Open your System Preferences, then click on Network, then for each of your interfaces (Wi-Fi & Ethernet), click on Advanced, click on DNS and finally click on the + symbol at the bottom of the left hand-side panel and set 127.0.0.1 as your only DNS Server

    Step 3: Install nginx

    nginx (pronounced “engine-x”) is a Web server and a reverse proxy server for HTTP, SMTP, POP3 and IMAP protocols, with a strong focus on high concurrency, performance and low memory usage.

    • Unless this is a fresh install of OS X you need to ensure Apache doesn't load on startup
      $ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
    • We can add some 3rd party extensions here as well (this list item is optional, if you don't want these extensions just skip to the next list item)
      $ curl -s -L -o /tmp/nginx-upload-progress.tar.gz https://github.com/masterzen/nginx-upload-progress-module/tarball/v0.9.0 && mkdir /tmp/nginx-upload-progress && tar zxpf /tmp/nginx-upload-progress.tar.gz --strip-components 1 -C /tmp/nginx-upload-progress && rm /tmp/nginx-upload-progress.tar.gz
      $ curl -s -L -o /tmp/nginx-fair.tar.gz http://github.com/gnosek/nginx-upstream-fair/tarball/master && mkdir /tmp/nginx-fair && tar zxpf /tmp/nginx-fair.tar.gz --strip-components 1 -C /tmp/nginx-fair && rm /tmp/nginx-fair.tar.gz

      Now one giant line of sed regex that will edit the Homebrew formula for nginx to add the additional compile options that we need. Make sure it all gets entered as one line.

      $ sed -i '-default' 's/\([[:space:]]*\['\''--\)\(with-webdav\)\('\'',[[:space:]]*"\)\(Compile with support for WebDAV module\)\("\]\)/\1\2\3\4\5,%\1with-realip\3Compile with support for RealIP module\5,%\1with-gzip_static\3Compile with support for Gzip Static module\5,%\1with-uploadprogress\3Compile with support for Upload Progress module\5,%\1with-fair\3Compile with support for Fair module\5,%\1with-mp4\3Compile with support for MP4 module\5,%\1with-flv\3Compile with support for FLV module\5,%\1with-stub_status\3Compile with support for Stub Status module\5/; s/\([[:space:]]* args << "--\)\(with-http_dav_module\)\(" if ARGV.include? '\''--with-\)\(webdav\)\('\''.*\)/\1\2\3\4\5%\1with-http_realip_module\3realip\5%\1with-http_gzip_static_module\3gzip_static\5%\1add-module=\/tmp\/nginx-upload-progress\3uploadprogress\5%\1add-module=\/tmp\/nginx-fair\3fair\5%\1with-http_mp4_module\3mp4\5%\1with-http_flv_module\3flv\5%\1with-http_stub_status_module\3stub_status\5/; y/%/\n/' $(brew --prefix)/Library/Formula/nginx.rb

      Now we'll install Nginx with our new build options and extensions and start it.

      $ brew install nginx --with-realip --with-gzip_static --with-mp4 --with-flv --with-stub_status --with-uploadprogress --with-fair
      $ [ $? -eq 0 ] && rm -rf /tmp/nginx-upload-progress /tmp/nginx-fair
      $ mkdir -vp $(brew --prefix nginx)/var/{microcache,log,run}
    • If you didn't use the above to install extra nginx extensions run this, otherwise skip this command
      $ brew install nginx
    • Once nginx is compiled, backup the default nginx config
      $ mv /usr/local/etc/nginx/nginx.conf /usr/local/etc/nginx/nginx.conf.bak
    • Download our config as follows
    Need help?

    Documentation

    The notebook section provides a way for you to store and share information with your group members. With the book feature you can:

    • Add book pages and organize them hierarchically into different books.
    • Attach files to pages to share them with others.
    • Track changes that others have made and revert changes as necessary.
    • Archive books that are no longer of interest to the group. Archived books can be reactivated later if needed.

    The revisions let you track differences between multiple versions of a post.