Just because the entire exercise has driven me to madness (almost) where I was wishing I could literally do a table flip and none of my stuff will be broken. At 3AM. I’m afraid my neighbors think someone’s getting slaughtered at my apartment.
Anyhoo! So, you want to run your PHP app locally, eh? You’re in a for a ride! It may include hair pulling and a little bit of screaming – so I suggest you keep your scream jar nearby.
First, I hope you’re pretty familiar with the terminal; and if you haven’t already, you should create a shortcut so you can open sublime through the command line, makes everything so much easier.
Start with this pretty vague tutorial on running pow with apache and know that it may not just stop there.
If that didn’t work for you, time to get down and dirty! Open your apache2 folder in sublime by typing
sudo sublime /etc/apache2 it should show all of the files and folders within apache2. If you open your
other folder, you should see the
zzz_pow.conf file that was created earlier.
Note: if you want to see any changes in your localhost, you should always do a
sudo apachectl restart
Moving on, open
httpd.conf then go to line 118, uncomment that line to activate the PHP module so it should look like this:
LoadModule php5_module libexec/apache2/libphp5.so
Some tutorials will want you to uncomment
Include /private/etc/apache2/extra/httpd-vhosts.conf which will make your virtual hosts file readable by the server, but I prefer to be on the safe side. While doing this darn thing, I had to remember which files I had to edit and what I did to them, so I prefer to have my changes to be in the same folder, in this case it’s all in the
other folder. It will all be read anyway! Make sure that your
httpd.conf's last line is:
Create a new file within the
other folder called
aaa_default.conf (keeping with the original pow tutorial). This will contain your virtual host code(s) that may look something like this:
<VirtualHost *:80> ServerName project.dev ServerAlias www.project.dev DocumentRoot "/Users/username/Sites/project" ErrorLog "/private/var/log/apache2/project.com-error_log" CustomLog "/private/var/log/apache2/project.com-access_log" common ServerAdmin firstname.lastname@example.org <Directory "/Users/username/Sites/project"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> <VirtualHost *:80> #no need for settings, use apache defaults. </VirtualHost>
Replace ‘project’ with your actual project name and username with your account username. Remember that since we already did this, there’s no need for you to create a symlink in your
.pow folder. It’s not as nice and simple as the symlink but if it does the job… well…
Next, create another file called
php5.conf or whatever) which will contain a piece of code that will tell the server that whatever file that has the extension .php should be executed and not displayed as text.
<IfModule php5_module> AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps <IfModule dir_module> DirectoryIndex index.html index.php </IfModule> </IfModule>
If you got this error:
SQLSTATE[HY000]  No such file or directory
Open your /etc/php.ini in sublime and look for
pdo_mysql.default_socket. Mine was located in line 986 and it didn’t have any value. Just append
=/tmp/mysql.sock so it will be like this:
Restart your apache server, hopefully, for the last time and your local PHP app should be available in http://project.dev!
If welder bros still didn’t work, like mine, open your hosts file (
/etc/hosts) with sublime (don’t forget to sudo!) and add
localhost, and ta-da! Your PHP is running with pow!
It’s as easy as 10 million steps and lots of bashing! Enjoy! :)