Saturday 16 May 2015

how to install Drupal in ubuntu

Drupal is very popular and easy to use open-source CMS (content management system ) written in PHP and distributed under the GNU General Public License.


To install Drupal in ubuntu following steps to be followed. Its very easy and can be done easily.

Assumption:-
php, Apache, MySQL are installed and configured. This will be explained in another post if you are not aware of. Don’t worry it's easy.

You can use following commands to check if your system is up to date. Though these are not essential yet you can use if want

sudo apt-get update
sudo apt-get upgrade

Install Drush:
apt-get install drush php-console-table
Ubuntu 14.04 comes with Drush version 5.10.0. If you like to install and use the latest release of Drush, it can be installed via the custom PEAR channel using the following commands:

pear channel-discover pear.drush.org
pear install drush/drush


Following commands can be used to check if you have successfully installed the drus version.

drush version
Drush Version   :  6.2.0


Download the latest stable version of Drupal to the ‘/var/www/html/’ directory on your server:
cd /var/www/html/
drush dl drupal
mv /var/www/html/drupal-7.28 /var/www/html/drupal


Create a new MySQL database for Drupal on your server:
mysql -u root -p
mysql> CREATE DATABASE drupaldb;
mysql> GRANT ALL PRIVILEGES ON drupaldb.* TO 'drupaluser'@'localhost' IDENTIFIED BY 'your-password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> quit


Create a new virtual host directive in Apache. For example, create a new Apache configuration file ‘drupal.conf':
vi /etc/apache2/sites-available/drupal.conf
ln -s /etc/apache2/sites-available/drupal.conf /etc/apache2/sites-enabled/drupal.conf


then, add the following lines:

<VirtualHost *:80>
  ServerAdmin admin@your-domain.com
  DocumentRoot /var/www/html/drupal/
  ServerName your-domain.com
  ServerAlias www.your-domain.com
     <Directory /var/www/html/drupal/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
Order allow,deny
        allow from all
     </Directory>
  ErrorLog /var/log/apache2/your-domain.com-error_log
  CustomLog /var/log/apache2/your-domain.com-access_log common
</VirtualHost>
Restart the Apache web server for the changes to take effect:
service apache2 restart



Make the document root and the Drupal files and directories in it writable by the Apache service which is running as user ‘www-data’ and group ‘www-data’ by executing the following command:
chown www-data:www-data -R /var/www/html/drupal/


Thats it you can open your browser by simply typing

http://localhost/drupal




Below are the terminal logs that will be helpful. Attaching for reference
Please note if you see permission denied. Please make sure you are logged in as super user (use sudo command in from of all mentioned command as above) and for some paths/command it should be as root user




oyeweb@oyeweb-Latitude-3540:~$ apt-get install drush php-console-table
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
oyeweb@oyeweb-Latitude-3540:~$ sudo apt-get install drush php-console-table
[sudo] password for oyeweb:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
 account-plugin-windows-live libupstart1
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
 php-pear
Suggested packages:
 git drupal7 php5-dev
Recommended packages:
 php-console-color
The following NEW packages will be installed:
 drush php-console-table php-pear
0 upgraded, 3 newly installed, 0 to remove and 3 not upgraded.
Need to get 634 kB of archives.
After this operation, 3,790 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu/ trusty-updates/main php-pear all 5.5.9+dfsg-1ubuntu4.9 [267 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu/ trusty/universe php-console-table all 1.1.6-1 [14.7 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu/ trusty/universe drush all 5.10.0-2 [353 kB]
Fetched 634 kB in 4s (143 kB/s)
Selecting previously unselected package php-pear.
(Reading database ... 255377 files and directories currently installed.)
Preparing to unpack .../php-pear_5.5.9+dfsg-1ubuntu4.9_all.deb ...
Unpacking php-pear (5.5.9+dfsg-1ubuntu4.9) ...
Selecting previously unselected package php-console-table.
Preparing to unpack .../php-console-table_1.1.6-1_all.deb ...
Unpacking php-console-table (1.1.6-1) ...
Selecting previously unselected package drush.
Preparing to unpack .../drush_5.10.0-2_all.deb ...
Unpacking drush (5.10.0-2) ...
Processing triggers for doc-base (0.10.5) ...
Processing 1 added doc-base file...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up php-pear (5.5.9+dfsg-1ubuntu4.9) ...
Setting up php-console-table (1.1.6-1) ...
Setting up drush (5.10.0-2) ...
oyeweb@oyeweb-Latitude-3540:~$ drush version
drush version 5.10.0
oyeweb@oyeweb-Latitude-3540:~$ pear channel-discover pear.drush.org
could not create lock file: fopen(/usr/share/php/.lock): failed to open stream: Permission denied
oyeweb@oyeweb-Latitude-3540:~$ sudo pear channel-discover pear.drush.org
Adding Channel "pear.drush.org" succeeded
Discovery of channel "pear.drush.org" succeeded
oyeweb@oyeweb-Latitude-3540:~$ sudo pear install drush/drush
downloading drush-6.2.0.0.tgz ...
Starting to download drush-6.2.0.0.tgz (505,989 bytes)
.....................................................................................................done: 505,989 bytes
install ok: channel://pear.drush.org/drush-6.2.0.0
oyeweb@oyeweb-Latitude-3540:~$
oyeweb@oyeweb-Latitude-3540:~$
oyeweb@oyeweb-Latitude-3540:~$ drush version
Drush Version   :  6.2.0

oyeweb@oyeweb-Latitude-3540:~$ cd /var/www/html/
oyeweb@oyeweb-Latitude-3540:/var/www/html$ ls -ltr
total 12
-rw-r--r-- 1 root root 11510 May 16 08:28 index.html
oyeweb@oyeweb-Latitude-3540:/var/www/html$ drush dl drupal
Directory /var/www/html exists, but is not writable. Please check directory permissions.                                              [error]
Project drupal (7.37) could not be downloaded to /var/www/html/drupal-7.37.                                                           [error]
oyeweb@oyeweb-Latitude-3540:/var/www/html$ sudo drush dl drupal
Project drupal (7.37) downloaded to /var/www/html/drupal-7.37.                                                                        [success]
Project drupal contains:                                                                                                              [success]
- 3 profiles: testing, minimal, standard
- 4 themes: stark, seven, bartik, garland
- 47 modules: drupal_system_listing_incompatible_test, drupal_system_listing_compatible_test, taxonomy, image, menu, update, trigger,
options, number, text, field_sql_storage, list, field, toolbar, color, poll, user, contextual, simpletest, block, node, overlay,
dashboard, blog, profile, translation, php, book, comment, filter, syslog, openid, shortcut, search, path, dblog, tracker, rdf,
field_ui, system, contact, help, locale, aggregator, forum, statistics, file

oyeweb@oyeweb-Latitude-3540:/var/www/html$ ls -ltr
total 16
-rw-r--r-- 1 root root 11510 May 16 08:28 index.html
drwxr-xr-x 9 root root  4096 May 16 16:35 drupal-7.37
oyeweb@oyeweb-Latitude-3540:/var/www/html$ mv /var/www/html/drupal-7.37 /var/www/html/drupal
mv: cannot move ‘/var/www/html/drupal-7.37’ to ‘/var/www/html/drupal’: Permission denied
oyeweb@oyeweb-Latitude-3540:/var/www/html$ sudo mv /var/www/html/drupal-7.37 /var/www/html/drupal
oyeweb@oyeweb-Latitude-3540:/var/www/html$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 36
Server version: 5.5.43-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE drupaldb;
Query OK, 1 row affected (0.08 sec)

mysql> GRANT ALL PRIVILEGES ON drupaldb.* TO 'drupaluser'@'localhost' IDENTIFIED BY 'your-password' WITH GRANT OPTION;
Query OK, 0 rows affected (0.27 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.04 sec)

mysql> quit
Bye
oyeweb@oyeweb-Latitude-3540:/var/www/html$ vi /etc/apache2/sites-available/drupal.conf
oyeweb@oyeweb-Latitude-3540:/var/www/html$ cd /etc/apache2/sites-available/
oyeweb@oyeweb-Latitude-3540:/etc/apache2/sites-available$ ls -ltr
total 20
-rw-r--r-- 1 root root 6437 Jan  7  2014 default-ssl.conf
-rw-r--r-- 1 root root 1332 Jan  7  2014 000-default.conf
-rw-r--r-- 1 root root 1332 May 16 08:57 default
-rw-r--r-- 1 root root 1346 May 16 08:57 drupal
oyeweb@oyeweb-Latitude-3540:/etc/apache2/sites-available$ su
Password:
root@oyeweb-Latitude-3540:/etc/apache2/sites-available# ln -s /etc/apache2/sites-available/drupal.conf /etc/apache2/sites-enabled/drupal.conf
root@oyeweb-Latitude-3540:/etc/apache2/sites-available# ls -ltr
total 20
-rw-r--r-- 1 root root 6437 Jan  7  2014 default-ssl.conf
-rw-r--r-- 1 root root 1332 Jan  7  2014 000-default.conf
-rw-r--r-- 1 root root 1332 May 16 08:57 default
-rw-r--r-- 1 root root 1346 May 16 08:57 drupal
root@oyeweb-Latitude-3540:/etc/apache2/sites-available# vi drupal.conf
root@oyeweb-Latitude-3540:/etc/apache2/sites-available# ls -ltr
total 20
-rw-r--r-- 1 root root 6437 Jan  7  2014 default-ssl.conf
-rw-r--r-- 1 root root 1332 Jan  7  2014 000-default.conf
-rw-r--r-- 1 root root 1332 May 16 08:57 default
-rw-r--r-- 1 root root 1346 May 16 08:57 drupal
root@oyeweb-Latitude-3540:/etc/apache2/sites-available# touch drupal.conf
root@oyeweb-Latitude-3540:/etc/apache2/sites-available# ls -ltr
total 20
-rw-r--r-- 1 root root 6437 Jan  7  2014 default-ssl.conf
-rw-r--r-- 1 root root 1332 Jan  7  2014 000-default.conf
-rw-r--r-- 1 root root 1332 May 16 08:57 default
-rw-r--r-- 1 root root 1346 May 16 08:57 drupal
-rw-r--r-- 1 root root    0 May 16 16:40 drupal.conf
root@oyeweb-Latitude-3540:/etc/apache2/sites-available# vi drupal
root@oyeweb-Latitude-3540:/etc/apache2/sites-available# vi drupal.conf
root@oyeweb-Latitude-3540:/etc/apache2/sites-available# service apache2 restart
* Restarting web server apache2                                                                                                                 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
                                                                                                                                         [ OK ]
root@oyeweb-Latitude-3540:/etc/apache2/sites-available# chown www-data:www-data -R /var/www/html/drupal/
root@oyeweb-Latitude-3540:/etc/apache2/sites-available#

No comments:

Post a Comment