Note: This post is specific to installing Concrete5 sites on Mac OSX computers that use MAMP. Unfortunately it does not work with any other environments on OSX (XAMPP, built-in Apache/MySQL/PHP, etc.), nor does it work on other OS’s (Windows or Linux). Also note that while the initial setup is complicated, it is absolutely worth the trouble if you build lots of sites, themes, or addons!
A promising feature that was included in Concrete5.5.1 was the ability to install C5 from the command line. In theory, what this means is that with one simple command typed (or pasted) into the OSX Terminal, you can have a new Concrete5 site up and running without having to go through the trouble of filling out the "Install new site" form and clicking through the steps there. In practice, though, this feature doesn't gain you all that much benefit because:
- You still need to install the database yourself.
- You still need to download Concrete5, unzip it, and move the files into your web server directory.
- You need to remember the very complex set of command-line arguments that are fed into the installer program.
- If you want to install different versions of Concrete5 (for example, if you are testing addons with older versions of C5), you need to have an old version of the script lying around (which requires understanding how to fork the github repository and roll back your working copy to a prior version).
Due to these limitations, I have found it to not be worth the trouble. But after installing 1,000 new Concrete5 sites (mostly for testing out addons with different versions of the system), I finally got sick and tired of going through the installation process each time (especially having to create new databases for each one). So I improved upon the command-line installer to address these limitations, and make it as quick and easy as possible:
The installation requires a small amount of work (which I'll walk you through here), but after you do these steps the first time, you won't need to do them again.
First, download the program by going to the github page, and clicking the "ZIP" button near the top:
Unzip the downloaded ZIP file, rename the unzipped folder to something that's easier to read and type (e.g. "concrete5-cli"), then move that folder to wherever you want it to live on your computer (for example, inside the /Applications folder).
Once moved the unzipped directory to your desired location, you'll need to enter some settings by editing the "settings.php" file in your text editor:
This file should look familiar (it's similar to Concrete5's "config/site.php" file). The database server, username, and password are self-explanatory. The HTDOCS_DIR is the top-level directory on your computer that MAMP serves web files from. By default, it's the /Applications/MAMP/htdocs/ directory, but you might have moved this (for example, on my computer I changed the MAMP settings so my top-level web directory is ~/Sites/). BASE_URL is the top-level domain name that you use to access sites running under MAMP. Don't forget to include the port number! (By default this is localhost with port 8888 -- so http://localhost:8888 -- but you may have changed it for your own MAMP installation). Admin email should be changed to your email address, but you should leave the admin password as something generic. As the comment explains, this password is eventually passed along to the new site so that you can be automatically logged-in as the admin upon first installation -- so you don't want a "real" password to be showing up in your browser history. (You of course should always change the admin password to something more secure before releasing a site out into the wild... but often these sites are just for local testing so it's better to have an easy password anyway).
Mac OS X includes its own installation of MySQL, but we want to use MAMP's MySQL instead. Open the Terminal app, and run the following command:
You should see the message
No such file or directory.
IMPORTANT: If you don't see that message, it means something else MySQL-related has already been set up on your machine, and you should probably not continue with the next step (unless you understand what's going on and the ramifications it will have on your existing setup).
Assuming you did see the
No such file or directory message, proceed by entering the following 2 commands into the Terminal:
sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock
(Note that you will probably be prompted for your administrator password after the first command)
Running The Installer
Okay! Now that everything has been set up, we’re ready to roll (remember, you’ll only need to do the above installation steps one time... from here on out you can skip to these steps every time you want to install a new Concrete5 site on your computer).
First, make sure MAMP is up and running on your computer:
Next, open the Terminal and
cd into the directory where you installed the program (e.g.
Now, run the command line installer from the Terminal like so:
(don't forget the leading
You will now be prompted with a series of questions about this installation.
- Concrete5 versions: enter the line number next to the version you wish to install (not the full version number itself). The versions are listed with the most recent first. You can just hit ENTER without making a selection to choose the most recent version. Note that the oldest version available is 5.5.1, because this was the first version of Concrete5 that allowed for command-line installations. Also note that only the most-recent “point release” of each version is included (for example, there’s no 5.6.0 or 126.96.36.199), but if you want to be able to install those, you can uncomment the other versions near the top of the “local_mamp.php” file (in the $c5_versions array).
- Target Directory: enter the directory you wish to install this site to (note that it must always be within the HTDOCS_DIR directory you entered in the settings.php file).
- Database Name: enter the name of the site’s database. Note that this installer will create this database for you, so it should be a name that does NOT already exist!
- Site Name: the name of your site. Note that due to limitations of the Terminal, any quotation marks, apostrophes, or exclamation points will be stripped out of the name (but you can change the site name via the dashboard after it’s been installed if you want to).
- Sample Content: Choose whether or not you wish the “sample content with blog” to be installed on this new site. This is the same as choosing the “starting point” through the normal browser-based installation procedure.
Remove empty top-level folders: Choosing this option (by entering “y”) will delete the empty folders at the top-level of your new site (and some files too):
Why would you want to do this? Well, I personally like to keep my top-level directory nice and clean. There’s no reason to have empty folders there. Furthermore, when I do need to use any of those folders to override the core system, I can just create it then -- now when I look at my sites, I can quickly see at a glance where my core overrides are. Otherwise, you never know unless you open each folder and see if there are files inside. But I understand this is an unorthodox way to do things in the Concrete5 world. If it makes you feel queezy to do this, then by all means just skip this prompt by entering “n” (or just hitting ENTER, since “no” is the default choice).
- Remove non-english Zend Locale Data: Choosing this option (by entering “y”) will delete all of the non-english language localization files from the
SITEROOT/concrete/libraries/3rdparty/Zend/Locale/Datadirectory (for a full list of the files that will be deleted, look at the
remove_zend_locale_data.txtfile in the same directory as all the other files for this program). Why would you want to do this? If your site is english-language only, then all the other language data is unnecessary. If you add up all of those files, they total between 8-10MB (!!). If you’re just installing some sites on your computer for addon testing, then this doesn’t really matter much. But if you are building a site for a client and use version control such as Subversion or Git, this can save you a ton of space and cut down the time it will take for your initial import. But as with the “remove empty top-level directories” option, this is a non-standard thing to do and if it makes you feel queezy then by all means skip it by entering “n” (or just hitting ENTER since “no” is the default choice).
What It Does
After you’ve answered all of the questions, installation will proceed. Watch the screen and revel in all the clicking you don’t have to do!
The script will download the appropriate version of Concrete5 for you:
...then it will create the new database for you:
...then it will install Concrete5 for you (this is the only part of the process that the default command line installer will actually do for you):
...and eventually you will have your new site installed:
Out of courtesy, the installer will also open the files directory in the Mac Finder:
...and open the site in your browser:
(note that it brings you to the Cache Settings page in the dashboard, because most likely the first thing you’ll want to do is disable the cache for development purposes).
Also note that the dashboard does not show the rotating background image, nor does it check for updates or connect to the marketplace or display the “newsflow” dialog -- these have all been disabled in the
config/site.php file. You can alter the config settings that are applied to your new sites by editing the
append_to_config_site_php.txt file which exists in the same directory as the installer program.
If you get an “Unable to connect to database” error, make sure you have MAMP running, make sure your database settings are correct in the settings.php file, and make sure you’ve done the “mysql.sock” commands mentioned in the installation instructions above.
If you try to install Concrete5.5.1, you will see a few warning messages in the Terminal during the installation process. As far as I can tell, these don’t adversely affect anything so you can safely ignore them.