Tag Archives: Linux

Setting Up Apache, PHP, MySQL – The Easy Way

I’ve been experimenting with Content Management Systems recently, and after some research, I’ve decided to use Joomla for my next couple of projects. The idea is that I don’t need to spend as much time writing code, and I can get a website up and running quickly. In order to get more experience with of Joomla I decided to install it on my MacBook.

In order to use Joomla, you need three things: Apache, PHP and MySQL. Individually, these are easy enough to install, but getting them to work together can be a bit of a headache. Config files need to be edited, file permissions need to be changed, servers need to be started and restarted, and it can be a bit daunting, not to say time consuming.

That’s where MAMP comes in. An acronym for Mac, Apache, MySQL, PHP, it’s a collection of all these programs in one handy installer that does all the work for you. It took a couple of minutes to download and about 30 seconds to install. Once installed you have a full Apache server, MySQL server and PHP 4 and PHP 5 installation. Better still, it doesn’t interfere with any other Apache, MySQL, or PHP installations you may have running, and it’s controllable from a handy Dashboard Widget.

Once MAMP is installed and running, it’s just a matter of downloading the package and installing Joomla. A simple browser-based installer guides you through the setup, and within minutes I was up and running. The only issue I came across was that the permissions of the Joomla folder had to be updated to allow the installation. It was just a matter of selecting the folder, holding Option-I and changing the permissions for “Others”. Done and dusted.

For those of you not on the Mac platform there are also versions for Windows, Linux, and Solaris available, along with a Joomla Standalone Server (Windows based).

CR vs LF vs CRLF

If the above title seems cryptic, it’s supposed to be. It’s representative of a problem that I came across today when I was editing one of the plugins on this site. When I went to check the plugin status, I was shocked to see that instead of the normal options to activate/ deactivate the plugin, all I got was a mish-mash of PHP code.

I couldn’t think why this had happened, then it hit me. I had done the editing on my MacBook. The Mac, just like every other platform has built-in text editors. These editors treat text in much the same way as editors on other platforms, although there is one crucial difference. When you hit the enter key on a Mac, a special character is inserted to signal that a new line should be started. On a Mac, this is called the Carriage Return, or CR, character. On a Windows editor, the enter key inserts a Carriage Return – Line Feed, (CR-LF), character, and on a Linux machine, it’s a Line Feed, (LF), character.

So each of the major platforms treat a new line in a different manner. The upshot is that if you write a text document on a Windows machine, the new line will be interpreted correctly on both a Linux and Mac, as it uses characters common to both. However, if you write a text document on a Mac, then it won’t be interpreted correctly on a Linux machine, and vice versa.

So here was my problem, I had edited the PHP files on my Mac and uploaded the changed files to a Linux server. Using EditPad Lite for Windows, I was able to easily convert the newline characters from CR to CR-LF, and re-upload the file. Problem solved. The only thing that I can’t figure out is that if Linux has a problem with the CR-only newline character, how come the plugin worked OK?