Thursday, November 12, 2015

Install Drupal with Nginx on an Debian Jessie

Drupal is a free and open-source content management framework (CMF) written in PHP and distributed under the GNU General Public License. Drupal provides deep capabilities and endless flexibility on the web.

# Install Nginx

sudo su

apt-get install nginx


# Start Server

/etc/init.d/nginx start

# TEST THE WEB SERVER
# WELCOME #

# Install PHP

apt-get install php5-fpm

# edit site default

nano /etc/nginx/sites-enabled/default

      # insert index.php after index

      index index.php index.html index.htm;

       # Edit Location

        location ~ \.php$ {
           fastcgi_split_path_info ^(.+\.php)(/.+)$;
           fastcgi_pass unix:/var/run/php5-fpm.sock;
           fastcgi_index index.php;
        include fastcgi.conf;
       }

# Reload nginx

/etc/init.d/nginx reload

# TEST PHP

nano /var/www/html/index.php

<?php echo phpinfo();?>


------------------- Nginx Success Installed ---------------------------------

# Configure PHP-FPM

nano /etc/php5/fpm/php.ini

cgi.fix_pathinfo=0


# Check www.conf

nano /etc/php5/fpm/pool.d/www.conf

listen = /var/run/php5-fpm.sock

# Install Drupal

apt-get install php5-mysql

apt-get install php5-gd

# Create Database
mysql -u root -p

CREATE DATABASE black_coffee;

GRANT ALL PRIVILEGES ON black_coffee.* TO root@localhost IDENTIFIED BY 'ratimint.org';


cd /var/www/html/ratimint

# CHANGE php.ini

nano /etc/php5/fpm/php.ini

session.auto_start = Off
mbstring.http_input = pass
mbstring.http_output = pass
mbstring.encoding_translation = Off


# Or modify

nano /var/www/html/ratimint/sites/default/default.settings.php

---------------- server is ready ------------

cd /tmp/

wget http://ftp.drupal.org/files/projects/drupal-7.7.tar.gz


tar xvfz drupal-7.7.tar.gz 

cd drupal-7.7

cp * /var/www/html/ratimint/ -R

chown -R www-data:www-data /var/www/html/ratimint/


nano /etc/nginx/sites-available/ratimint


server {
       listen 80;
       server_name www.ratimint.org ratimint.org;
       root /var/www/html/ratimint/;
       if ($http_host != "www.ratimint.org") {
                 rewrite ^ http://www.ratimint.org$request_uri permanent;
       }
       index index.php index.html;
       location = /favicon.ico {
                log_not_found off;
                access_log off;
       }
       location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
       }

# Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS!

        location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
                deny all;
        }
       # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
       location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
       }
       location / {
                try_files $uri $uri/ /index.php?$args;
       }
       location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                expires max;
                log_not_found off;
       }
       location ~ \.php$ {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       }




cd /etc/nginx/sites-enabled/
ln -s /etc/nginx/sites-available/ratimint www.ratimint.org


/etc/init.d/nginx reload

Browser ?? http://localhost/ratimint
And Install Drupal



# On Error


1.) File: /ratimint/includes/unicode.inc

Changed Line #76 from:

'\x{D800}-\x{F8FF}\x{FB29}\x{FD3E}-\x{FD3F}\x{FDFC}-\x{FDFD}' .

To:

'\x{E800}-\x{F8FF}\x{FB29}\x{FD3E}-\x{FD3F}\x{FDFC}-\x{FDFD}' .

As per the same file in Drupal 7.34, yes, really that simple, one letter changed.

NOTE: Below must be done DURING install (the configure site page when the error appears).


2.) File: /ratimint/includes/menu.inc

Changed line #3155 from:

if (!$existing_item || (array_intersect_assoc($item, $existing_item)) != $existing_item) {

To:

if (!$existing_item || (array_intersect_key($item, $existing_item) != $existing_item)) {

Method change and brackets were in the wrong places.

Below is how I solved the error specific to THIS post...

NOTE: The below must be done AFTER install, after clicking visit your site and getting the error.


3.) File: /ratimint/includes/database/query.inc

<?php
function __clone() {
    $this->changed = TRUE;
    foreach ($this->conditions as $key => $condition) {
      
            if ($condition['field'] instanceOf QueryConditionInterface) {
                $this->conditions[$key]['field'] = clone($condition['field']);
         
        }
    }
 }
?>

To:

<?php
function __clone() {
    $this->changed = TRUE;
    foreach ($this->conditions as $key => $condition) {
        if( isset($condition['field'])){     //THIS SHOULD TAKE CARE OF THE ERROR 
            if ($condition['field'] instanceOf QueryConditionInterface) {
                $this->conditions[$key]['field'] = clone($condition['field']);
            }
        }
    }
 }
?>

# You Can Try call http://localhost/ratimint