If you believe my posts will help someone please feel free to share.
I am messing around installing Drupal 8 using Composer on an Amazon EC2 instance and ran into some errors. To eliminate whether it is Drupal 8 or some other factor, I installed Drupal 7 in another virtual user directory.
For this example I am using Apache 2.4, PHP 7.1 and MySql 5.4 and using Apache per user web directories.
Log into your remote server on using ssh
I like to download and extract files in my home directory.
To make sure you are in the home directory (you most likely will be you) you can type
[user ~]$ cd ~
cd = change directory
You can download Drupal remotely using wget or curl. I will use wget here.
If you are curious if you have wget on your machine you type this into you terminal. It will tell you the file path the webget binary if it is on your machine.
[user ~]$ which wget
The Drupal installation instructions give you an example command:
But if you are new to this you might not realize that you need to replace “.x” with the actual version you want to download. At the time of this writing, the latest Drupal 7 version is 7.5.9
So you command will actually look like this in your terminal
[user ~]$ wget https://www.drupal.org/files/projects/drupal-7.5.9.tar.gz
Hit Enter and it will begin to download
One it is done you might want to look to make sure it is there.
[user ~]$ ls
ls simply is a command to list the contents of the directory you are in.
You will see it is zipped up. So we need to unzip it. Just use the exact file name.
tar -xvzf drupal-7.59.tar.gz
Now if you list the contents of the directory again we will see the zipped files, the unzipped directory by the same name, and the directory we want to host our site in, public_html.
[user ~]$ ls
drupal-7.59 drupal-7.59.tar.gz public_html
I have configured Apache to serve my Drupal site from public_html so I need to move my Drupal files , the contents of the drupal-7.59 directory to public_html
We can do this by using the copy command, cp. I prefer cp to mv (move) here simply because if I have done something wrong I have a known good copy.
[user ~]$ cp -R drupal-7.59/* public_html
If you don’t put the -R (recursive) option it won’t cp the directories inside the drupal-7.59 directory.
I like to look and make sure it copied over. So change directories (cd) to public_html and list (ls) the contents of the directory.
[user ~]$ cd public_html
[user public_html]$ ls
Not done yet.
Depending on how your server is set up you may or may not have to create a settings file and a files directory. If you are using the web installer the installer will tell you if Drupal was not able to create these for you.
If Drupal hasn’t created these for you, it will look something like below. It tells you exactly what the error is and what you need to create and modify. If it has you will just be able to proceed.
OK so here is where it gets a little tricky if you aren’t used to navigating in a terminal. If you have been following along in this post, you should be in the public_html which is the root of your Drupal web application.
If you are lost or aren’t sure at any point and need to know where you are relative to the root of machine you are on simply type pwd (present working directory)
Let’s take a look:
[user public_html]$ pwd
In this example you are in the public_html directory (your Drupal root) which is inside your user home directory, /home/user/public_html relative to the root of the directory structure.
If you aren’t there are aren’t sure you can always change directories (cd) and specify the absolute path ie /home/user/public_html where user is your username.
Hopefully that didn’t confuse you too much.
All that to say, you want to be in public_html and you want to work relative to there from here on out.
Let’s tackle this one first.
Because we got the errors we need to create a settings.php file and change its permissions so the web installer will work.
We could do it all in one command like which would make a directory (mkdir) called files in public_html/sites/default
[user public_html]$ mkdir sites/default/files
or just to illustrate, we can transverse each directory then make the new directory (mkdir), files
Starting at public_html
[user public_html]$ cd sites
[user public_html]$ cd default
[user public_html]$ mkdir files
The difference here is the first option leaves you in the public_html directory whereas the second option puts you in the public_html/sites/default directory.
If you go back to web installer you see a different error message. The directory is there but is not writeable by Drupal.
So we need to change the permission on the directory.
We change permission with the command chmod (change mode). Understanding file permissions is beyond the scope of this post. On this particular server we want to the permission of site/default/files to 777.
[user public_html]$ chmod files 777