Month: November 2014

Setting up Zend Server for development

Having just attended ZendCon 2014 and getting my copy of Zend Server Developer Edition.  I could not wait to setup Zend Server on my workstation and start using Z-Ray, but having been a PHP developer for quite a while now, I have very specific setup I like.

My Requirements:

My first requirement is an Apple workstation, Windows just won’t cut it.  “Dude, I’m not getting a Dell”.  See Automatic /etc/hosts on Apples’ OS X to understand why.

My next requirement is a local mod_vhost_alias domain setup on port 80.  This may take some explaining; I want my local web server to automatically know where my code is based on the URL:

http://someproject.develop.dev  –> /var/htdocs/develop.dev/someproject

I also want my local DNS to work automatically (/etc/hosts):

127.0.0.1 localhost
127.0.0.1 someproject.develop.dev

See my previous post Automatic /etc/hosts on Apples’ OS X.

Checking that port 80 is not in use

First we need to make sure port 80 is not in use.

Method 1

From the terminal run:

You should see nothing, if you see something like:

You will need to find the currently running web server and turn it off.

Method 2

Open the browser to http://localhost you should get a message like “Unable to connect” (FireFox), “This webpage is not available” (Chrome) or “Safari Can’t Connect to the Server” (Safari).

If you get anything else you will need to find the currently running web server and turn it off.  See Tips and Tricks at the bottom of this post.

Reboot and run the test again.  Make sure you don’t have a web server automatically restarting when you reboot.  If you install Zend Server with another web server running you will get a conflict on port 80.

Setting up Zend Server:

After downloading Zend Server, just install as you would any other Apple application.

If you are running Yosemite, you will need to install this patch:

http://us-up.zend.com/files/Patch%20Zend%20Server%20for%20Yosemite.zip

Setup Port 80

Using your favorite text editor sudo edit the Apache config file at /usr/local/zend/apache2/conf/httpd.conf around row 40 you will find a line “Listen 10088” add “Listen 80” just below it.

Testing

From the terminal start Zend Server:

Next, open the browser to http://localhost, you should see:

Screen Shot 2014-11-01 at 8.56.49 PM

If you don’t see this you will need to troubleshoot the setup.

Setting up mod_vhost_alias:

Next, again edit the file /usr/local/zend/apache2/conf/httpd.conf and at the very bottom put:

[pastacode lang=”markup” user=”jstormes” repos=”DynamicHosts” path_id=”httpd-alias.conf” revision=”master” highlight=”” lines=”” provider=”github”/]

Testing:

Restart Zend Server:

Create a directory in /usr/local/zend/apache2/htdocs/ called develop.com.  Then create a directory in /usr/local/zend/apache2/htdocs/ called test.  Finally inside test create a directory called public.

Create a file called index.php in public with the following:

If you open your browser to http://test.develop.com you should see the PHP info page.

Tips and Tricks:

Adding user to the staff group

To start/stop all Zend Server processes run:

To start/stop Apache run:

To start/stop MySQL run:

To see all options available for zendctl.sh run:

To install PHPMyAdmin:

With all Zend Server processes running go to the http://localhost:10081/ZendServer/ url and from the getting started section select PHPMyAdmin.  Follow the instructions, PHPMyAdmin will be installed at:

To Stop the Apple Apache Server see:

Modification to .htaccess for Zend Framework

Zend Framwork 1:

Before

After

Zend Framework 2:

Before

After

Another Older Post on Setting up Zend Server

http://outlast.hu/setting-up-apache-with-zend-server-ce-for-multi-site-use/

Final thoughts:

With this setup, I can clone most websites into my development environment within seconds, cutting the time I spend setting up my development system, freeing time to do useful work.