How to Manually Update Drupal Core through CPanel

How to Manually Update Drupal Core through CPanel

Drupal is a wonderful Content Management System with tons of features that solve many problems for editors and content managers. A developer can take different approaches to achieve the same result, and the Drupal update process is no exception.

It is possible to update Drupal either with Composer, Drush, or manually within the CPanel interface. The first two methods imply that you have at least mid-level experience with the command line and secure shell access to your public host. The third method is more visual and is suitable for developers beginning with Drupal.

Keep reading, if you want to learn how to update your Drupal site with this method.


Step #1. The Local Installation

This tutorial assumes, you already have managed to create a local installation, as described in steps #6 and #7 of this tutorial. This tutorial will build upon that example.

  • Enter the SSH mode of the virtual machine (Scotch box)

vagrant up

vagrant ssh

190930 drupal basic workflow

  • Access the public directory of your virtual machine

cd /var/www/public  

  • Enter 192.168.33.10 on the address bar of your browser to access the site
  • Click Configuration > Maintenance mode
  • Check Put site into maintenance mode
  • Click Save configuration

190930 drupal basic workflow 001

The local site is now in maintenance mode. You need to create a backup of the database and of the codebase.

  • In the terminal of your PC, typetar -zcvf drupal-backup.tar.gz .

To create a compressed file called drupal-backup.tar.gz of the public directory. This process will take about one minute.

190930 drupal basic workflow 002

To create a copy of the database type:

mysqldump -u root -p my_drupal_8 > /var/www/public/my_drupal_8.sql

  • Enter root as password (you won’t see any characters rendered on the screen)

190930 drupal basic workflow 003

Notice that these two files are now stored inside the public directory within the virtual machine and also in the public directory located at mydrupalbox in your projects folder.

190930 drupal basic workflow 004


 Step #2. – Installing on a Production Server

On a regular hosting provider, you normally install your application (e.g. Drupal) with a one-click-install procedure.

190930 drupal basic workflow 005

The hosting provider will assign a Username and Password for the newly created account. We need these, to edit the settings.php file of the installation we are going to import.

  • Click the link to CPanel
  • Click File manager within the Files section

190930 drupal basic workflow 006

  • Click on the public_html folder on the left

190930 drupal basic workflow 007

On the right is the Drupal codebase installed by the system of your hosting provider.

  • Select all files and folders
  • Press Delete
  • On the menu bar Click Upload, a new tab will open

190930 drupal basic workflow 008

  • Click Select file
  • Upload the compressed file you created in the last step

190930 drupal basic workflow 009

  • Select the file
  • Click Extract
  • Click Extract file(s)
  • Click Close
  • Select the tar.gz file and press Delete
  • Press Confirm
  • Open the sites/default folder
  • Select the settings.php file
  • Click the pencil on the menu bar, to edit the file
  • Scroll down to the end of the file
  • Change the database, username, and password with the ones you got from your hosting provider (hint: a better approach is to edit the file before compression on your local installation)

To find out the database name, head over to CPanel. In the Databases section, click  phpmyadmin

190930 drupal basic workflow 011

The database name is on the left.

190930 drupal basic workflow 012

  • Edit the settings.php file accordingly
  • Click Save changes
  • Click Close

190930 drupal basic workflow 013.0


 Step #3. – The Database

  • In phpmyadmin scroll down and click Select all, to select all tables

190930 drupal basic workflow 013

  • On the dropdown select DROP
  •  Click Yes/ok

190930 drupal basic workflow 014

The database is now empty.

  • Click Import
  • Select the database backup you created in the last step

190930 drupal basic workflow 015

  • Click Continue

The system will prompt you, once the import process has finished.

190930 drupal basic workflow 016

  • In the address bar of your browser type:  mysitedomain.com/user 
  • Enter your Username and password – make sure that you change these in your user profile, in case you had a less secure password in your local installation
  • On the address bar type: mysitedomain.com/update.php

You will be redirected to the Update screen

  • Click Continue

190930 drupal basic workflow 018

If everything goes well, the system will prompt you to continue to the Front page or the Administration pages.

  • Click Administration pages
  • Click Configuration > Maintenance mode
  • Uncheck Put site into maintenance mode
  • Click Save configuration

190930 drupal basic workflow 019

How to Update Drupal Core

The first thing you have to check on your local installation is the status of core and contrib modules.

After putting your local installation on maintenance mode, and making backups of the codebase and the database, position your cursor at the root folder of your local installation (the composer.json file is there)

  • Type: composer outdated “drupal/*”

To check for outdated modules.

  • To update modules type: composer require drupal/modulename

Just like re-installing the module.

190930 drupal basic workflow 020

You can update all modules, but as you can see, the drupal/core package is not listed.

190930 drupal basic workflow 021

Honestly, I don’t know what this is about, however, this is simple to solve.

  • Edit the composer.json file

Omit the “replace” section and place the “drupal/core”: ”^8.x” statement inside the “require” section.

190930 drupal basic workflow 022

190930 drupal basic workflow 023

  • Type:

rm composer.lock     –To delete the file.

sudo rm -R vendor    –To delete the folder

 composer update drupal/core –with-dependencies     –To update Drupal core. This will also generate the vendor folder and the composer.json file.

190930 drupal basic workflow 024

190930 drupal basic workflow 025

Now you need to start over with step #2. You will not need to upload the database this time.

I hope you liked this tutorial.

Thanks for reading!

Author

  • Jorge Montoya

    Jorge lived in Ecuador and Germany. Now he is back to his homeland Colombia. He spends his time translating from English and German to Spanish. He enjoys playing with Drupal and other Open Source Content Management Systems and technologies.

    View all posts
0 0 votes
Article Rating
Subscribe
Notify of
guest

4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
D2D
D2D
4 years ago

I know that I need some remedial training, but this is totally foreign to my workflow, and I am having trouble making sense of it.

I have never successfully installed Composer or Drush on my hosting service (GoDaddy).  It looks like they install, and some commands seem to run OK, but others return an error that I don’t have sufficient administrator rights or some such thing.  Therefore, I do everything in cPanel – form the cPanel GUI.

I have been using XAMPP on my Windows 10 machine since I started.  It is so painfully slow that I abandoned it in favor of a “demo” account that I keep at the hosting provider.  My customers all have their own hosting accounts – mostly with GoDaddy, but as long as the provider has cPanel and PHPmyAdmin, it doesn’t matter.

I tried a version of Linux running in a box on one of my Windows machines a few years ago without an improvement in speed.  I have been reading about Scotchbox and Lando recently, but I haven’t been able to convince myself that I should take the time to experiment with them.

Robert Ring’s video on how to move a Drupal site actually works quite well for moving sites, but his video on updating Drupal 8 sites is more to the point.  In that video, Robert says to extract the new version, On the site to be updated Delete Core, Vendors, and all the “loose” files except .htaccess and robots.txt.  Then copy the files corresponding to those that were deleted from the extracted Drupal files to the site being updated. He actually recommends saving your changes to .htaccess and robots.txt and reapplying them after copying all of the “loose” files.  Either way, there is no reason at this point to mess with the database.

My workflow, based on my troubles with Composer and Drush and based on Mr. Ring’s videos is as follows:
 
In cPanel
   1. Back up the production site files:  Select all files and compress as a tar file.
             I don’t want to mess with the production site any more than I have to.
   2. Back up the data base using PHPmyAdmin
   3. Transfer the backup files to my local computer and then to my demo account.
          Note that each customer website has its own sub-directory and database.
   4.  Delete any existing files for that site on the demo account.
   5.  Extract the backup.
   6.  In PHPmyAdmin delete the contents of the appropriate database.
   7.  Import the backed up database to the appropriate database.
   8.  Edit settings.php to be the settings needed for the demo site.
            These settings are recorded in a local file for reuse when I need them.
            [b]The bonus here is that I now have a tested backup of the production site:)[/b]
   9.  Upload the latest Drupal 8 to the demo account.
  10. Extract the updated Drupal 8.
  11. Replace the demo site files as shown in Mr. Ring’s video.
  12. Test the demo site.
            Don’t forget to clear cache.
  13. Repeat steps 9 through 12 for the production account.
             Note that I never touched the production database.

I would be delighted if someone can tell me why Composer and Drush don’t work correctly on my demo site, tell me how to speed up PHPmyAdmin imports, help me speed up a local environment, or point me to more efficient methods of backup and upgrade.

I do need to point out that with the demo  site, I can’t just “grab content (images usually) from the Internet”.  I saw a customer go through a lot of pain when my predecessor did that on her site and the owner of an image found it and threatened to sue.

The part that doesn’t make sense to me is that I can’t figure out why you replace the database on the production site – or did I miss something.

April Summers
April Summers
4 years ago

Drupal is now a techie CMS. If you can’t use Composer and Drush you’re not going to get much help from the community. I’m a one-person operation but Drupal is becoming an agency-level CMS with a set of experts in specialist fields. Just setting up the environment on a shared server is a nightmare – you’re fiddling with PHP settings and many requirements that are not default. For example OpCache isn’t allowed on my reseller account (and my service provider is really flexible about most things).  Remember Drupal is owned by a hosting company – and they invest in it to get more business. Eventually Drupal will either need an IT team, or you WILL use one of the few hosting companies who know what it needs to work.  Luckily WordPress is getting better and safer each year – when they add easy custom content types with views, I will switch .

dafnie
4 years ago
Reply to  April Summers

You are right. WordPress is easier for newbies. But drupal is much more fleksible.

If you find a hosting company with a drupal logo (the most) and especially Softcalous on their cpanel. Then it is as easy to install Drupal as any other CMS.

I do not think most Drupalist need a special Drupal-host. Drupal is also good at reporting if something is missing in the installation.

dafnie
4 years ago

I use Softaculous for updating Drupal 8. This does nearly the same in just a few klik.
I this most hosting-providers with cpanel also have Softaculous.

4
0
Would love your thoughts, please comment.x
()
x