วันพุธที่ 13 พฤษภาคม พ.ศ. 2558

How to install Drupal on Debian 8

Adapted From http://www.davidam.com/docu/installingdrupal.html

Installing Drupal in Debian/Ubuntu GNU/Linux
Table of Contents
1 Installing Debian Packages

A fast way to do it with mysql may be the next:

$ sudo apt-get install  drush

Drush is an useful tool to facilitate the manage of our drupal by command line, by example, updates of modules, backups, etc.

Really, it's better download the last version of drupal that the debian package, due to my policy of use drush to upgrades. But install drupal7 as debian package is a good idea to install depedencies.

$ cd /var/www/
$ sudo drush dl drupal
$ sudo chown -R www-data.www-data drupal-7.3x
$ sudo chmod g+w -R drupal-7.3x
$ sudo mv drupal-7.32 mysite

2 Configuring Apache

To install a drupal site, I would like enable clean urls, to it I will create the file mysite in /etc/apache2/sites-available/mysite.conf, with the next content:




 
NameVirtualHost 192.168.1.29:80


  ServerAdmin webmaster@localhost
  ServerName mysite

  DocumentRoot /var/www/mysite

 
                RewriteEngine on
                RewriteBase /mysite
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
 

 
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
       





Due to in this moment don't have the domain of the site it will be possible enable the host in /etc/hosts

127.0.0.1       localhost
127.0.1.1       mysite

Later, we can enable it so:

$ sudo a2enmod rewrite
$ sudo a2ensite mysite

3 Creation of the database in Mysql

$ mysql -u root -p
mysql> create database drupal7;
mysql> create user 'drupal7'@'localhost' identified by 'lapasswd';
mysql> grant all privileges on drupal7.* to 'drupal7'@'%' with grant option;

4 Creation of the database in Postgresql

First of all, you must install the needed debian packages:

$ sudo apt-get install postgresql-9.1 postgresql-client php5-pgsql

Now, you can create the database and the user to postgres.

$ createuser dpsql --pwprompt --encrypted
$ createdb dpsql --owner=dpsql

To use the psql client on local you can modify the line local in /etc/postgresql/9.1/main/pghba.conf:

local             all            all                   trust

If you want change the pass you can do:

$ psql -U dpsql dpsql -W
dpsql=> ALTER USER dpsql with password 'thepassword';

5 Web install

First, you can remove permissions to CHANGELOG.txt to avoid security problems:

$ cd /var/www/mysite/
$ chmod 600 CHANGELOG.txt

So enabled the site, you can go to http://mysite/install.php and the installation is done step by step

In the step 4 (Set up database) you can find database name, database username and database password with the data provided.
6 Simple backup system

You can do a tar file every day at 13:00 with:

$ crontab -e

And introducing a line such as

0 13 * * * /bin/tar -cvzf /var/backups/drupal7-$(date "+%d-%m-%Y").tar.gz /var/www/drupal7
0 13 * * * cd /var/www/drupal7; drush sql-dump > /var/backups/drupal7-$(date "+%d-%m-%Y").sql

You must check if the cron user has permissions to make the backup, sure. Perhaps, you need create a sh script, if you have troubles.
7 Ssl

The first steps is enable ssl in apache and create the ssl certificates.

$ sudo a2enmod ssl
$ sudo service apache2 restart
$ sudo mkdir /etc/apache2/ssl
$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

Later, we can create virtualhost mysite-ssl



  ServerAdmin webmaster@localhost
  ServerName mysite:443

  DocumentRoot /var/www/mysite

 
                RewriteEngine on
                RewriteBase /mysite
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
 

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key



We can enable the virtualhost

$ sudo a2ensite default
$ sudo service apache2 reload

And enable securelogin

$ cd /var/www/mysite/
$ drush dl securelogin
$ drush en securelogin

Finally, I use go to the configuration to request https in forms.
8 Nagios

$ sudo apt-get install nagios3
$ sudo htpasswd -c htpasswd.users nagiosadmin

Go to http://localhost/nagios3/
9 References

    https://drupal.org/documentation/install


ไม่มีความคิดเห็น: