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#

Friday, 15 May 2015

How to install mysql in ubuntu

How to install mysql in ubuntu


1) Logged in as super user
2) Type following command to install
sudo apt-get install mysql-server


3) It will ask for an option say yes
4) After installation it will ask for password - set password
5) Confirm password again
Now check the status of SQL server
1) To start service use
sudo service mysql start
2) To check status of servce use following command
sudo service mysql status
3) To go on SQL terminal use following command
mysql -uroot -pXXXXX


XXXXX - put your password
4) Once connected you can verify and check. For example running following command
mysql> show databases
-> ;
+--------------------+
| Database        |
+--------------------+
| information_schema |
| mysql           |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)


mysql>
Complete logs are as follows
**************************


oyeweb@oyeweb-Latitude-3540:/var$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
 linux-generic-lts-quantal
Use 'apt-get autoremove' to remove it.
The following extra packages will be installed:
 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
 libmysqlclient18:i386 libterm-readkey-perl mysql-client-5.5
 mysql-client-core-5.5 mysql-common mysql-server-5.5 mysql-server-core-5.5
Suggested packages:
 libmldbm-perl libnet-daemon-perl libplrpc-perl libsql-statement-perl
 libipc-sharedcache-perl tinyca mailx
The following NEW packages will be installed:
 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
 libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-server
 mysql-server-5.5 mysql-server-core-5.5
The following packages will be upgraded:
 libmysqlclient18:i386 mysql-common
2 upgraded, 10 newly installed, 0 to remove and 216 not upgraded.
Need to get 9,900 kB of archives.
After this operation, 96.4 MB 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 mysql-common all 5.5.43-0ubuntu0.14.04.1 [13.8 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu/ trusty-updates/main libmysqlclient18 i386 5.5.43-0ubuntu0.14.04.1 [593 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu/ trusty-updates/main libmysqlclient18 amd64 5.5.43-0ubuntu0.14.04.1 [596 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu/ trusty/main libdbi-perl amd64 1.630-1 [879 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu/ trusty/main libdbd-mysql-perl amd64 4.025-1 [99.3 kB]
Get:6 http://in.archive.ubuntu.com/ubuntu/ trusty/main libterm-readkey-perl amd64 2.31-1 [27.4 kB]
Get:7 http://in.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-client-core-5.5 amd64 5.5.43-0ubuntu0.14.04.1 [709 kB]
Get:8 http://in.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-client-5.5 amd64 5.5.43-0ubuntu0.14.04.1 [1,590 kB]
Get:9 http://in.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server-core-5.5 amd64 5.5.43-0ubuntu0.14.04.1 [3,221 kB]
Get:10 http://in.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server-5.5 amd64 5.5.43-0ubuntu0.14.04.1 [2,093 kB]
Get:11 http://in.archive.ubuntu.com/ubuntu/ trusty/main libhtml-template-perl all 2.95-1 [65.5 kB]
Get:12 http://in.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server all 5.5.43-0ubuntu0.14.04.1 [12.2 kB]
Fetched 9,900 kB in 50s (195 kB/s)                                             
Preconfiguring packages ...
(Reading database ... 249974 files and directories currently installed.)
Preparing to unpack .../mysql-common_5.5.43-0ubuntu0.14.04.1_all.deb ...
Unpacking mysql-common (5.5.43-0ubuntu0.14.04.1) over (5.5.41-0ubuntu0.14.04.1) ...
Preparing to unpack .../libmysqlclient18_5.5.43-0ubuntu0.14.04.1_i386.deb ...
Unpacking libmysqlclient18:i386 (5.5.43-0ubuntu0.14.04.1) over (5.5.41-0ubuntu0.14.04.1) ...
Selecting previously unselected package libmysqlclient18:amd64.
Preparing to unpack .../libmysqlclient18_5.5.43-0ubuntu0.14.04.1_amd64.deb ...
Unpacking libmysqlclient18:amd64 (5.5.43-0ubuntu0.14.04.1) ...
Selecting previously unselected package libdbi-perl.
Preparing to unpack .../libdbi-perl_1.630-1_amd64.deb ...
Unpacking libdbi-perl (1.630-1) ...
Selecting previously unselected package libdbd-mysql-perl.
Preparing to unpack .../libdbd-mysql-perl_4.025-1_amd64.deb ...
Unpacking libdbd-mysql-perl (4.025-1) ...
Selecting previously unselected package libterm-readkey-perl.
Preparing to unpack .../libterm-readkey-perl_2.31-1_amd64.deb ...
Unpacking libterm-readkey-perl (2.31-1) ...
Selecting previously unselected package mysql-client-core-5.5.
Preparing to unpack .../mysql-client-core-5.5_5.5.43-0ubuntu0.14.04.1_amd64.deb ...
Unpacking mysql-client-core-5.5 (5.5.43-0ubuntu0.14.04.1) ...
Selecting previously unselected package mysql-client-5.5.
Preparing to unpack .../mysql-client-5.5_5.5.43-0ubuntu0.14.04.1_amd64.deb ...
Unpacking mysql-client-5.5 (5.5.43-0ubuntu0.14.04.1) ...
Selecting previously unselected package mysql-server-core-5.5.
Preparing to unpack .../mysql-server-core-5.5_5.5.43-0ubuntu0.14.04.1_amd64.deb ...
Unpacking mysql-server-core-5.5 (5.5.43-0ubuntu0.14.04.1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up mysql-common (5.5.43-0ubuntu0.14.04.1) ...
Selecting previously unselected package mysql-server-5.5.
(Reading database ... 250318 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.5_5.5.43-0ubuntu0.14.04.1_amd64.deb ...
Unpacking mysql-server-5.5 (5.5.43-0ubuntu0.14.04.1) ...
Selecting previously unselected package libhtml-template-perl.
Preparing to unpack .../libhtml-template-perl_2.95-1_all.deb ...
Unpacking libhtml-template-perl (2.95-1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.5.43-0ubuntu0.14.04.1_all.deb ...
Unpacking mysql-server (5.5.43-0ubuntu0.14.04.1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
Setting up libmysqlclient18:i386 (5.5.43-0ubuntu0.14.04.1) ...
Setting up libmysqlclient18:amd64 (5.5.43-0ubuntu0.14.04.1) ...
Setting up libdbi-perl (1.630-1) ...
Setting up libdbd-mysql-perl (4.025-1) ...
Setting up libterm-readkey-perl (2.31-1) ...
Setting up mysql-client-core-5.5 (5.5.43-0ubuntu0.14.04.1) ...
Setting up mysql-client-5.5 (5.5.43-0ubuntu0.14.04.1) ...
Setting up mysql-server-core-5.5 (5.5.43-0ubuntu0.14.04.1) ...
Setting up mysql-server-5.5 (5.5.43-0ubuntu0.14.04.1) ...
150516  7:40:43 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
150516  7:40:43 [Note] /usr/sbin/mysqld (mysqld 5.5.43-0ubuntu0.14.04.1) starting as process 8654 ...
mysql start/running, process 8786
Setting up libhtml-template-perl (2.95-1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Setting up mysql-server (5.5.43-0ubuntu0.14.04.1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...


oyeweb@oyeweb-Latitude-3540:/var$
oyeweb@oyeweb-Latitude-3540:/var$ sudo service mysql start
start: Job is already running: mysql
oyeweb@oyeweb-Latitude-3540:/var$
oyeweb@oyeweb-Latitude-3540:/var$ sudo service mysql status
mysql start/running, process 8786
oyeweb@oyeweb-Latitude-3540:/var$

oyeweb@oyeweb-Latitude-3540:/var$ mysql -uroot -pXXXX
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 43
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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)


mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A


Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
24 rows in set (0.00 sec)