Setting Up Drupal

php
drupal

#1

For Drupal there are some installation guides around which tell you to install PHP first, but that’s not necessary with Cloud9.
You don’t need to install MySQL either, it is already preinstalled in PHP workspaces.
Just make a new workspace, choose PHP, go to the Terminal, and execute the following:

cd $HOME
curl -O http://ftp.drupal.org/files/projects/drupal-7.39.tar.gz
tar xvf drupal-7.39.tar.gz
mv drupal-7.39/* workspace/
mv drupal-7.39/.htaccess workspace/
cd $HOME/workspace
mysql-ctl install
mysql-ctl start
mysql-ctl status

Open the file install.php in the file tree, and while opened, click on the “Run Project” button in the menu bar on top of the IDE.
An URL will be shown at the bottom of the page, something like https://projectname-username.c9.io/, but with your username and workspace name in it.

Copy the url in a new browser tab and you will see the install page of Drupal

Broken Styles

If the Drupal install is trying to load certain stylesheets over HTTP and the page is loaded with HTTPS then those stylesheets will break and leave the page unstyled. If this occurs, reload the page with http:// at the beginning.

You can now proceed with the installer.

Now be careful inserting the correct values for the database. You need to change the values as follows:

User: Your username
Database: c9 (or you may make another database before running this install and use that one)
Host: 127.0.0.1

No Localhost

localhost will not work, while 127.0.0.1 will.

Be sure to open the Advanced Options in the database settings page so you can change the host to 127.0.0.1.

Now fill the form with the correct site information:

Continue the setup and enjoy your website!

Correct the broken styles by enabling SSL as follows: go to the Terminal, and execute the following:

cd $HOME/workspace/sites/default
sudo pico settings.php

Scroll down to the line:

# base_url = 'http://www.example.com';
$base_url = 'https://projectname-username.c9.io';  // NO trailing slash! 

Press Ctrl+x to save the file
Press Y to confirm you want to save the changes.
The file name that will be overwritten (settings.php), is shown. Press Enter to confirm.

Refresh the browser panel and your drupal-site will appear including stylesheets.


Drupal project on Cloud9
Is it possible to install CiviCRM on Cloud9?
Tutorials - Table of Contents
How to select WordPress or Drupal icon to work?
#2

Thanks for this post, just installed Drupal and it was a breeze.
Just a quick note for anyone else looking to install Drupal:

  • Drush can further simplify the install process. Here’s a one liner to get it going: sudo apt-get install drush

  • Using a separate tab in my own browser fixed the issue, but good to be aware of http/https when using c9.io’s Preview browser as noted above. Also see here.


#3

Actually I still need help with installation Drupal on cloud9.
I follow link as below but end up with error(see output after link). I’ve tried drupal 7.3.2 and drupal 8.3.2
How to fix it?

d HOME tatyana_pol:~ curl -O http://ftp.drupal.org/files/projects/drupal-8.3.2.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
tatyana_pol:~ tar xvf drupal-7.3.2.tar.gz tar: drupal-7.3.2.tar.gz: Cannot open: No such file or directory tar: Error is not recoverable: exiting now tatyana_pol:~ tar xvf drupal-8.3.2.tar.gz
tar: drupal-8.3.2.tar.gz: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tatyana_pol:~ curl -O http://ftp.drupal.org/files/projects/drupal-7.39.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 tatyana_pol:~ tar xvf drupal-7.39.tar.gz
tar: drupal-7.39.tar.gz: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tatyana_pol:~ $


#4

I be able to open file but setting database create error. … I’ve used for database c9 and my user_name that was created earlier… but it create only error…
How to settle or is it possible database for Drupal8?
thanks.


#5

Since I don’t get update, I assume that there is no way to settle database for Drupal 8 and therefore Cloud9 could not host Drupal8.
thanks.


#6

@tatyana_pol Drupal 8 is 100% supported on Cloud9. By the looks of your errors, you haven’t successfully downloaded Drupal before trying to extract it.

Notice that the lines
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
are showing you 0% for everything and then you run
tatyana_pol:~ $ tar xvf drupal-7.3.2.tar.gz
and the response
tar: drupal-7.3.2.tar.gz: Cannot open: No such file or directory
is telling you that it cannot find drupal-7.3.2.tar.gz

Try copying and pasting this into your terminal - I have tested this and it definitely works :slight_smile:

cd ~/workspace wget http://ftp.drupal.org/files/projects/drupal-8.3.2.tar.gz -O ~/workspace/drupal-8.3.2.tar.gz mkdir drupal8 tar -zxvf drupal-8.3.2.tar.gz -C drupal8/ --strip-components=1

That will download and decompress Drupal 8.3.2 into a directory called drupal8 with the path /home/ubuntu/workspace/drupal8/ Depending on how you have configured your workspace, you may need to move it to another directory in order to access it via a browser. For example, I use Apache and set the vhost path to /home/ubuntu/workspace/public/ because the public directory is where I normally extract Drupal, but your setup may be different.

I hope that helps.


#7

Take a look on my latest posts on Cloud9 - I successfully downloaded Drupal8 but I would not be able to complete the process of installations of database. I use c9 for database and it gave me error.Do you completed installation and could see the Drupal side? Is so, what datas do you use for database?thanks.


#8

Sorry, I realised after I made the post that you passed that issue.

I have multiple workspaces with Drupal installed with the database hosted on the workspace… I just use my workspace username with no password to connect to the database, connecting the host 127.0.0.1 although localhost also works.

Here is my settings.php file for a Drupal 8 install

$databases['default']['default'] = array ( 'database' => 'c9', 'username' => 'imlaurie', 'password' => '', 'prefix' => '', 'host' => '127.0.0.1', 'port' => '3306', 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', 'driver' => 'mysql', );

What is the error you are receiving when trying to connect to the database. If you explain all of your steps, we can probably work out what the issue is.

It might be worth checking that mySQL is running, from the command prompt type mysql and hit enter. If you get something similar to
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
MySQL isn’t running, so you can manually start it using sudo service mysql start or by using one of the pre-configured “runners”.

For example the Apache based one should start MySQL for you… from the IDE toolbar, go to Run -> Run With.. and choose Apache httpd (PHP, HTML).


#9

I also “have multiple workspaces with Drupal installed with the locally-hosted database…” and I have Drupal installed in my server as well.But i have problem installed Drupal in cloud9 and I also provide screenshot (take a look on it) indicated the error that I encounter: it pointed to the wrong database name. I’ve used c9 as was directed in your tutorial.Let me know what credential for database need to use in order to complete the installation and see Drupal side.thanks.


#10

When I said “multiple workspaces with Drupal installed with the locally-hosted database…” I meant c9.io workspaces.
I cannot see your screenshot in this thread, do you mean the one in your other post?

If so, the error is saying that access to the database is denied for user admin. If you have not configured a MySQL user admin then change the username to your c9.io username and leave the password empty/blank. If you have set up the MySQL admin user, then either you have your password incorrect or MySQL is not running.

Let me know what credential for database need to use in order to complete the installation and see Drupal side.thanks.

As you can see in my previous reply, my credentials, specified in sites/default/settings.php are as follows:

$databases['default']['default'] = array ( 'database' => 'c9', 'username' => 'imlaurie', 'password' => '', 'prefix' => '', 'host' => '127.0.0.1', 'port' => '3306', 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', 'driver' => 'mysql', );

So, to summarise:

if you are working through the Drupal installation wizard, by default, you need use set the database name to c9, the username to your c9.io username and leave the password empty/blank. You need to set the hostname to 127.0.0.1


#11

I’ve used:Root user: tatyana_polDatabase name: c9I’ve seen the url as below:https://drupal.tatyana_pol.c9users.ioWhat if any need to change to complete the installation?thanks.


#12

I could see Drupal side now. On Report/Status Report error - "trusted host not enabled"I’ve tried to fix it but could not for some reasons safe file.Could you fix this error?thanks.


#13

Great, yes that we can fix -
sudo chmod 755 sites/default/settings.php
that will let you edit and save the file, allowing you to add your trusted host - during development, you should be OK disable the trusted host configuration but when the website is live, you should definitely enable it.

There are more options/approaches to disabling trusted hosts during development, but let’s get it working first :slight_smile:


#14

I’ve changed permission to 755 and fixed error.
What permission it should be: 644?
thanks.


#15

Great! Is everything working correctly now then?

Unless you have configured it otherwise, Drupal 8 will attempt to sort file permissions for you, but yes 644 or 555 will do the trick.
You can also check that your files are secure by navigation to admin/reports/status so for example https://drupal.tatyana_pol.c9users.io/admin/reports/status


#16

Right now the tests all green but I could not see app because I’ve tried to put code for security keys as below - it said that the hosts are wrong.

//code
settings['trusted_host_patterns'] = array( '^drupal-tatyana-pol\.c9users\.io’,
);
I put similar code for local host and for hosting system and putting those codes make test green and the same time show the page.
As I said, not able to configure trusted hosts create the secure vulnerability and this error need to be fixed.
What is the hosts for Cloud9/how to change the code as above to see the page and satisfy the trust hosts condition?
thanks.


#17

if the address to acccess the website is that URL, then you just ned to escape the periods drupal-tatyana-pol\.c9users\.io
so then your your settings would be

$settings['trusted_host_patterns'] = array( '^drupal-tatyana-pol\.c9users\.io$', );

I tend to use this
$settings['trusted_host_patterns'] = array( '^.+\.c9users\.io$', );
That way, if I ever clone the workspace or download the website to a new workspace in the future, the domain is still trusted without having to reconfigure it.


#18

It works. thanks.
Now is 8.3.2 Drupal.
I am wondering if there is a way to update this version for ex. to 8.3.3 in case if 8.3.2 became outdated without reinstalling completely?


#19

Brilliant, glad it’s working.

In order to update, I recommend either using Composer or Drush. Personally, I use Drush, installed via Composer.

Here is the Drupal page for updating: https://www.drupal.org/docs/8/update/update-procedure-in-drupal-8

It’s worth setting up this way so that when future updates are released, installing them is a straight forward process.