
A local testing environment
Alternatively, you can set up a local testing environment for your site. This allows you to set up Drupal and other applications on your computer. A local testing environment can be a great tool for learning a piece of software. Fortunately, open source tools can automate the process of setting up your testing environment.
PC users can use XAMPP (http://www.apachefriends.org) to set up a local testing environment; Mac users can use MAMP (http://www.mamp.info).
If you are working in a local testing environment set up via XAMPP or MAMP, you have all the pieces you need to start working with Drupal: your domain, your web host, the ability to move files into your web directory, and phpMyAdmin.
Setting up a local environment using MAMP (Mac only)
While Apple's operating system includes most of the programs required to run Drupal, setting up a testing environment can be tricky for inexperienced users. Installing MAMP allows you to create a preconfigured local environment quickly and easily using the following steps:
- Download the latest version of MAMP from http://www.mamp.info/en/index.html. Note that the paid version of the program will download as well. Feel free to pay for the software if you wish, but the free version will be sufficient for our needs.
- Navigate to where you downloaded the
.zip
file, and double-click to unzip it. Once it is unzipped, double click on the.pkg
file that was contained in the.zip
file. - Follow the directions in the wizard until you reach the Installation Type screen. If you want to use only the free version of the program, click on the Customize button:
- In the Custom Install on "Macintosh HD" window, uncheck the MAMP PRO option and click on the Install button to install the application:
- Navigate to
/Applications/MAMP
and open the MAMP application. The Apache and MySQL servers will start, and the start page will open in your default web browser. If the start page opens, MAMP is installed correctly.
Setting up a local environment using XAMPP (Windows only)
- Download the latest version of XAMPP from http://www.apachefriends.org/en/xampp-windows.html#641. Download the
.zip
version. - Navigate to where you downloaded the file, right-click, and select Extract All.... Enter
C:\
as the destination and click on Extract. - Navigate to
C:\xampp
and double-click the xampp-control application to start XAMPP Control Panel Application: - Click on the Start buttons next to Apache and MySql.
- Open a web browser, and enter
http://localhost
orhttp://127.0.0.1
in the address bar, and you should see the following start page: - Navigate to
http://localhost/security/index.php
, and enter a password for MySQL's root user. Make sure to remember this password or write it down in your notebook because we will need it later.
Configuring your local environment for Drupal
Now that we have the programs required to run Drupal (Apache, MySQL, and PHP), we need to modify some of their settings to match Drupal's system requirements.
PHP configuration
As mentioned before, Drupal 7 requires Version 5.2.5 or higher, and as of the writing of this book MAMP includes Version 5.4.4 (or you can switch to Version 5.2.17) and XAMPP includes Version 5.4.7. PHP configuration settings are found in the program's php.ini
file.
For MAMP, the php.ini
file is located in /Applications/MAMP/bin/php/[php version number]/conf
, where the php version number
is either 5.4.4 or 5.2.17.
For XAMPP, the php.ini
file is located in C:\xampp\php
.
Open the file in a text editor (not a word processor), find the Resource Limits section of the file and edit the values to match the following values:
max_execution_time = 60; max_input_time = 120; memory_limit = 128M; error_reporting = E_ALL & ~E_NOTICE
The last line is optional and is used if you want to display error messages in the browser, instead of only in the logs.
MySQL configuration
As mentioned before, Drupal 7 requires MySQL Version 5.0.15 or higher. MAMP includes Version 5.5.25 and XAMPP includes Version 5.5.27. MySQL's configuration settings are contained in a my.cnf
or my.ini
file.
MAMP does not use a my.cnf
file by default, so we need to copy the my-medium.cnf
file from the /Applications/MAMP/Library/support-files
directory to the /Applications/MAMP/conf
folder. After copying the file, rename it to my.cnf
.
For XAMPP, the my.ini
file is located in the C:\xampp\mysql\bin
directory.
Open the my.cnf
or my.ini
file in a text editor, find the following settings and edit them to match the following values:
# * Fine Tuning # key_buffer = 16M key_buffer_size = 32M max_allowed_packet = 16M thread_stack = 512K thread_cache_size = 8 max_connections = 300 # # * Query Cache Configuration # query_cache_type = 1 query_cache_limit = 15M query_cache_size = 46M join_buffer_size = 5M # Sort buffer size for ORDER BY and GROUP BY queries, data # gets spun out to disc if it does not fit sort_buffer_size = 10M innodb_flush_method = O_DIRECT innodb_file_per_table = 1 innodb_flush_log_at_trx_commit = 2 innodb_log_buffer_size = 4M innodb_additional_mem_pool_size = 20M # num cpu's/cores *2 is a good base line for innodb_thread_concurrency innodb_thread_concurrency = 4
After you have made the edits, you have to stop and restart the servers for the changes to take effect. Once you have restarted the servers, we are ready to install Drupal!