I spent this morning successfully installing the Expression Engine CMS. I was surprised at how simple the instructions were. I had no problem following along, and getting everything installed and configured correctly. As I went through the process, I also realized how little directions there really were. If I were a newbie, I would have no idea where to start. There was a time when I didn’t know that much about using a command line to set up PHP and MySql for an application install. Directions such as these were crucial to my success back then.
So that’s why I wrote this… for all you newbies out there who need a little bit of a boost up when it comes to installing and configuring this stuff.
For the record. I have a commercial license, and am installing ExpressionEngine version 2.2.2 on Red Hat Enterprise Linux Server release 6.1.
A note about this document. Whenever possible I try to use command line tools while explaining things. I do this not because I think that command line tools are the best, just that when dealing with files on a server, most of the time you have to use the command line. So while you may be reading this post and thinking, “I could use my FTP program to do that.,” or “I would use Textwrangler to edit that” I understand and will not hold it against you. I am outlining the command line tools here because I think they are the least common denominator when it comes to tools on a server. MOST of things I outline here can be found on most *Nix servers.
Concerning my use of square brackets in some of the commands below. I felt I had to use square brackets around some of the information in the command to make it clear what you should be replacing. Replace anything inside of the square brackets with your own information, but do not type the actual brackets. For example when I type [userName] then you replace that with your username. Do not include the brackets. They are just there to get your attention.
It should go without saying, but when using the command line you must use ENTER or RETURN to execute that command. SO when I say you should type a command, I really mean you should type that command then hit ENTER or RETURN. Which ever happens to reside on your keyboard.
The Server
Expression Engine runs on top of PHP and MySQL. The minumum requirments for version 2.2.2 state that you have to have at least PHP version 5.1.6 and MySQL version 4.1 or later. At this point many default versions of *Nix have both PHP and MySql version installed. That means you shouldn’t have to worry about having the correct versions, but it never hurts to check. Back on the minimum requirements page you will also find the minimum grant table privileges that the Expression MySql user must have to be able to function properly. More on that later…
While this is all great information, the holes in this are vast. If you have never used MySql before, how do you set all this up. How do you know what version of PHP is installed?
The MySQL Setup
Lets start with setting up MySql properly. On the MySql server, Expression Engine needs both a database created, and a user created. This user must have the correct privileges set for that database.
NOTE: to do the following things you need to have root access to the instance of MySql on the server. IF you do not then you will have to ask your server admin to make the changes outlined here.
Open your command line interface. Mine happens to be Terminal App. Yours may differ. To each his own.
SSH to your server…
ssh yourUsername@www.yourdomain.com
Now you want to login to the MySql server as root using the following command
mysql -u root -p
Hit enter and it will ask you for your password.
A couple things to remember. At the end of every MySql command statement you must have a semicolon (;) It uses the semicolon to denote the fact that Yes this is a command, and I want to execute it now. If you do not put the semicolon at the end of the command then when you hit enter; MySql will just send you to the next line. If this occurs to you then just type a semicolon on that next line, and hit enter again.
Once inside MySql we want to first create the database using this command
create database [databaseName];
That was easy. Now we have to create a user within the MySql system for Expression Engine to use. To do that we need to first switch to the MySql database, Create the User, then update Privileges.
Switch to the MySql Database…
use mysql;
Create the user…You will have to come up with a username and strong password.
INSERT INTO user (Host, User, Password) VALUES('%', '[username],PASSWORD('[password]'));
Now update privileges…
flush privileges;
NOTE: make note of this username, password, and database name because you will need this information during a later step of the install.
OK so we have created the database, and created a user, now we have to ensure that the user has the correct privileges to the database we just created. Since we are already in the MySql database we don’t need to switch to another database to make our changes. Let’s go ahead and grant the privileges, then update those privileges.
Way back on the minimum requirements page we saw that this user needs to have the following grant privileges SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, and DROP.
To grant these privileges to our user type…
INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Alter_priv,Drop_priv) VALUES ('%','[databaseName]','[userName]','Y','Y','Y','Y','Y','Y','Y');
Now we have to update the privileges to show our changes…
flush privilege;
That should have set things up nicely for us in MySql. Now lets move on to PHP.
Checking PHP…
The first thing I like to do with PHP is to find out what version is installed, and running. To do that quickly I use the phpinfo() method.
If you have never heard of it…Basically you create a php file with one command in it that asks the PHP server how it’s configured. This might seem daunting, but is actually quite easy to implement.
First open up your favorite txt editor and type in the following code.
<?php phpinfo(); ?>
Then save that file as phpInfo.php.
Take that file and upload it anywhere on your web server that you can access with a browser. I usually put it in the folder I am currently working in.
Now access that file with your web browser. For Example, IF you put it in the root of your site… http://www.yourDomain.com/phpInfo.php
That should pop up a webpage with all your current PHP and Apache server information. It tells you what modules are installed, and host of other things. If you do not see that page, then PHP is not installed or not running on your server. Get that fixed, then proceed.
In my version of PHP the default timezone was not set. So after my install was complete I got THIS error across the top of the screen.
A PHP Error was encounteredSeverity: WarningMessage: date_default_timezone_get(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/New_York’ for ‘EDT/-4.0/DST’ insteadFilename: libraries/Core.phpLine Number: 227
I also couldn’t use any of the menus therefore rendering ExpressionEngine useless. After some research I found out that I had to go into the PHP configuration file and make sure the default timezone was set. You can save yourself this error, and time by checking that your default timezone has been set properly before you install Expression Engine. Let’s do that now.
We should still be in an SSH session on your web server. If not then please log back in.
First let’s peek into the file using CAT.
cat /etc/php.ini | grep date
NOTE: This will show you all the times that the word “date” appears in the php configuration file. That character before the word grep is a pipe NOT a lowercase el “l”.
Looking for the line that contains…
date.timezone =
If that line looks like THIS –> date.timezone = America/New_York <– then you are just fine.
If that like looks like THIS –> :date.timezone = <– then it is commented out and you need to change it.
To change it you will have to use something like the vi editor. (convenient link to my easy guide to editing files with vi) and you must have root privileges on the server. If you don’t have root privileges then you need to speak with someone who does like your friendly neighborhood sysadmin.
To start editing the file. Make sure you are root when you type…
vi /etc/php.ini
This will open the file in vi in the command interface. Vi has two modes command, and edit. To switch between the two all you have to do is hit the ESCape key. It is like a toggle switch.
Now that we are in vi we want to find, then edit our line. We are already in command mode so just type…
/date
This will search our document for the word ‘date’ and send us to the first instance of that word within our document. This just so happens to be pretty close to the line we are looking for. First use the arrow key to go down a couple lines, then hit the ESCape key.
This allows us to edit the current line. Go ahead and use the arrow keys to go to the beginning of the line and delete the semicolon. Then go back to the end of the line and insert your native timezone. Mine was America/New_York .
When you are done, the line should look something like this…
date.timezone = America/New_York
To save our changes we need to be back in command mode so hit the ESCape key again.
Then type in :wq (that is…a colon, then the letter w, then the letter q) then hit enter. This saves your changes and quits the vi editor.
Now we have to restart the Apache web server so our changes take effect like so…
/etc/init.d/httpd restart
Downloading, Changing, then Uploading the files.
Now that we have MySQL and PHP set up and ready for the install, lets go ahead and upload the needed files.
Of course you should already have downloaded the latest version from expressionengine.com and have your license number handy.
Your downloaded Expression Engine file should be in the form of a ZIP file. Within that ZIP file resides a host of other files and folders. One of those folders is named “System.” Once installed, you will be accessing this system folder to gain access to the administrative back end of Expression Engine. It is good security practice for you to change the name of this system folder so it doesn’t match everyone else’s system folder.
With that in mind go ahead and rename the system folder to anything other than system.
We now need to make sure that Expression Engine knows where the new system folder is. To do that we need to edit BOTH the index.php file and the admin.php file. Open the index.php file in your favorite txt editor. You want to change the line
$system_path = './system';
All you have to do is change the word “system” to whatever you renamed your system folder to. Don’t forget to save your changes.
Do the same for the admin.php file, and you will be all set.
Now take all those files and upload them to your web server.
Change File the Permissions
Once the files are uploaded we need to change the permissions on some of those files. The files and their permissions are listed here, but following the theme of these instruction, I will list them here as well, then tell you the commands that can make that happen.
OK back to the terminal window; SSH to your server again, then navigate your way to the folder you just uploaded. We need to change the permissions on the following files and folders to the ones listed. Remember you renamed the “system” folder. So in the following file list don’t forget to to so the same. Every time I say system, you should insert whatever you changed the name too.
- system/expressionengine/config/config.php –> 666
- system/expressionengine/config/database.php –> 666
- system/expressionengine/cache/ –> 777
- images/avatars/uploads/ –> 777
- images/captchas/ –> 777
- images/member_photos/ –> 777
- images/pm_attachments/ –> 777
- images/signature_attachments/ –> 777
- images/uploads/ –> 777
The command you use to change those permissions is chmod. To use chmod you type the command, then the permissions, then the file that those permissions effect. So… chmod 777 [theFileName]
So for the first file you need to get to the same folder that the file exists
cd system/expressionengine/config
Then use chmod to change the permissions in that file…
chmod 666 config.php
While we are here might as well change the other file in this folder.
chmod 666 database.php
Now all you have to do is make your way down the list changing permissions as you go. Once you are done you can log off the server because we are done with the command line for now.
Go ahead and open a browser and point it to the admin interface.
http://www.yourDomain.com/admin.php
Click through the screens and agree to the license terms.
Eventually you will get to the screen that allows you to put in your license number, and all the Mysql database info. Remember when I told you to note the name and password of the expression engine mysql user we created. Well this is the screen you put it into.
Fill in all the info concerning the creation of your admin account on the expression engine server, and check the box next to the modules you would like to install right off the bat. Dont forget to set the timezone. On this screen you can choose to install sample data so you can learn how Expression Engine works, but I always choose NONE-Empty installation because I like to start from scratch.
Once you are done, hit the button to install Expression Engine.
One Last Step
You need to delete the installer directory that exists within the system directory. If you do not take this step nothing will work.
You can delete the files via FTP or command line.
To do this you have to SSH back to the server, and navigate to the Expression Engine system directory.
Now that we are in the right place you can delete the installer folder contained within by using this command
rm -r installer
Log out of the server and that’s it. Your install is complete.
To get started within Expression Engine just access your new admin interface by pointing your browser to the admin.php file that we edited earlier.
http://www.yourDomain.com/admin.php
That’s it. Now the real work starts.