Serving ExpressionEngine
2 January, 2009 | Filed under “ExpressionEngine”
This article is kind of twofold. On the one hand it checks if ExpressionEngine – the Content Management System (CMS) from EllisLab – is compatible with an external server, and on the other hand, if it works with a client side server. The latter is interesting if you have followed the earlier articles on building a local Apache server with PHP, MySQL, and phpMyAdmin. You will find nothing new or revolutionary here. It is more or less my own diary as I am working towards different installations of my choice of CMS. This laboratory exercise will run a check for ExpressionEngine 1.6.6.
I am not going to add anything to the arguments that speak in favour of ExpressionEngine. With the plethora of CMS options out there it is an impossible task to try everything out before settling for a system. It all boils down to word of mouth and gut feeling. In the end, it doesn’t really matter – if everything works and one is happy with the workflow. And if it leaves time to spend on actual web pages and content.
There is one but, however. Each CMS has certain requirements that must be met for most or anything to work – and there is not much mere mortals can do about that. Point in question is the communication between CMS and server and between CMS and database. This is something you have to check regardless of chrome or pomp and ceremony. Refer to EllisLab’s web site for the formal list of requirements.
What follows is a rather sketchy procedure along with a few comments.
Is your server up to the task?
1. Download the Server Wizard. This is a script called wizard.php.
2. Unzip the file.
3a. Upload wizard.php to your external server.
4a. Point your web browser to the file, e.g.:
http://www.siteinquestion.com/wizard.php
Your browser returns a test page; Check Requirements for ExpressionEngine.

A typical list of supported features on an external server.
3b. Upload wizard.php to your local, client side server. If you are working with virtual hosts as per the article Apache on the Macintosh, choose one of the web site folders on the server partition,e.g., Cochise.
4b. Point your web browser to the file:
cochise/wizard.php
Your browser returns a test page; Check Requirements for ExpressionEngine.

A possible list of supported features on a client side server.
If the test page quarrels about a missing image, never mind. Your machine is presently not able to retrieve the logo from EllisLab (their server may be down for some reason or you are not connected to the Internet).

This is not a problem.
5. Make sure that your server supports at least the two required features. If your external server is not up to the task, you will either have to request your Internet provider to “open” the features, or you may have to upgrade your web hosting service.
Is your database up to the task?
ExpressionEngine depends on a MySQL database. It must already be installed and set up properly for the communication to work. You will need to fill in four fields in the wizard to check communication:
MySQL server address
MySQL username
MySQL password
MySQL database name
Note: Your Internet host will create a database for you and provide you with all the necessary information for your external server. If you are testing a client side server, you will have to create the (named) database yourself, for instance via phpMyAdmin, before trying to connect. The MySQL user name will most likely be root.
6. With the four pieces of information at hand, run the MySQL settings check. If everything is in place for ExpressionEngine, you will be greeted with the following message:
Congratulations! Your Server is Ready for ExpressionEngine!
If something is amiss, you will see the following message:

This is a problem.
Important: If connection with the EllisLab suggestion of localhost as the MySQL server address fails, try 127.0.0.1 instead. If this turns up an error as well, you may have to backtrack your original database installation steps.
The number of the Beast – and worse!
I will not dwell on the actual installation of ExpressionEngine. The procedure is adequately described in its documentation. There is, however, one small detail which must be taken care of regardless of installation method, be it FTP for uploading to an external server or simple copying to a client side (local) server. It concerns the setting of file permissions. Usually performed with the FTP application once the files have been uploaded to a web server, it is not immediately evident that this can be carried out on local files as well.
On a Unix server the following three files must be set to file permissions 666:
path.php
system/config_bak.php
system/config.php
The following seven directories (aka folders) must be set to file permissions 777:
images/avatars/uploads/
images/captchas/
images/member_photos/
images/pm_attachments/
images/signature_attachments/
images/uploads/
system/cache/
Note: EllisLab recommends that the system folder be renamed for security reasons. Not a big issue with client site servers, but if done, three of the paths will differ from the ones shown above.
Once the complete suite of ExpressionEngine files have been copied to your local server, open your FTP program (for the sake of this exercise, Transmit from Panic is used) and point the application to the local ExpressionEngine directory (in Transmit this is called your stuff).

Mark the file/folder in question, ask for information on the item (in Transmit this is File > Get Info), and change the permissions (aka octal) to the new value (in Transmit you will have to choose <Apply> for the changes to take effect).

Repeat the procedure for all files and folders involved.

phpMyAdmin for MySQL
29 December, 2008 | Filed under “Apache on the Macintosh”
Note: Building on the earlier articles Apache on the Macintosh, PHP for Apache, and MySQL and the Macintosh, this article focuses on the installation of phpMyAdmin on the same client Macintosh running Mac OS X as discussed earlier. The phpMyAdmin project is more than ten years old and presently at version 3.1.1. For compatibility, you will need at least PHP 5.2 and MySQL 5.
What is this MySQL, anyway?
With MySQL up and running on your local machine, the obvious question is how to create, gain access to, and maintain a MySQL database. MySQL is an implementation of Structured Query Language (SQL), originally developed by IBM and later standardized. SQL is, in short, a language for relational databases. So, do I need to know and use SQL commands to administer this thing? As it happens, no. This is where phpMyAdmin takes on the role of go-between, or negotiator, if you will. Itself a PHP script running in your web browser, it adds a human interface to it all.
Acknowledgement
I claim no intimate knowledge of phpMyAdmin configurations. Everything below this paragraph is the direct result of me consulting the documentation that comes with the script and recommendations of people who know their stuff. For the most part I will parrot back information already available – much like talking aloud to myself while struggling with the ins and outs of databases in an ExpressionEngine content management system. In other words, necessity is not the mother of invention in this case. I simply need to make sure that I have something to refer back to should web pages on e.g. Train Signal and Server Codex go the way of the dinosaur. In the case of Server Codex there are indications that this is already the case. They do, however, note that theirs is a live document “that will be constantly refined”. Now, that is more than this dinosaur can promise.
Let’s get on with it
1. Head over to the official phpMyAdmin website and download the latest stable release. I opted for the ZIP archive. Depending on your choice, the compressed, downloaded file may or may not decompress automatically. At Versiontracker you should be able to find a decompression tool. Once decompressed, you have a folder named phpMyAdmin-3.1.1-all-languages (or similar) on your hands.
2. Change the name of the folder to whatever makes sense to you. For practical and logical reasons, however, a good suggestion is:
phpMyAdmin
3. Move (or copy) the folder thus:
X > Library > WebServer > Documents > phpMyAdmin
where X represents the name of your main hard disk/partition. If you copied the folder, the original is no longer needed and can be trashed.
Note: Remember from the first article in this series that you, as I, are stubbornly working with virtual hosts on a non-default, dedicated partition. Apple’s pre-installed Sites folder (as one of two suggestions by Server Codex) is therefore not the logical place for phpMyAdmin.
Configuration
Whenever phpMyAdmin is started, it first loads the file config.default.php from its libraries folder and then overrides those values with anything found in a user specific file called config.inc.php. And where is this config.inc.php file? Well, up front it is nowhere, so you will have to create your own or, rather, modify a sample document.
Note: If the default value is okay for a particular setting, there is no need to include it in config.inc.php.
4. Open the sample document:
X > Library > WebServer > Documents > phpMyAdmin > config.sample.inc.php
5. You will modify this document, but before doing so, save it to the same directory with the new name:
config.inc.php
This ensures that you do not accidentally overwrite anything in the original sample document.
6. There are several ways to configure the login behaviour of phpMyAdmin. If you go with the (maybe) obvious “cookie method”, do as instructed in the documentation that comes with the script:
X > Library > WebServer > Documents > phpMyAdmin > Documentation.html
If you want to avoid the problems described below in the mcrypt chapter, opt for, e.g., an HTTP authentication. Depending on your database needs, uncomment or add parameters based on availability as per the Configuration section in Documentation.html. Instead of going through the sample document line for line, adding and/or deleting, I simply state: Here is what works for me as of this writing:
<?php
// Bjorn 081228 (Refer to 'config.sample.inc.php' for comments)
// Original document Western (Mac OS Roman) changed to Unicode (UTF-8, no BOM)
$i = 0;
$i++;
$cfg['Servers'][$i]['auth_type'] = 'http';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['socket'] = '/tmp/mysql.sock';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
$cfg['Servers'][$i]['relation'] = 'pma_relation';
$cfg['Servers'][$i]['table_info'] = 'pma_table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
$cfg['Servers'][$i]['history'] = 'pma_history';
$cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
?>Important: I made one significant change to avoid the Error #2002 described later:
$cfg['Servers'][$i]['connect_type'] = 'tcp';
was changed to:
$cfg['Servers'][$i]['connect_type'] = 'socket';
and the following line was added:
$cfg['Servers'][$i]['socket'] = '/tmp/mysql.sock';
This points the phpMyAdmin configuration to where MySQL stores its socket file.
7. Save the document and close it.
Does it work?
The time has come to test if your local installation of phpMyAdmin works.
8. Point your browser to:
http://localhost/phpmyadmin/
or simply:
localhost/phpmyadmin
Note: If you renamed your phpMyAdmin folder to something different from phpMyAdmin, the address should reflect this.
Depending on your configuration, whenever you are prompted for a user name and a password, it would be root and your_MySQL_password, respectively.
For the record: I still have (at least) one configuration problem to sort out on my own system. When I log in, I get the message: “Your PHP MySQL library version 5.0.45 differs from your MySQL server version 5.1.30. This may cause unpredictable behavior”. I live in the hope of returning with an update sometime in the future.
mcrypt
If you get the following warning on login:

my guess is that you went with the cookie login alternative which may choke for at least two reasons. Either you are using the default Mac OS X PHP installation (read up on this in the second article of this series) – and the mcrypt extension is not part of that installation – or you are on a 64-bit computer, or both. This is a major headache because it is (probably) not possible to install mcrypt without compiling the whole thing from source – something I am not willing to do as mine is not a production environment.
Quoting the phpMyAdmin documentation: “When using the ‘cookie’ authentication method, the mcrypt extension is strongly suggested for most users and is required for 64–bit machines. Not using mcrypt will cause phpMyAdmin to load pages significantly slower.”
If you still want to login with cookies anabled, you are on your own. But as always: Suggestions and solutions are appreciated!
FAQ the problems
If phpMyAdmin returns error messages or if you have questions in general, consult the Documentation.html installed together with everything else in your phpMyAdmin folder. The section on Frequently Asked Questions may have the answers.
If you get the following error message on login:

a possible solution has already been mentioned. Otherwise you will eventually have to sort it out yourself because your configuration may differ from mine, and the scenario is complex. This MySQL forum entry may come to your rescue.

MySQL and the Macintosh
18 December, 2008 | Filed under “Apache on the Macintosh”
Note: The procedure herein described installs a MySQL 5.1.30 database on a 64-bit PowerPC Macintosh client running Mac OS X 10.5.5 (Leopard). The procedure may, however, be followed for different configurations. My main interest is to use the database in conjunction with a core version of the ExpressionEngine content management system (CMS) from EllisLab, both running locally on one of my own computers. MySQL was the natural “next step” in building a local Apache server and this is the third in a series of articles; the first article took care of the actual Apache installation while the second article set the Apache to work with PHP. CMSs generally rely on PHP and MySQL to build their web applications and ExpressionEngine specifically requires both.
MySQL – and yours, too
1. From Sun Microsystems’ MySQL downloads page, choose the “MySQL Community Server” download link. As of this writing, the latest stable version of MySQL is 5.1.30.
2. Download the correct version for your hardware and software. You are given a choice of “package format” and “TAR packages”. The former (which I prefer) is delivered as a dmg file; familiar to everyone who has previously installed software on Mac OS X. In the discussion below, I will presume that you opt for this more convenient package format.
Note: If you are uncertain of your system configuration, choose “About This Mac” under the Apple in Finder’s menu to see which version of Mac OS X you are running. Choose “More Info…” if you need information on your make of Macintosh. 32-bit? 64-bit? Still uncertain or in a nostalgic mood? Consult Ian Page’s Mactracker application and chime away! Know, however, that the PowerMac G5 was the first 64-bit consumer-level desktop computer ever sold. It was introduced in June of 2003. So, if you have a G4 computer, it is 32-bit. If you have a G3 computer, it is blue.
Important: If your system already has a MySQL instance up and running, shut it down before you proceed with a new installation. At this point it may be a good idea to read Sun’s article Installing MySQL on Mac OS X.
3. Double-click the dmg file icon to open the package.
4. Read the ReadMe.txt file in the package. The instructions more or less repeat what you (should have) read on Sun’s web site.
5. Double-click the pkg file for your system (e.g., mysql-5.1.30-osx10.5-powerpc-64bit.pkg) to start the installation. You will be guided through the necessary steps – only make sure you choose the correct install location should you have more than one operating system available.
6. To automate your system, follow this instruction from the ReadMe-file: “If you want MySQL to start automatically during system startup, you also need to install the MySQL Startup Item. It is part of the Mac OS X installation disk images as a separate installation package. Simply double-click the MySQLStartupItem.pkg icon and follow the instructions to install it. The Startup Item need be installed only once. There is no need to install it each time you upgrade the MySQL package later.”
Note: The startup item installation adds the variable MYSQLCOM=-YES- to the hostconfig system configuration file. Please observe that Apple has stamped this file with a This file is going away warning. Up ahead, we can expect to see some changes in this area.
7. If you are comfortable with the Terminal window, you will probably start and stop MySQL with sudo commands. For the rest of us, the world became a better place when Sun gave us a preferences pane. Once and for all, install MySQL.prefPane, from the package, here:
X > Library > PreferencePanes> MySQL.prefPane
(where X represents the name of your main hard disk/partition). Whenever you need to start or stop the database, do so from the Finder menu:
Apple > System Preferences… > Other > MySQL

The MySQL preferences pane.
Note: That said and taken care of, it might, however, come in handy at some time to know how to start and stop the database server from the Terminal. If you ever need information on this, you will find it tucked away at the end of this article.
8. Back to work: Unmount the installation package by throwing its drive icon to the trash, then delete the original dmg file which is no longer needed.
Database passwords
9. With PHP installed and the MySQL server operational, it is important to issue passwords to users. Out of the box, the initial MySQL user accounts lack passwords until assigned one. In the following you will assign a root password for MySQL.
Important: ‘root’ as used in this setting, should not to be confused with UNIX root.
Now, believe me: I shy away from the Terminal and UNIX command lines whenever I can, telling myself it is a normal, human reaction. After all, Apple gave us the graphical user interface for a reason. But at some point I have to bow down before the king. For what we are about to do, the Terminal rules.
9a. Fire up the Terminal application and enter the following:
sudo /usr/local/mysql/bin/mysql -u root
9b. When promted for a password, enter your Mac OS X administrator password.
9c. At the mysql> prompt, enter:
UPDATE mysql.user SET Password = PASSWORD('NewPassword') WHERE User = 'root';
where in place of NewPassword you supply your own password.
9d. At the next mysql> prompt, enter:
FLUSH PRIVILEGES;
9e. At the third mysql> prompt, disconnect from MySQL with:
quit
Preparing MySQL for PHP passwords
10. The default installation of MySQL should now be configured to recognize the format for PHP-compatible passwords. According to Kevin Yank in his book Build your own database driven website using PHP & MySQL, all it takes is a plain text document with the following two lines of code:
[mysqld]
old-passwords
Save the document temporarily to, e.g., the Desktop with the name:
my.cnf
The cnf suffix is important here! This file stores global options (aka configurations) for MySQL programs.
But why temporarily? Because the file is expected to reside in one of those folders which are normally hidden from the casual user. In Finder:
Go > Go to Folder…
and enter the following destination:
/etc/
Now, drag the cnf file into this folder, let go of the mouse, and authenticate with your administrator password when prompted.
Note: If you read Kevin Yank’s book, you may be tempted to copy the configuration file to the data folder of the MySQL installation – unless you read the errata information later released on the publisher’s web site. It so happens that the MySQL team now specify a different path for my.cnf.
11. Restart the computer and that’s it!
Digression
The Internet is both a blessing and a curse. You start off looking for information on a specific subject – and end up reading about something quite off the track. Or close to it. Or parallel to it. Or … whatever. If you do not care a fiddler’s fart about password hashing, do not read James McGlinn’s article.
Want (eh, need) to start or stop MySQL from the Terminal?
The reference manual for the MySQL database system, mysql.info, is brimming with command examples. But take heed: The text document is a hefty 10 MB and may take some time and horsepower to open. You will find it (hidden away) here:
/usr/local/mysql/docs/
Let us, however, restrict this to simply starting and stopping the MySQL server.
To start the server
a. Fire up the Terminal.
b. Enter the following:
sudo /usr/local/mysql/bin/mysqld_safe
c. Type in your system administrator password (not the database password) if prompted for Password. And, by the way, you will not see the password as you type.
d. Suspend MySQL by hitting Ctrl-Z.
e. Switch MySQL to background execution with the following command:
bg
To shut the server down
a. Fire up the Terminal.
b. Enter the following:
sudo /usr/local/mysql/bin/mysqladmin -u root -p shutdown
Beware of the differences in c) and d):
c. If prompted for Password, type in your system administrator password.
d. Type in your database password when prompted for Enter password.
Important: You may have observerd a couple of “ifs” in the steps above – and wondered why you are not always required to enter an administrator password. This has everything to do with sudo. Whenever you enter a command starting with sudo, the system grants you a 5 minutes temporary access as a system root user. And as a root user you can do pretty much whatever you want – no passwords asked – and may wreak havoc if you do not take care. The Apple support article Enabling and using the “root” user in Mac OS X might give some insight into this.

The “Take on me” effect
Read it all …
Transparent, horizontal navigation bar
Read it all …
First snow
Read it all …
Windows screen dump with a Macintosh keyboard
Read it all …
Ten years after
Read it all …
The external link symbol
Read it all …
PHP for Apache
Read it all …
Apache on the Macintosh
Read it all …