Jul 022013
 

Thank GNUtransfer the loan us a VPS and other resources to write this article.

In this article we will see how to install Drupal on a VPS or a dedicated server.

For our article we will use the domain example.geeklab.com.ar and our IP is 69.61.93.19
We start from a minimal install of Debian Wheezy or Ubuntu Precise Pangolin.

NOTE: Although Drupal is in the Debian repositories in this article we will install from the tar.gz of Drupal site

First we need to install the necessary packages apache2, libapache2-mod-php5, php5, php5-curl, php5-intl, php5-mcrypt, php5-mysql, php5-sqlite, php5-xmlrpc, php5-gd, mysql-server, mysql-client

root@vps415960:/# apt-get install apache2 libapache2-mod-php5 php5 php5-curl php5-intl php5-mcrypt php5-mysql php5-sqlite php5-xmlrpc php5-gd mysql-server mysql-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common fontconfig-config libaio1 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libcurl3 libdbd-mysql-perl libdbi-perl libfontconfig1 libgd2-xpm
  libhtml-template-perl libicu48 libjpeg8 libltdl7 libmcrypt4 libmysqlclient18 libnet-daemon-perl libonig2 libplrpc-perl libpng12-0 libqdbm14 librtmp0 libssh2-1 libxpm4 mysql-client-5.5 mysql-common mysql-server-5.5
  mysql-server-core-5.5 php5-cli php5-common ssl-cert ttf-dejavu-core
Suggested packages:
  apache2-doc apache2-suexec apache2-suexec-custom php-pear libgd-tools libipc-sharedcache-perl libmcrypt-dev mcrypt libterm-readkey-perl tinyca openssl-blacklist
The following NEW packages will be installed:
  apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common fontconfig-config libaio1 libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libcurl3 libdbd-mysql-perl libdbi-perl libfontconfig1
  libgd2-xpm libhtml-template-perl libicu48 libjpeg8 libltdl7 libmcrypt4 libmysqlclient18 libnet-daemon-perl libonig2 libplrpc-perl libpng12-0 libqdbm14 librtmp0 libssh2-1 libxpm4 mysql-client mysql-client-5.5 mysql-common mysql-server
  mysql-server-5.5 mysql-server-core-5.5 php5 php5-cli php5-common php5-curl php5-gd php5-intl php5-mcrypt php5-mysql php5-sqlite php5-xmlrpc ssl-cert ttf-dejavu-core
0 upgraded, 49 newly installed, 0 to remove and 0 not upgraded.
Need to get 25,5 MB of archives.
After this operation, 152 MB of additional disk space will be used.
Do you want to continue [Y/n]?

We ask that we enter a password for the mysql root user

drupal_debian_wheezy_01

We are asked again to confirm the password for the root user of mysql

drupal_debian_wheezy_02

Now proceed to configure Apache will use as working directory /var/www/drupal
first create the directory

root@vps415960:/# mkdir -p /var/www/drupal

Then create the file /etc/apache2/sites-available/drupal with the following content
Note: You must change the IP, domain and email address through which they belong.

NameVirtualHost 69.61.93.19:80
<VirtualHost 69.61.93.19:80>
        ServerAdmin rmalvarez@gnupanel.org
        ServerName example.geeklab.com.ar

        DocumentRoot /var/www/drupal

        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Then we disable the default site configured in apache and drupal put a site we’ve added recently, stop that run the following commands

root@vps415960:/# a2dissite default
Site default disabled.
To activate the new configuration, you need to run:
  service apache2 reload
root@vps415960:/# a2ensite drupal
Enabling site drupal.
To activate the new configuration, you need to run:
  service apache2 reload
root@vps415960:/#

Also edit /etc/hosts and where our IP will also add our domain

root@vps415960:/# cat /etc/hosts
127.0.0.1 localhost
69.61.93.19 example.geeklab.com.ar vps415960
2002:453d:5d13::1 example.geeklab.com.ar vps415960

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
root@vps415960:/#

And in the file /etc/apache2/ports.conf comment the line NameVirtualHost *:80 so that it looks like

root@vps415960:/tmp# cat /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz

#NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

root@vps415960:/tmp# 

Then add the apache rewrite module

root@vps415960:/# a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
  service apache2 restart
root@vps415960:/#

Then optimize PHP to suit the needs of Drupal
NOTE: This is not the optimal configuration, just put on estimated values ​​to make sure that drupal work properly for each particular installation should tune this setting.
Edit /etc/php5/apache2/php.ini and modify the following variables so they are with the following values.

max_execution_time = 900
max_input_time = 900
memory_limit = 512M
post_max_size = 64M
upload_max_filesize = 64M
max_file_uploads = 32
default_socket_timeout = 900

We proceed to restart apache

root@vps415960:/# /etc/init.d/apache2 restart
[ ok ] Restarting web server: apache2 ... waiting .
root@vps415960:/#

Now we connect to mysql and create database and user mysql for drupal
for that first we connect to mysql

root@vps415960:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 5.5.30-1.1 (Debian)

Copyright (c) 2000, 2013, 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>

And now create the database and user with these statements
NOTE: In our example both the database and the user are drupal, replace the password PASSWORD_DB who wish to assign to the database.

mysql> CREATE DATABASE drupal;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL ON drupal.* TO drupal@localhost IDENTIFIED BY 'PASSWORD_DB';
Query OK, 0 rows affected (0.00 sec)

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

mysql> \q
Bye

We now proceed to download Drupal, we make sure to install wget and then proceed to the download

root@vps415960:/# apt-get install wget
Reading package lists... Done
Building dependency tree
Reading state information... Done
wget is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@vps415960:/#
root@vps415960:/# cd /tmp
root@vps415960:/tmp#
root@vps415960:/tmp# wget http://ftp.drupal.org/files/projects/drupal-7.22.tar.gz
--2013-07-02 21:07:56--  http://ftp.drupal.org/files/projects/drupal-7.22.tar.gz
Resolving ftp.drupal.org (ftp.drupal.org)... 140.211.166.134
Connecting to ftp.drupal.org (ftp.drupal.org)|140.211.166.134|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3183014 (3,0M) [application/x-gzip]
Saving to: `drupal-7.22.tar.gz'

100%[===================================================================================================================================================================================================>] 3.183.014   1,31M/s   in 2,3s

2013-07-02 21:07:58 (1,31 MB/s) - `drupal-7.22.tar.gz' saved [3183014/3183014]

root@vps415960:/tmp#

Unzip it then copy the contents in /var/www/drupal and make sure to change the permissions so that no conflicts

root@vps415960:/tmp# tar -xf drupal-7.22.tar.gz
root@vps415960:/tmp# cp -R drupal-7.22/* /var/www/drupal/
root@vps415960:/tmp# chown -R www-data:www-data /var/www
root@vps415960:/tmp# find /var/www -type f -exec chmod 0600 {} \;
root@vps415960:/tmp# find /var/www -type d -exec chmod 0700 {} \;
root@vps415960:/tmp#

Now we turn to the browser to our site to use Drupal installer, in the example http://example.geeklab.com.ar and follow the steps.

Step 1

drupal_debian_wheezy_03

Step 2

drupal_debian_wheezy_04

Step 3, Here we put database conection data.

drupal_debian_wheezy_05

Step 4, Here we wait to be installed all modules in Drupal

drupal_debian_wheezy_06

drupal_debian_wheezy_07

Step 5, Here we put the basic data from our Drupal site

drupal_debian_wheezy_08

Step 7, Ready Drupal already installed.

drupal_debian_wheezy_09

Step 8, go to the site

drupal_debian_wheezy_10

This completes the installation of Drupal on a Debian Wheezy installation with the minimum to run