Drupal is a popular content management system used by 2% of all the websites on earth. Drupal is known for its flexibility. However, this flexibility comes at the cost of increased server resource requirements and a sharp learning curve. This website is made on Drupal 8. One of the major advantage (or disadvantage for that matter) of Drupal is that the Drupal core is frequently changing. A new version of Drupal core will have major changes in APIs. The advantage of this is that the CMS will get to adapt to changes in the trends of websites. In addition, it can clean up and redesign its core more intuitively, resulting in better performance and leaner code. However, this poses certain disadvantages as well. The developers will have to re-write their modules and themes for every new version of the core. This might be easy for small modules, but gets really difficult as the size of the code increases, especially if was using an old deprecated API.
The latest version of Drupal Core, Drupal 8 is under construction. Its alpha version is now available for testing purposes. Here, I describe how to get Drupal 8 installed on a system from scratch. This tutorial assumes the following:
- You have root access to a server with resources greater than or equal to the one specified on this page.
- You have an SSH client such as PUTTY installed on your computer to access the server and are familiar with the procedure of doing so.
- You have a text editor installed on your server. Nano is a good text editor and we use that in this tutorial. If you don’t have nano installed, Type in the following command to your putty console after logging in as root:
yum install nano
Type in “y” when prompted and you have a Nano installation in place.
From the requirements page, it is understood that Drupal requires a server daemon (such as Apache or Nginx), PHP language, a database daemon (such as MySQL, mariadb). Here, we will start with a server installed with Centos 6, and will add the dependencies to it. I will be using Apache as the server daemon and MySQL as the database daemon as both of them are the most popularly used options.
The system requirements of Drupal 8 are different from that of Drupal 7, in the fact that Drupal 8 requires PHP 5.4. There are added complexities to the installation of Drupal 8. However, you are guaranteed an effortless installation if you follow the steps mentioned in this tutorial.
At this point in the tutorial, I assume that you have centos installed and ready, you have a clearly configured iptables, and you have edited your hosts file and set the server root to /var/www/html
Step 01 : Install and Configure httpd
It is in this step that we install Apache to the server. Type in the following command
yum install httpd
Enter “y” to any question that you are asked in between. This should finish the installation of httpd without much trouble. Try to access your website’s domain name (if you have configured your DNS) or its IP address in your browser. It should display an Apache http server test page powered by centos. That means that the step is successfully completed.
We can now instruct the server to start httpd automatically every time the server is turned on
chkconfig httpd on
We can now start httpd
service httpd restart
Drupal uses a local .htaccess file which defines the redirect rules. These redirects help to serve clean urls (without ? or q=) to the visitors. This is also a basic necessity in case of Drupal 8. However, Apache prevents this as a default behavior. We should make sure that Apache has the necessary components to rewrite the urls, and that local use of a .htaccess file is permitted. Let us now go to the file that defines them all.
See that there is a line called
LoadModule rewrite_module modules/mod_rewrite.so
And that it is not commented out (not preceeded by a #). If not, then add the line or remove the preceding #. In the same file, locate this portion:
Change AllowOverride from “None” to “All”. It should now look like:
Once that is ready, save and exit (ctrl+x and y) we are ready to proceed further.
Step 02 : Install and Configure MySQL
We should configure the database daemon now. Start with the following command
yum install mysql-server
Type in “y” when asked for confirmation. We can now start MySQL
service mysqld restart
We can now instruct the server to start mysqld automatically every time the server is switched on.
chkconfig mysqld on
Now we can proceed to configure mysql
Hit enter when asked for the current password. We don’t have a password yet, as this is our first use. Type in Y and hit enter when asked “Set root password?”. Give a new root password for interacting with mysqld now. Re-enter the password to confirm it. Type in “y” to the next four questions and this should give you a pretty standard installation. Advanced users may want to read the questions, understand them, and give answers according to their needs. Now we have a running mysql installation in place.
Step 03: Installing and configuring PHP
As evident from the system requirements page, Drupal 8 requires PHP 5.4. Unfortunately, the default centos repo contains installation of PHP 5.3.3 only. So we need to download PHP 5.4 from outside the yum repo. In this tutorial, we install PHP 5.4.3 provided by webtactic. This requires that we modify the yum repository and add the packages provided by webtactic.
Now we can use yum to install PHP 5.4
yum install php54w
Type in “y” when prompted.For PHP to interact with mysql, it requires the php54w-mysql package. Let us install that:
yum install php54w-mysql
Type in “y” when prompted. In addition, for Drupal to function, we require a few more extensions of PHP. Let us install them together:
yum install php54w-xml php54w-mbstring php54w-gd
Type in "y" when prompted. Let us restart httpd so that PHP will start functioning:
service httpd restart
Let us now check whether we have the PHP version successfully installed. For that we need to use the function phpinfo(). Let us start by creating a file in the document root, where it can be accessed from your browser.
Copy and paste the following code into the field.
Now let us access the file in the browser by typing your_ip_address/info.php or domainname.com/info.php into your browser's address bar. A page displaying all the information about your PHP installation will appear. Verify that the PHP version is 5.4.3 and the extensions mbstring, gd, pdo, xml and mod_rewrite are enabled in the list.
Step 04: Creating a Database
Before starting with the installation of Drupal, we need to make sure that we have a mysql username, password and database set up for Drupal to use. Type In the following command to start mysql:
mysql –u root -p
Type in the root password that you set up in step 02. Now let us create a database for Drupal to use. Let us name it Drupal itself. Feel free to give whatever name you want:
CREATE DATABASE drupal;
Now we need to create a username so that Drupal can login to mysql and make changes to the database. I am going to create a username “drupal8” and a password “password”:
CREATE USER drupal8@localhost;
SET PASSWORD FOR drupal8@localhost=password(“password”);
We now have to grant sufficient privileges to the user “drupal8” for the database “drupal” so that our Drupal installation can make the necessary changes to the database:
GRANT ALL PRIVILEGES ON drupal.* TO drupal8@localhost IDENTIFIED BY ‘password’;
Now let us refresh MySQL:
Let us exit the mysql command line. Type in:
Let us restart httpd before we proceed any further:
service httpd restart
Step 05: Installing Drupal 8
We can now download and install Drupal 8. The stablest version available at the time of writing this tutorial is alpha 13. So we will start from there. Make sure that you are in the root folder, and type in the following command:
We can now extract the compressed archive that we downloaded:
tar zxvf drupal-8.0-alpha13.tar.gz
We can now copy the extracted files to the document root on the server:
mv drupal-8.0-alpha13/* /var/www/html
We now have everything in place to start installing Drupal. However, before we proceed any further, we need to allow the Drupal installer to make some necessary changes to your file system. So we need to change the file system permissions temporarily for the process of installation:
chmod 777 /var/www/html/sites/default
During the installation, Drupal will store settings specific to your website into a file located in /var/www/html/sites/default/settings.php. However, Drupal 8 does not come with such a file by default. An example settings.php file is available at /var/www/html/sites/default named as default.settings.php. We can use a copy of that file as a temporary settings.php file for your website, where the installer can make modifications specific to your website. Use this command to copy it over:
cp /var/www/html/sites/default/default.settings.php /var/www/html/sites/default/settings.php
We can now give the installer permission to modify the file:
chmod 777 /var/www/html/sites/default/settings.php
We can now access the installer by pointing your browser to your server’s IP address or to your domain name. The installer will launch automatically. Here are the steps in the installer:
Language : you may choose English
Profile : Default profile is good enough for most people. If you are familiar with Drupal before, you may start from Minimal.
Verify requirements: If you followed all the steps mentioned above, there won’t be any problems with the requirements.
Database Configuration: We need to provide Drupal with information as to how to communicate with the database located on the server. We have created this information in step 04. In this specific example, the values are
Database name: Drupal
Database username: drupal8
Database password: password
Now you will see a message saying that Drupal is being installed, and you will be taken to the configuration page where you can configure your New Drupal 8 Website. On the configuration page, you will see a message asking you to take off the necessary permissions that you granted to the installer to edit your file system. This has to be done once you completed the whole installation of the website.
Type in the following commands after you completed your installation.
chmod 555 /var/www/html/sites/default
chmod 555 /var/www/html/sites/default/settings.php
If there is any step in this tutorial that you are not clear about, or you encountered any error, feel free to comment below and we will clear it out for you.