In this chapter you'll learn what you need to get your own concrete5 site up and running on your local computer. You don't need to have a lot of experience with Apache, PHP, and MySQL configuration as we're going to use XAMPP, which will install all the necessary components in almost no time.
Before you can start working with concrete5, you have to set up an environment where you can test and play around with concrete5 to get used to it. If you have a web hosting account, you can install concrete5 there, but since that isn't always the case, we'll install everything concrete5 needs to work smoothly on your local Windows computer.
The local webserver will only be used to build and test the site as well as the add-ons we're going to create. In the last chapter of this book, we're going to move the site from your local computer to a live webserver.
There are a few tools you'll need before you can start the installation process. You probably already work with similar tools, but let's still make sure you've got everything before continuing.
concrete5 supports all major browsers as long as you're working with an up-to-date version. Please note: You can create a website which is viewable with Internet Explorer 6.0. The In-context editing system won't work with Internet Explorer 6.0 which means that you won't be able to update the content of your website, unless you use a more up-to-date web browser like Internet Explorer 7 or higher.
Since we're going to edit lots of files you'll need a text editor. The requirements are quite small; you can pick almost any text editor you want. Just make sure it does support PHP syntax highlighting. If you don't work with PHP very often, here are some possible editors:
PSPad (Windows only, free), http://www.pspad.com. A simple text editor with built-in FTP support. This can make a quick fix on your website even quicker.
Coda (Mac OS only, commercial), http://www.panic.com/coda/. A very slick and clean editor, FTP support, CSS editor.
Notepad++ (Windows only, free), http://notepad-plus-plus.org/. A small and fast replacement for Windows notepad.
There are a lot more text editors, as mentioned previously; you can use almost any editor you want. If you're familiar with another product, just go with it. You won't find anything in this book where you need a special text editor feature.
The same with the file archive utility; there are plenty of tools you can use as long as it extracts standard ZIP files. If you don't have any archive utility installed, you can go with IZArc http://www.izarc.org/; it's free and does a good job.
Once more, there are lots of choices. You'll have to change file permissions later, so make sure your FTP client includes this option. A powerful and well known client is FileZilla, http://filezilla-project.org/. It's free as well and has a lot more features than we need.
concrete5 is a PHP application which uses PHP as its programming language in combination with a MySQL database. There are lots of possibilities to meet the requirements of concrete5. The preferred web server is Apache, IIS should work as well but isn't supported by the core team, even if it isn't as well tested as Apache.
If you already have a server or a local Apache, PHP, and MySQL setup, you can skip this step and continue with downloading concrete5. Otherwise, you are going to need to install XAMPP on your local computer by following these simple steps:
Go to http://www.apachefriends.org/ and click on XAMPP for Windows. Scroll down and download the latest version of XAMPP Lite. If you're not very familiar with these tools, you should download the EXE and not the ZIP. Double-click the EXE as soon as it has been downloaded. You should see the following window:
Click Install to start the installation process; it will take a while as it extracts quite a lot of files. You can install XAMPP in your program directory
C:\Program Filesbut it won't work on Vista unless you modify some privileges. If you don't feel comfortable changing your security settings, just use
If you want to know more about the security changes needed on Vista to install XAMPP in your program directory, go to this page and follow the instructions: http://www.apachefriends.org/en/faq-xampp-windows.html#vista
At the end you'll see a menu where you can execute different actions. You'll later have to start the XAMPP Control Panel but let's leave this screen untouched for now; we have to make one modification first.
Before you start XAMPP, you should change one MySQL setting. MySQL table names are not case sensitive on Windows. This will cause some problems if you want to move your site to a Linux server where MySQL is by default set up with case sensitive table names. It's therefore recommended to change this, if you work with concrete5:
Go to the directory where you've installed XAMPP, open
bin. It should look like the following:
lower_case_table_names = 0
The first lines should then look like the following:
# Example MySQL config file for medium systems. # # This is for a system with little memory (32M - 64M) # where MySQL plays an important part, or systems # up to 128M where MySQL is used together with # other programs (such as a web server) # # You can copy this file to # /etc/my.cnf to set global options, # mysql-data-dir/my.cnf to set server-specific options # (in this installation this directory is @[email protected]) # or # ~/.my.cnf to set user-specific options. # # In this file, you can use all long options that a # program supports. # If you want to know which options a program supports, # run the program with the "--help" option. # The following options will be passed to all MySQL clients [client] #user = your_username #password = your_password host = . port = 3306 socket = "MySQL" # Here follows entries for some specific programs # The MySQL server [mysqld] lower_case_table_names = 0 basedir = "C:/xampplite/mysql/" datadir = "C:/xampplite/mysql/data/" port = 3306 socket = "MySQL" skip-locking key_buffer = 16M max_allowed_packet = 1M table_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M
Downloading the example code for this book
You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.
If everything worked you should be able to open your browser and enter
http://localhost/. On this screen you can select your preferred language and you'll see a nice status page about XAMPP.
It might just happen that Apache doesn't start because port 80 is already used by an application like Skype. You can click on Port-Check to see if there are any ports being used before you start the XAMPP services. If there are, either disable the other services, or reconfigure, or stop them.
The XAMPP setup package installed a working web server, including PHP with the most commonly used modules and a MySQL database. This is what a lot of web applications need, an environment which works for a lot of web applications and CMS's as well.
You've also had a quick look at one MySQL configuration file to avoid problems when moving your data to a Linux server. If you want to know more about this setting, the MySQL documentation is going to answer almost any question about table names: http://dev.mysql.com/doc/refman/5.1/en/identifier-case-sensitivity.html.
Please don't forget, XAMPP is by default a user-friendly and simple system but insecure to simplify the development process as much as possible. It is nice to work with and great for your first experience with your own web server, but not recommended for a production environment. Later in this book, we'll move your site to a LAMP server (Linux, Apache, MySQL, and PHP) which is more widely used by webhosting companies with a more secure configuration.
Like any other software, concrete5 needs certain things to run. Try to answer which of the following items are true:
Which of the following server-side programming language(s) has been used to build concrete5?
All of the above
Which of the following database(s) can you use with concrete5?
All of the above
Which of the following operating system(s) can you use to run concrete5?
Mac OS X
All of the above
Name the webserver(s) you can use to run concrete5.
Before we can install anything we have to get the latest concrete5 version from this URL: http://www.concrete5.org/developers/downloads/ and follow these steps:
Open the ZIP archive and extract all the files to
C:\xampplite\htdocs. Override the files which are already in the directory.
After you've extracted the ZIP file you should see a structure like the following:
At the time of writing, concrete5 v126.96.36.199 was the latest version. You can download a newer version if available; changes in the installation process should be minor if there are any at all.
downloaded and extracted the concrete5 CMS files. Depending on your archive utility it might have been the case that empty folders like
files, and others hadn't been created. Make sure your structure looks like the one shown in the preceding screenshot.
Before we continue, a few words about the file structure you've just created. It's important that you understand the structure of concrete5 before you start working with it. It's helpful to have a clear understanding about the structure so you can find your files easily. You'll later see that all add-ons in the marketplace follow this structure. Using the suggested structure helps to keep a clean structure, no matter who builds the concrete5 site or add-on.
It might look a bit bulky to have so many folders in the root of your website but you'll realize that it makes perfect sense to have this structure the more you work with concrete5. To give you a first impression about the most important folders:
Put your custom blocks in this folder; you'll learn more about blocks in the next few chapters.
Probably the most important part; this is where all core files, the actual CMS, is located. Never update anything in this folder.
The folder where concrete5 puts the configuration files.
The file manager stores your files in this directory.
This is where you have to put add-ons if you install them manually.
The concrete5 auto update feature puts the new core in this directory.
There are a few more folders but you probably won't need them unless you dive deep into concrete5. We won't use them in this book and therefore won't mention them.
Use phpMyAdmin which is included in XAMPP Lite to create the database:
http://localhost/phpmyadmin/or hit the Admin button next to MySQL in the XAMPP control panel and you should see the following page:
Select the collation utf8_general_ci.
Go to the Privileges tab and click on Add a new User to create a dedicated user for concrete5.
When prompted, use the following credentials to fill in the following fields:
localhostThis makes sure that the user can only be used if the database is accessed by the local machine.
concrete5The password to access your database. Feel free to use a more secure password than concrete5, just make sure you remember it when we install concrete5 in the next step.
Open your favorite browser and enter
http://localhost/. You should see the installation screen:
C5 Request URLs: By default you'll see
index.phpin each concrete5 URL you open. To get rid of this, you need to have the Apache module
mod_rewrite, which we're going to deal with later in this chapter.
Image Manipulation and XML Support: These are PHP modules which are enabled by default and needed by concrete5.
Web Server Access to Files: Usually not a problem if you work with XAMPP on Windows. The webserver must be able to write some files in your website's installation directory. We'll discuss this issue later, when we move the site to the production server.
Version Comparison: This feature uses Python to show you the difference between page modifications. A nice feature but it doesn't work because XAMPP Lite doesn't install Python. But since it's optional we're not going to worry about it.
To install concrete5 you have to enter the following personal information:
Server: Since the database is running on the same machine as the web server, just enter
MySQL Username, MySQL Password, and Database Name: concrete5 or whatever you used when you created the user in phpMyAdmin.
Sample Content: If you enable this, concrete5 will create a few sample pages to play around with. Enable this, if you're new to concrete5, it will create some nice pages where you can see the different blocks you can use to build your website.
If you've entered all the necessary information, click Install Concrete >!
A few seconds after you've clicked Install Concrete you should see a screen with an automatically generated admin password. Make sure you don't lose it.
concrete5 is installed and ready to work with on your computer!
you've successfully installed concrete5 you'll find a file called
directory. This is where the installation process has saved the information you've entered during the process. Here's how it looks:
<?php define('DB_SERVER', 'localhost'); define('DB_USERNAME', 'concrete5'); define('DB_PASSWORD', 'password'); define('DB_DATABASE', 'concrete5'); define('BASE_URL', 'http://localhost'); define('DIR_REL', ''); define('PASSWORD_SALT', 'zc8tSsYQI0E2MifRwboxBq6K9UmbL4X7vrf3Tz1unNFVCPWkO5glHjZaGpADJ'); ?>
DB_DATABASEare obviously just database related. If the credentials to access your MySQL database have changed, this is where you have to modify them to make sure concrete5 can access your database.
BASE_URLis used by default to make sure that your website visitors use your primary domain. If your site is accessible by multiple domains, concrete5 will just forward them to the URL specified in
PASSWORD_SALT, this is a random string and is used in combination with the password to generate the password hashes found in the user table. Salts are used to complicate dictionary attacks and even if they are useless without a password you should still not publish a real password salt to keep your site safe.
You'll often have to check or modify a few lines in the configuration file, so where can you find it?
<concrete5 installation directory>\config.php
<concrete5 installation directory>\config\config.php
<concrete5 installation directory>\config\site.php
you browse to a subpage in your concrete5 site you'll notice an odd thing in every URL: there's
in it like this
http://localhost/index.php/about/. Every request to a page in concrete5 is processed by
index.php. This has several advantages: It's easier to check the permissions, there's a single point where the page rendering time can be improved, and a few more things.
However, even with these advantages you probably wouldn't like to see
index.php in every URL. Luckily it's rather easy to change it if your web server supports rewrite rules. XAMPP does, and here's what we have to do.
Log in to concrete5.
Click on the Dashboard button in the top-right corner.
Select Sitewide Settings in the navigation.
Check Enable Pretty URLs and hit Save, you should see the following screen:
Congratulations, you're done! concrete5 is running and you've also activated some options to improve the behavior of concrete5.
is a configuration file most commonly used by Apache to configure Apache modules on a directory level. It's a simple text file you can open with any text editor of your choice. If you haven't worked with Apache before, the content might be a bit confusing but concrete5 took care of it. You shouldn't have to modify anything on your own in this file.
Pretty URLs can also be used with Microsoft IIS but you need to install a rewrite filter first.
If you want to try it on your own, you can find a solid and free rewrite filter at this address: http://iirf.codeplex.com/.
You've reached the end of Chapter 1!
You should now have a working concrete5 installation from where you'll learn how to work with concrete5.
In case you have to check or modify your concrete5 configuration, you should know where to find the files.
We've looked at the requirements to run concrete5.
All the tools you'll need to go though this book should be installed in your computer.
We're going to use this test site to build our own site including some customization and programming.