Zen PHP Development Installation and Setup on a Mac

First of all: What is Zen?

The Mac as a development platform

Setting up Linux

Terminal

Sudo and Nano

sudo nano -w

Setting up Apache

httpd -v
Server version: Apache/2.4.23 (Unix)
Server built: Aug 8 2016 16:31:34
whoami
sudo nano -w /etc/apache2/httpd.conf
  • myuser is you user name, as you took note of before,
  • address@yoursite.com is a real e-mail address you own,
  • /path/to/yoursite is the full path where your local Web site files are.
User myuser
LoadModule php5_module libexec/apache2/libphp5.so
ServerAdmin address@yoursite.com
DocumentRoot "/path/to/yoursite"
Options None
<Directory />
Options None
AllowOverride None
Order Allow,Deny
Deny from All
</Directory>
<Directory /path/to/yoursite>
Options ExecCGI IncludesNOEXEC SymLinksIfOwnerMatch
AllowOverride All
<IfVersion >= 2.4>
Require all granted
Satisfy all
</IfVersion>
Order Allow,Deny
Allow from All
</Directory>
sudo apachectl restart

.htaccess

AccessFileName .htaccess !htaccess<FilesMatch "^[.!]([Hh][Tt]|[Dd][Ss]_[Ss])">
Require all denied
</FilesMatch>

Setting up MySQL

The MySQL Preferences pane

Setting up PHP

xcode-select --install
ls /usr/lib/php/extensions/
sudo nano -w /etc/php.ini
pdo_mysql.default_socket = /tmp/mysql.sock
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock
zend_extension="/usr/lib/php/extensions/zts-directory/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.extended_info=1
; Disable features to speed up Xdebug and PHP:
xdebug.coverage_enable=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.trace_enable_trigger=0
php -v

PEAR and PECL

sudo php /usr/lib/php/install-pear-nozlib.phar
pear config-set php_ini /etc/php.ini
pecl config-set php_ini /etc/php.ini

PHPDocumentor

sudo pear channel-discover pear.phpdoc.org
sudo pear install phpdoc/phpDocumentor-alpha

Setting up the ability to send e-mail messages

sudo nano -w /etc/aliases
Editing /etc/aliases
sudo newaliases
sudo nano -w /etc/postfix/main.cf
queue_directory = /var/spool/postfix
data_directory = /var/lib/postfix
smtp_generic_maps = hash:/etc/postfix/generic
hostname
sudo nano -w /etc/postfix/generic
@mymac.home             address@yoursite.com
@mymac.local address@yoursite.com
@mymac.localdomain address@yoursite.com
@mymac address@yoursite.com
@localhost address@yoursite.com
@localhost.local address@yoursite.com
@localhost.localdomain address@yoursite.com
@localdomain.local address@yoursite.com
@localdomain address@yoursite.com
sudo postmap /etc/postfix/generic
sudo postfix check
sudo nano -w /System/Library/LaunchDaemons/org.postfix.master.plist
<string>/var/spool/postfix/maildrop</string>
<string>/var/spool/postfix/active</string>
<string>/var/spool/postfix/deferred</string>
sudo launchctl unload  /System/Library/LaunchDaemons/org.postfix.master.plistsudo launchctl load -w /System/Library/LaunchDaemons/org.postfix.master.plist

One last thing…

local.yoursite.com

cat /etc/hosts
  • Lines beginning with # are comments
  • Empty lines are ignored
  • Remaining lines must have an IP (v4) number followed by a domain name, and map that domain name to that IP
sudo nano -w /etc/hosts
127.0.0.1 local.yoursite.com
sudo nano -w /etc/apache2/httpd.conf
  • address@yoursite.com is a real e-mail address you own,
  • /path/to/yoursite is the full path where your local Web site files are.
<VirtualHost *:80>
ServerName local.yoursite.com
ServerAdmin "address@yoursite.com"
DocumentRoot "/path/to/yoursite"
Options +ExecCGI
php_admin_value open_basedir "/path/to/yoursite/:/tmp/"
php_admin_value sendmail_from "address@yoursite.com"
php_admin_value user_agent "PHP @ local.yoursite.com"
<Directory /path/to/yoursite>
Options ExecCGI IncludesNOEXEC SymLinksIfOwnerMatch
AllowOverride All
<IfVersion < 2.4>
Order Allow,Deny
Allow from All
</IfVersion>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
</Directory>
</VirtualHost>
sudo apachectl restart

Ta-da!

--

--

--

Engineering Lead at Farfetch

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

SLOConf 2022

#Envisioning a New Age of Empathy

Deny Rules! Fine-Grained Kubernetes Access Controls with Kyverno

Tips and ideas for experimenting with new apps in Mendix’s free sandbox environment

Kong: The API Gateway disruptor

GraphQL Fragments are amazing!

Misconceptions about Parser

Parameters and Argument

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pedro Freire

Pedro Freire

Engineering Lead at Farfetch

More from Medium

A simple PHP site (4/?)— Routing

How To Debug Wordpress Using XDebug and Visual Studio Code

PHP Basics : Comparison operators

An Example of TDD Cycle With PHP