Drupal has managed to hold its own in the fiercely competitive world of content management systems. Many attribute this success to outstanding security related features which ensure that a Drupal installation is much more secure than other CMSs. In addition, Drupal offers all the bells and whistles that users associate with any modern CMS. Given all this, there is little wonder that Drupal is steadily gaining market share.
As of today, the latest version of Drupal is 8.2.3. However, the majority of Drupal users still prefer Drupal 7 over the newer version, as the transition from Drupal 7 to Drupal 8 is currently riddled with complex issues. Additionally, many modules are not yet compatible with Drupal 8, which poses challenges when looking for the best Drupal hosting that fully supports both versions and ensures a smooth experience for users regardless of the version they choose.
In this article, I will demonstrate how you can install Drupal 7 on your local machine. Working on a Drupal project that is hosted on the local machine ensures that you could modify all aspects of the project without affecting the live version. Once you are done, you could easily replace the existing version on the live web server with the new one.
Stop Wasting Time on Servers
Cloudways handle server management for you so you can focus on creating great apps and keeping your clients happy.
Install a Web Server Package
The prerequisite of the process of installing Drupal 7 on the localhost is a web server package.
Essentially, a web server package is a self-contained package that has all the necessary software components required to run a web server on a local machine.
I recommend two popular open source web server packages: XAMPP and WAMP. Both these packages have PHP, Apache server, MySQL and related software components that are required to host and run websites and web apps on the local machine.
For the purpose of this article, I will use XAMPP.
Fire up your browser and navigate to the official XAMPP page.
Download the version of XAMPP that is compatible with the OS of the local machine. Once the download finishes, install the software.
Remember to use Xampp-control.exe instead of setup.bat for launching XAMPP. You will be presented with this screen.
To run Drupal, I need Apache web server and MySQL database. To start these components, click Start button for both services.
NOTE: If you are logged into Skype at this point, an error will occur. Sign out of Skype and then start Apache and MySQL. You can sign back into Skype after starting the services.
If everything goes according to the plan, you will see the following screen.
Change Parameters in Configuration Files
Lack of available PHP memory allocation and execution time are two very common sources of errors during Drupal installation. To prevent these errors, I will change several parameters in PHP config file. This file can be accessed in two ways.
The first method of accessing PHP config is through the XAMPP control panel. Click the Config button for Apache in the XAMPP Control Panel .
The second method is manually accessing the php.ini file located at xampp/php/php.ini
I will change the following settings in the php.ini file:
max_execution_time = 600
max_input_time = 600
memory_limit = 512M
post_max_size = 64M
upload_max_filesize = 64M
mysql.connect_timeout = 600
The next step is making changes to my.ini. This file is located in MySQL directory and could be accessed in two ways.
The first method is clicking the Config button for MySQL in the XAMPP Control Panel
The second method is manually accessing the my.ini file located at xampp/mysql/bin/my.ini
I will change the following parameters in this file:
max_allowed_packet = 64M
innodb_flush_log_at_trx_commit = 2
The pre-installation changes to the environment are now done and I will now move to the actual installation of Drupal on the local machine.
Download and Install Drupal 7
This is the final stage in the installation of Drupal on the local machine. Now, we arrive at the final step of our Drupal 7 installation journey.
First, get the installation package for Drupal 7. For the purpose of this article, I will download the installation package for Drupal 7.52. After the download completes, extract the downloaded file to any location. To make the process easier, rename the folder inside the extracted folder to drupal7.
Next, copy the drupal7 folder to xampp/htdocs/. Open XAMPP control panel and verify that both Apache and MySQL services are active. If not, click Start button to launch the services.
In the browser, navigate to 127.0.0.1. The following screen will open in the page.
Click phpMyAdmin in the top-left and the following page will open:
Click Databases, enter the database’s name as drupal7 and click the button to create it. Make sure that the name of the database should be same as the folder in xampp/htdocs/.
Now, open a new tab in the browser and type localhost/drupal7 in the address bar. The installation page of Drupal 7 will open.
For the purpose of this article, choose the Standard option and click Save and continue.
Choose your desired language from the next page and click Save and continue page.
Next, the installation process will verify requirements and you will be brought to the Database Configuration page.
On this screen, enter the database name that you entered when you created the database in the phpMyAdmin panel. Next, enter the database username and password you entered in PhpMyAdmin. If you skipped the step earlier, just set the username to root and leave the password field empty. Finally, click the Save and continue button. The installation will begin and you would be able to follow the progress through a progress bar.
After installation finishes, the website configuration page will open where you could set website related options. where you can set various settings for the website.
On the next screen, click the blue link to go to your new Drupal website.
The website is now ready for your Drupal project. Also do see our another blog post on, How To Build An Ecommerce Website With Drupal 7.
Conclusion
In this article, I discussed how to setup a web server package at your local machine and then install Drupal 7. If you have a question or would like to contribute to the discussion, please leave a comment below.
Shahzeb Ahmed
Shahzeb is a Digital Marketer with a Software Engineering background, works as a Community Manager — PHP Community at Cloudways. He is growth ambitious and aims to learn & share information about PHP & Laravel Development through practice and experimentation. He loves to travel and explore new ideas whenever he finds time. Get in touch with him at [email protected]