Getting Started

Go to the App Store and install XCode. Once it's installed, start the program, just so you can accept the license and then quit.

Procedure

Install Homebrew (http://brew.sh/). Instructions for how to do this are on the Homebrew webpage. This is software that will let us easily install both php and apache. Below is the output for when I installed it.

          mac:~ hep$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
          ==> This script will install:
          /usr/local/bin/brew
          /usr/local/Library/...
          /usr/local/share/man/man1/brew.1

          Press RETURN to continue or any other key to abort
          ==> /usr/bin/sudo /bin/mkdir /usr/local

          WARNING: Improper use of the sudo command could lead to data loss
          or the deletion of important system files. Please double-check your
          typing when using sudo. Type "man sudo" for more information.

          To proceed, enter your password, or type Ctrl-C to abort.

          Password:
          ==> /usr/bin/sudo /bin/chmod g+rwx /usr/local
          ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local
          ==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew
          ==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
          ==> Downloading and installing Homebrew...
          remote: Counting objects: 240733, done.
          remote: Compressing objects: 100% (8/8), done.
          remote: Total 240733 (delta 3), reused 1 (delta 1), pack-reused 240724
          Receiving objects: 100% (240733/240733), 34.01 MiB | 7.19 MiB/s, done.
          Resolving deltas: 100% (179217/179217), done.
          From https://github.com/Homebrew/homebrew
           * [new branch]      master     -> origin/master
          HEAD is now at 436a759 cidrmerge: add 1.5.3 bottle.
          ==> Installation successful!
          ==> Next steps
          Run `brew help` to get started
          mac:~ hep$ 
        

Now that we have homebrew installed, we'll use that to install php.

          mac:~ hep$ brew install homebrew/php/php56
          Cloning into '/usr/local/Library/Taps/homebrew/homebrew-php'...
          remote: Counting objects: 8380, done.
          remote: Total 8380 (delta 0), reused 0 (delta 0), pack-reused 8380
          Receiving objects: 100% (8380/8380), 1.72 MiB | 0 bytes/s, done.
          Resolving deltas: 100% (5598/5598), done.
          Checking connectivity... done.
          Tapped 446 formulae
          ==> Installing php56 from homebrew/homebrew-php
          Cloning into '/usr/local/Library/Taps/homebrew/homebrew-dupes'...
          remote: Counting objects: 1617, done.
          remote: Total 1617 (delta 0), reused 0 (delta 0), pack-reused 1617
          Receiving objects: 100% (1617/1617), 324.80 KiB | 0 bytes/s, done.
          Resolving deltas: 100% (894/894), done.
          Checking connectivity... done.
          Tapped 39 formulae
          ==> Installing dependencies for php56: libpng, freetype, gettext, homebrew/dupes/zlib, icu4c, jpeg, openssl, unixodbc
          ==> Installing php56 dependency: libpng
          ==> Downloading https://homebrew.bintray.com/bottles/libpng-1.6.16.yosemite.bottle.tar.gz
          ######################################################################## 100.0%
          ==> Pouring libpng-1.6.16.yosemite.bottle.tar.gz
          🍺  /usr/local/Cellar/libpng/1.6.16: 17 files, 1.3M
          ==> Installing php56 dependency: freetype
          ==> Downloading https://homebrew.bintray.com/bottles/freetype-2.5.5.yosemite.bottle.tar.gz
          ######################################################################## 100.0%
          ==> Pouring freetype-2.5.5.yosemite.bottle.tar.gz
          🍺  /usr/local/Cellar/freetype/2.5.5: 60 files, 2.6M
          ==> Installing php56 dependency: gettext
          ==> Downloading https://homebrew.bintray.com/bottles/gettext-0.19.4.yosemite.bottle.tar.gz
          ######################################################################## 100.0%
          ==> Pouring gettext-0.19.4.yosemite.bottle.tar.gz
          ==> Caveats
          This formula is keg-only, which means it was not symlinked into /usr/local.

          Mac OS X provides similar software, and installing this software in
          parallel can cause all kinds of trouble.

          OS X provides the BSD gettext library and some software gets confused if both are in the library path.

          Generally there are no consequences of this for you. If you build your
          own software and it requires this formula, you'll need to add to your
          build variables:

              LDFLAGS:  -L/usr/local/opt/gettext/lib
              CPPFLAGS: -I/usr/local/opt/gettext/include

          ==> Summary
          🍺  /usr/local/Cellar/gettext/0.19.4: 1920 files,  21M
          ==> Installing php56 dependency: homebrew/dupes/zlib
          ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/dupes/zlib-1.2.8.yosemite.bottle.tar.gz
          ######################################################################## 100.0%
          ==> Pouring zlib-1.2.8.yosemite.bottle.tar.gz
          ==> Caveats
          This formula is keg-only, which means it was not symlinked into /usr/local.

          Mac OS X already provides this software and installing another version in
          parallel can cause all kinds of trouble.

          Generally there are no consequences of this for you. If you build your
          own software and it requires this formula, you'll need to add to your
          build variables:

              LDFLAGS:  -L/usr/local/opt/zlib/lib
              CPPFLAGS: -I/usr/local/opt/zlib/include

          ==> Summary
          🍺  /usr/local/Cellar/zlib/1.2.8: 9 files, 392K
          ==> Installing php56 dependency: icu4c
          ==> Downloading https://homebrew.bintray.com/bottles/icu4c-54.1.yosemite.bottle.1.tar.gz
          ######################################################################## 100.0%
          ==> Pouring icu4c-54.1.yosemite.bottle.1.tar.gz
          ==> Caveats
          This formula is keg-only, which means it was not symlinked into /usr/local.

          Mac OS X already provides this software and installing another version in
          parallel can cause all kinds of trouble.

          OS X provides libicucore.dylib (but nothing else).

          Generally there are no consequences of this for you. If you build your
          own software and it requires this formula, you'll need to add to your
          build variables:

              LDFLAGS:  -L/usr/local/opt/icu4c/lib
              CPPFLAGS: -I/usr/local/opt/icu4c/include

          ==> Summary
          🍺  /usr/local/Cellar/icu4c/54.1: 242 files,  65M
          ==> Installing php56 dependency: jpeg
          ==> Downloading https://homebrew.bintray.com/bottles/jpeg-8d.yosemite.bottle.2.tar.gz
          ######################################################################## 100.0%
          ==> Pouring jpeg-8d.yosemite.bottle.2.tar.gz
          🍺  /usr/local/Cellar/jpeg/8d: 18 files, 776K
          ==> Installing php56 dependency: openssl
          ==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2a-1.yosemite.bottle.tar.gz
          ######################################################################## 100.0%
          ==> Pouring openssl-1.0.2a-1.yosemite.bottle.tar.gz
          ==> Caveats
          A CA file has been bootstrapped using certificates from the system
          keychain. To add additional certificates, place .pem files in
            /usr/local/etc/openssl/certs

          and run
            /usr/local/opt/openssl/bin/c_rehash

          This formula is keg-only, which means it was not symlinked into /usr/local.

          Mac OS X already provides this software and installing another version in
          parallel can cause all kinds of trouble.

          Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

          Generally there are no consequences of this for you. If you build your
          own software and it requires this formula, you'll need to add to your
          build variables:

              LDFLAGS:  -L/usr/local/opt/openssl/lib
              CPPFLAGS: -I/usr/local/opt/openssl/include

          ==> Summary
          🍺  /usr/local/Cellar/openssl/1.0.2a-1: 463 files,  18M
          ==> Installing php56 dependency: unixodbc
          ==> Downloading https://homebrew.bintray.com/bottles/unixodbc-2.3.2_1.yosemite.bottle.1.tar.gz
          ######################################################################## 100.0%
          ==> Pouring unixodbc-2.3.2_1.yosemite.bottle.1.tar.gz
          🍺  /usr/local/Cellar/unixodbc/2.3.2_1: 31 files, 1.0M
          ==> Installing php56
          ==> Downloading https://homebrew.bintray.com/bottles-php/php56-5.6.7.yosemite.bottle.tar.gz
          ######################################################################## 100.0%
          ==> Pouring php56-5.6.7.yosemite.bottle.tar.gz
          ==> Caveats
          To enable PHP in Apache add the following to httpd.conf and restart Apache:
              LoadModule php5_module    /usr/local/opt/php56/libexec/apache2/libphp5.so

          The php.ini file can be found in:
              /usr/local/etc/php/5.6/php.ini

          ✩✩✩✩ PEAR ✩✩✩✩

          If PEAR complains about permissions, 'fix' the default PEAR permissions and config:
              chmod -R ug+w /usr/local/Cellar/php56/5.6.7/lib/php
              pear config-set php_ini /usr/local/etc/php/5.6/php.ini system

          ✩✩✩✩ Extensions ✩✩✩✩

          If you are having issues with custom extension compiling, ensure that
          you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:

                PATH="/usr/local/bin:$PATH"

          PHP56 Extensions will always be compiled against this PHP. Please install them
          using --without-homebrew-php to enable compiling against system PHP.

          ✩✩✩✩ PHP CLI ✩✩✩✩

          If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc,
          ~/.zshrc, ~/.profile or your shell's equivalent configuration file:

                export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"

          ✩✩✩✩ FPM ✩✩✩✩

          To launch php-fpm on startup:
              mkdir -p ~/Library/LaunchAgents
              cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/
              launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

          The control script is located at /usr/local/opt/php56/sbin/php56-fpm

          OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH:

            PATH="/usr/local/sbin:$PATH"

          You may also need to edit the plist to use the correct "UserName".

          Please note that the plist was called 'homebrew-php.josegonzalez.php56.plist' in old versions
          of this formula.

          To have launchd start php56 at login:
              mkdir -p ~/Library/LaunchAgents
              ln -sfv /usr/local/opt/php56/*.plist ~/Library/LaunchAgents
          Then to load php56 now:
              launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
          ==> Summary
          🍺  /usr/local/Cellar/php56/5.6.7: 500 files,  51M
        

Next step is to use homebrew to install our webserver, which is apache.

            mac:~ hep$ brew install homebrew/apache/httpd24
            Cloning into '/usr/local/Library/Taps/homebrew/homebrew-apache'...
            remote: Counting objects: 632, done.
            remote: Total 632 (delta 0), reused 0 (delta 0), pack-reused 632
            Receiving objects: 100% (632/632), 150.05 KiB | 0 bytes/s, done.
            Resolving deltas: 100% (400/400), done.
            Checking connectivity... done.
            Tapped 11 formulae
            ==> Installing httpd24 from homebrew/homebrew-apache
            ==> Installing dependencies for httpd24: apr, apr-util, pcre
            ==> Installing httpd24 dependency: apr
            ==> Downloading https://homebrew.bintray.com/bottles/apr-1.5.1.yosemite.bottle.tar.gz
            ######################################################################## 100.0%
            ==> Pouring apr-1.5.1.yosemite.bottle.tar.gz
            ==> Caveats
            This formula is keg-only, which means it was not symlinked into /usr/local.

            Mac OS X already provides this software and installing another version in
            parallel can cause all kinds of trouble.

            Apple's CLT package contains apr.
            ==> Summary
            🍺  /usr/local/Cellar/apr/1.5.1: 54 files, 1.4M
            ==> Installing httpd24 dependency: apr-util
            ==> Downloading https://homebrew.bintray.com/bottles/apr-util-1.5.4.yosemite.bottle.tar.gz
            ######################################################################## 100.0%
            ==> Pouring apr-util-1.5.4.yosemite.bottle.tar.gz
            ==> Caveats
            This formula is keg-only, which means it was not symlinked into /usr/local.

            Mac OS X already provides this software and installing another version in
            parallel can cause all kinds of trouble.

            Apple's CLT package contains apr.
            ==> Summary
            🍺  /usr/local/Cellar/apr-util/1.5.4: 47 files, 820K
            ==> Installing httpd24 dependency: pcre
            ==> Downloading https://homebrew.bintray.com/bottles/pcre-8.36.yosemite.bottle.tar.gz
            ######################################################################## 100.0%
            ==> Pouring pcre-8.36.yosemite.bottle.tar.gz
            🍺  /usr/local/Cellar/pcre/8.36: 146 files, 5.9M
            ==> Installing httpd24
            ==> Downloading https://archive.apache.org/dist/httpd/httpd-2.4.12.tar.bz2
            ######################################################################## 100.0%
            ==> ./configure --enable-layout=Homebrew --enable-mods-shared=all --enable-unique-id --enable-ssl --enable-dav --enable-cach
            ==> make
            ==> make install
            ==> Caveats
            To have launchd start httpd24 at login:
                mkdir -p ~/Library/LaunchAgents
                ln -sfv /usr/local/opt/httpd24/*.plist ~/Library/LaunchAgents
            Then to load httpd24 now:
                launchctl load ~/Library/LaunchAgents/homebrew.mxcl.httpd24.plist
            ==> Summary
            🍺  /usr/local/Cellar/httpd24/2.4.12: 209 files, 4.5M, built in 3.1 minutes
          

Now start the Apache webserver and see if it works.

              mac:~ hep$ sudo /usr/sbin/apachectl start
            

Open a web browser and go to page http://localhost. You should see the following.

screenshot of It works

As long as you get the 'It works' message, apache is running correctly. There are two changes though that we need to make to the default config file. Since most of our sites use php on the webpages, we need to edit the apache config file to make sure that it processes the php files correctly. And we need to tell it to run the apache program as the current user.

              mac:~ hep$ sudo vi /etc/apache2/httpd.conf
              Then press / to do a search, type php and press enter.  This should take you to a line like this:

              #LoadModule php5_module libexec/apache2/libphp5.so

              You need to uncomment the line, so use the arrow keys to position the cursor over the # and press the letter x. 
              (If you actually type an x here, press backspace, then the Escape key and then press x.)  So it should look 
              like this:

              LoadModule php5_module libexec/apache2/libphp5.so

              About 10-20 lines below the php line, are two lines that look like this:

              User _www
              Group _www

              Change these lines to the name and group of the current user.  The default group is usually staff, and in our 
              case our username is hep.  So I changed this to:

              User hep
              Group staff

              Then save the file, by typing :wq which will write and quit the file.
            

Restart the apache webserver and you'll be able to view php files correctly. (We'll check later.)

              mac:~ hep$ /usr/sbin/apachectl restart
            

For this example, we're going to duplicate the website with a list of glass parts. The website that people would visit would be http://glass.example.com. However, that's just a cname. The computer that actually has the files on it is cdfs3.example.com.

Start Dreamweaver and click on the Sites menu choice. Select New Site. For our example, we'd fill in the window as below.

Screenshot of new site window

On our computer, we're going to store the files in the /Users/hep/Documents/websites/glass directory.

Next click on the Servers choice and fill in the window as is necessary for you. On our servers, we don't allow plain FTP, so we have to change the "Connect using" choice to SFTP. Fill in the username that you'll use to login as and the password. The root directory needs to be where on the server (in our case cdfs3.example.com) are the files located.

screenshot of server information

Click the "Test" button to make sure you can connect to the server. If everything works as expected, you should see this:

screenshot of successful login

If you're ok, save everything and close the Site window. Now we want to get a copy of the files currently on the server to our computer. You'll see and move files in Dreamweaver with the Files panel. It's usually located on the right side of the screen. If you don't see it there, go to Window - Files to bring it up.

screenshot of files panel

The files panel is really helpful. It will let you see the files on both the remote server and your local computer. To do that, you need to expand the window. The button circled in yellow below is the one to change the view. Click that to get your Files panel to look like the one below.

screenshot of files panel expanded

The button circled in green is the one to connect to the server. You'll want to click that one to login to the server to see your current files.


Now we just need to tell our web server where your directory is that is holding the files to serve. You can edit the httpd.conf file to give it the location, but I think it's easier to just make a link to point to the location. Open a terminal and type the following:

              mac:~ hep$ cd /Library/WebServer
              mac:~ hep$ sudo mv Documents Documents.ORIG
              mac:~ hep$ sudo ln -s /Users/hep/Documents/websites/glass Documents
            

The last thing we need to do is check that php is working. A very simple way to do this is to create a new PHP file in Dreamweaver. Inside the body tags, just add this line:

 <? phpinfo(); ?>

Save this file as check.php. Then go to http://localhost/check.php and see if you get a page that has a lot of information about your php setup. If you just get a blank page, then php isn't working. Most likely the reason is that you either didn't uncomment the php module in your httpd.conf file or you didn't restart apache after making this change.

Once we have all of this set up, you are ready to work. If you don't already have a copy of the files on the server on your computer, click the top folder on the remote server and then click the down arrow. This will "download" all of the files from the server to your laptop. Then, double-click on a local file to open it for editing. After you save this file, open a browser and go to http://localhost to view your changes. Once you're happy with the new pages, go back to the Files window, highlight your new files and click the up button to "upload" them to the server.

Mary Heintz, April 2015