Spinning up a CentOS server for Drupal
Spinning up a CentOS server for Drupal
Language
English
Spinning up a CentOS server for Drupal
This blog post was originally going to be an email to someone who needed a bit of help getting set up. Then I realised it would be a nice blog. So here we are! CentOS and Drupal from the top.
Tue, 2016-07-12 16:33By greg
Before I start, I make no claim this is the best way to set up CentOS. I'm sure it isn't the only way, and I'm sure there will be other, more thorough, howto articles about the general setup of CentOS that are much better than this one. Heck, I don't even subscribe to CentOS (or RHEL) as the best distro for hosting Drupal (we usually use Debian), but that's debatable. What this blog is is a way to get going quick with a CentOS Linux server and Drupal.
On most virtualisation platforms you can probably choose a CentOS base image and start with an installed operating system. If you can't, or if this is a spare desktop computer or something, you'll need to download CentOS and make some install media. The download site is here - I recommend the "Minimal ISO" for servers:
https://www.centos.org/download/
Then you need to turn that into installable media. The easiest way to do that these days is a "live USB". Fortunately, CentOS have provided an excellent HOWTO for that step already, and there is no sense in me repeating myself, so if you need to make a live USB, go and read this:
https://wiki.centos.org/HowTos/InstallFromUSBkey
Once you have a live USB, you can restart the target computer and (this obviously varies from computer to computer) interrupt the boot sequence and boot from the USB stick. Follow the install wizard and install CentOS. Once again, someone has done the hard work for me here, so no sense in writing all that again! Here's a nice run-through, with pictures, of the CentOS 7 installer:
https://www.howtoforge.com/tutorial/centos-7-minimal-server/
If you are in a corporate environment, and you don't appear to be able to get Internet access post-installation, you may need to use a proxy server. You should be able to ask your local desktop support staff about this, if you do, here is a good article about how to set that up with some pretty straightforward terminal commands:
http://www.thesysadminhimself.com/2013/08/configuring-web-proxy-on-cento...
OK, so we have CentOS, we have an Internet connection. Before we go on, let's just look at the basics of running commands as the root user. If you're not root, you can wrap any terminal commands in this:
su -c "my command here"
Note, it will ask you for the root user password, not your user's password. Or you can simply become the root user like this:
su root
Again, it's the root user password you'll be asked to give. I will assume you're operating as a normal user and using su -c with my examples, as that's consistent with the way RHEL does things, but if you switch to root then the su -c stuff is not necessary.
Next job is to update the system, just to make sure we have the latest of everything:
su -c "yum update -y"
Now, to avoid what scar-riddled Linux veterans call "dependency hell", you'll want to install a package called "yum-priorities". It isn't installed as standard, because some CentOS heavy hitters believe it's a bad idea, due to the restrictions it places on package availability. But I can tell you from bitter experience, it's vital protection for the beginner. In my early RHEL days I've had to start over after installing my way into a hole without yum-priorities!
It allows you to tell the package manager which repositories are more important, thus avoiding a situation where the package manager tries to install different packages from different repositories which depend on different versions of the same sub-packages. Essentially, if you don't give you package manager some sense of priority over software sources it becomes a free-for-all, it installs packages to achieve one purpose that then block you from doing something else, and the whole thing becomes a bowl of Linux package spaghetti. So, trust me:
su -c "yum install yum-priorities -y"
We'll come back to that in a moment. Now we'll install some extra repositories. The core RHEL / CentOS repositories are pretty slim. They lack a lot of useful software and they also hold quite old versions of other software you need, so you'll want to gain access to a wider set of packages and a more up to date source. The most common and trusted source for this is a repository called EPEL, which is managed by the Fedora Project, which is kind of RHEL's open source testing branch. (It's also my desktop of choice for some years.) Rackspace have written a good HOWTO on installing EPEL and other useful repositories:
https://support.rackspace.com/how-to/install-epel-and-additional-reposit...
For Drupal 7 you probably only need EPEL. For Drupal 8, you'll want the Remi repository too, because Remi provides latest PHP, whereas EPEL is sporting (a security patched and supported version of) PHP 5.4 (at time of writing). In any case, follow the above HOWTO as far as you need to.
Now you have all your repositories in place, you can configure yum-priorities. Again, someone else has written good instructions for this, so rather than re-write them, here's a link:
https://wiki.centos.org/PackageManagement/Yum/Priorities
We're almost there now!
su -c "yum install php httpd mysql -y"
That will go off and fetch all the bits Drupal needs in order to function. You're so close now, you can smell it! Just one last HOWTO to go through: The actual installation of Drupal itself, which again, someone else has thoughtfully documented for us:
https://www.howtoforge.com/centos-7-drupal-installation
One extra thing. For bonus points, install memcached and the memcache module for Drupal, to use this simple cache store for Drupal's caching instead of the database, and improve the performance of your Drupal website significantly.
su -c "yum install memcached -y"
All you need to do then is follow the README file. And that's it! Happy Drupalling!
Case studyDesign-led Drupal for a local authority