Monthly Archives: October 2014

Fix Apache broken after OS X Yosemite update

I could call it OS X tradition, Apple again broke the Apache 2 installation with latest OS X Yosemite upgrade. Let’s see how you can fix that and bring your local Apache2, PHP5 and MySQL development environment back.

I did very naive thing and just started the Apache 2 using sudo apachectl start . It worked, I got “It works!” page but nothing more. Then I reviewed Rob Allen’s article about setting up PHP & MySQL on Yosemite. He described steps on setting that on clean install but I needed to go through different steps as I had everything already installed. However, the article was helpful as it covered a few parts of the process.

If you have Apache 2 already installed, these steps can help you to go through to make it working again:

Update Apache 2 configuration

1. Uncomment Virtual Hosts line in Apache2 config (/etc/apache2/httpd.conf ) if you use that file to configure all hosts:

Include /private/etc/apache2/extra/httpd-vhosts.conf

2. Change Access Control block in httpd.conf as it has changed in new Apache 2.4:

AllowOverride All
Require all granted

3. Uncomment following lines to enable mod_rewrite and PHP5:

LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so

4. Restart apache:

sudo apachectl restart

After doing these steps my local sites started working again along with PHP5. However, Yosemite upgrade also removed custom extensions and at least Xdebug and Mcrypt were missing.

Reinstall Homebrew

I wanted to follow Rob’s guide regarding Mcrypt in which he used a Homebrew. Unfortunately the Homebrew didn’t worked for me as I didn’t upgrade that before upgrading OS X to Yosemite. I reinstalled the Homebrew then:

1. Remove old Homebrew

sudo rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup

2. Install latest one

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3.Run brew doctor

brew doctor

It came with a few recommendations. I fixed some of them, then I did the last one which was upgrading Xcode to 6.1. Actually Rob mentioned that in the article but I missed that part. It’s the following package:

https://developer.apple.com/downloads/download.action?path=Developer_Tools/xcode_6.1/xcode_6.1.dmg

Remember to run Xcode ater upgrading, it can save a lot of time later. I didn’t run that and I couldn’t get Mcrypt PHP extension installation working. After installing and running Xcode you also need to install Xcode command line tools. Run following in console to do so:

xcode-select --install

When Brew and Xcode are on their place, proceed to a Mcrypt installation.

Install Mcrypt

That part comes from Rob Allen’s post mentioned earlier.

1. Install Mcrypt using brew:

brew install mcrypt

2. Prepare for PHP extension installation

Run following commands:

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/php

I haven’t been able to run successfully some of these commands on my local. I needed to follow recommendations mentioned in commands output eg. to clean some symlinks, install some other packages using brew install, etc.

When  these repositories are added, edit one broken file and apply patch:

/usr/local/Library/Taps/homebrew/homebrew-php/Abstract/abstract-php-extension.rb

3. Install PHP extension:

brew install php55-mcrypt --without-homebrew-php

4. Enable PHP extension:

sudo mkdir -p /Library/Server/Web/Config/php
sudo ln -s /usr/local/etc/php/5.5/conf.d/ext-mcrypt.ini /Library/Server/Web/Config/php/ext-mcrypt.ini

Then restart apache again and mcrypt should work properly.

I’m really happy I made my development environment working after Yosemite upgrade. I also realized what should be the next step – I should get rid of MacPorts leftovers and make sure everything is installed using one package manager.

I hope these steps and Rob’s article can help you in fixing OS X web development environment.

Bring a lot of customers to Magento store… using n98-magerun

Recently I talked about my favourite n98-magerun commands, this time I’ll continue that topic. Let’s see how to easily add a lot of customers to a Magento store. Of course it’s about adding fake data for testing purposes, unfortunately n98-magerun doesn’t help in bringing real ones :-)

Command customer:create:dummy allows you to create dummy customer accounts for testing purposes. It supports a few different locales and allows to generate any amount of accounts.

$ n98-magerun.phar customer:create:dummy 1000 pl_PL
[…]
Please select a website: 1

It took about 13 minutes to create 1000 customers, so it is able to fill a database with thousands of customers in a few hours. Sample output looks as follows:

Customer wieczorek.julia.152196@example.org with password QAELhMP! successfully created
Customer fabian.291162@example.net with password 8grCBZ9$ successfully created
Customer emil.108200@example.com with password ARWRJALy successfully created
[…]

Internally it uses https://github.com/fzaninotto/Faker. That library allows it to generate other assets like texts (either lorem ipsum or more real ones), addresses, phone numbers, companies, date and times, internet accounts, payment data and a few others.

I would love to see the ability to generate products using Faker and have a few more dummy methods incorporated into n98-magerun. The ability to generate products, customer addresses, maybe sales data would be great. However, the ability to generate fake customer accounts helps a lot and it’s a great start.