Working Ninja
2014-09-14T17:46:50

The following command is for an Apache setup with multiple vhosts:
tail -f /var/www/vhosts/*/statistics/logs/access_log | grep 'wp-login'

tail -f outputs the end of the log file and updates any new content to the screen as the file is being updated, thus allowing real-time monitoring.

I use this command when fail2ban tips me off to a brute-force attack in progress. This gives me the domain(s) that are getting hit and allows me to monitor the site more closely.

2014-04-06T17:43:00

If I have my choice of workflow, here is what it currently includes (note: this is subject to change as there are tons of awesome people developing for the web):

The Cradle of Creation: The Development Server

First off, all creation and changes are made on the development server so that users won’t be subject to slow server responses, random 404s, coding errors or unstyled content.

Tools Used:

  • Version Control: Git local repository
  • Environment: Local MAMP server (see more about this on my MAMP Development Server Setup)
  • Editor: Light Table
  • Debugging: Chrome DevTools

To the Production Server!

After all is as it should be on the development server, changes will be committed (along the way, of course!) and made ready for the production server. Local git repository is pushed to the production server using git.

Testing on production server (with caching turned off) would then take place to verify no issues with latest update.

Worthy to note previous tools used:

Editors

  • TextMate
  • TextWrangler
  • Sublime Text
  • Coda 2
  • Atom
  • Brackets

Version Control

  • Subversion (SVN)
2014-04-05T17:40:11

Here’s the lowdown on how I setup my MAMP (Mac, Apache, MySQL and PHP) server for local web development and the steps I went through to create a development environment for a site already in production.

Configuring Apache

Apache comes preinstalled with OS X so I decided to stick with it in an effort to save time. Apache, though, thought it would rally around my optimism and not allow me to access the default DocumentRoot (~/user). After trying another directory inside my user folder I recalled clamping down permissions on my user folder which would have denied access to _www. Instead of adding back permissions, I decided to move DocumentRoot outside of ~/user and moved it to /Sites. Voilà!

Also, by default, the bind address inside httpd.conf is set to all IP Addresses available on your machine. I disabled this by binding the url to only 127.0.0.1 so that I wouldn’t have anyone snooping around my development sites at the coffee shop =)

Enabling PHP

Enabling PHP was probably the easiest part of the setup. All that was required here was to uncomment the following line in httpd.conf:
#LoadModule php5_module libexec/apache2/libphp5.so

Install and Configure MySQL

Installed MySQL Community Server.
Started MySQL via System Preference pane.
(Note: for increased security, don’t allow MySQL to accept incoming connections).

Install and Configure phpMyAdmin

To administer MySQL, I decided to install phpMyAdmin. I had an issue with MySQL’s config directory not being writable even though permissions were set correctly. I found that others had had the same issue and were able to get around this by manually creating the config.inc.php file. I was also able to get around the config directory error but, alas, the next hurdle was before me.

I was now presented with ‘unable to log into phpMyAdmin (root login w/o password not allowed)’. Fairly straightforward, I set the root password for MySQL and also set config.inc.php to use 127.0.0.1 instead of localhost (to match DocumentRoot in httpd.conf).

Database Creation + Export from Production + Import for Development

With phpMyAdmin properly setup, I created a new database and user (from wp-config.php) to house a copy of the production database.

At the production end, I exported the production database and then imported to development environment. With WordPress files and database now in place, I loaded up the login page. And yes, a few things left to configure =)

Troubleshoot WordPress Issues

Unable to login
Needed to update siteurl and home in wp_options table to reflect change of address (e.g. http://domain.name is now http://127.0.0.1/domain.name).

mysql.sock error
I also received a mysql.sock error which was resolved by updating the hostname in wp-config.php to 127.0.0.1 from localhost (same as phpMyAdmin).

Unable to access pages other than index
Found that WordPress permalinks aren’t working (for pages). Created .htaccess file but no change and gave _www 660 permissions (PHP can now write to .htaccess through Apache). Also needed to set AllowOverwrite All in httpd.conf to allow .htaccess.

My process could more than likely be improved but I sure did learn a lot along the way.

2014-04-04T17:31:34

I’ve enjoyed building websites for over a decade and have never kept a log of what I’ve learned. There are three reasons for wanting to start this blog.

  1. To share what I have been learning with others.
  2. To have a reference to go back to.
  3. To show a future client or employer what I have experience doing.

Also, since I worked a non-web-related job the past few years, I feel like I have lost touch with a lot of the changes HTML5, CSS3, mobile devices and responsive design have brought along. I’m pretty excited to blog about what I find (or shown to me by friends) and how I’m using that in my projects.