Jun
18
2017
By abernal
Virtual Machine
Machine Type | n1-standard-1 |
Operating System | Ubuntu 16.04 LTS |
1 Update Drupal
sudo apt update -y && sudo apt upgrade -y
2 Create administrative user
sudo useradd abernal -G sudo -d /home/abernal
3 Login as the administrative user
sudo su abernal
4 Create user www-data with shell access and home directory
sudo useradd www-data -d /home/www-data
If already exists
sudo usermod www-data -d /home/www-data -s /bin/bash sudo passwd www-data <PASSWORD> sudo mkdir -p /home/www-data sudo cp /etc/skel/.* /home/www-data/ sudo chown www-data:www-data /home/www-data/ -R
5 Install Zip and Unzip
sudo apt install zip unzip -y
6 Install Nginx Web Server
sudo apt install nginx -y sudo systemctl enable nginx sudo systemctl start nginx systemctl status nginx
7 Install MariaDB
# Setup MariaDB sudo apt install mariadb-server mariadb-client -y systemctl status mysql sudo systemctl start mysql sudo systemctl enable mysql sudo mysql_secure_installation # Setup Drupal user sudo mysql -u root -p create database domain; create user domain@localhost; set password for domain@localhost=password('<PASSWORD>'); grant all privileges on domain.* to domain@localhost identified by '<PASSWORD>'; flush privileges; exit;
8 Install php7
sudo apt install php7.0-fpm php7.0-mbstring php7.0-xml php7.0-mysql php7.0-common php7.0-gd php7.0-json php7.0-cli php7.0-curl -y sudo systemctl start php7.0-fpm systemctl status php7.0-fpm php --version
9.0 [OPTIONAL] Settup Nginx configurations
https://github.com/perusio/drupal-with-nginx#installation
9 Create a Default Nginx Server Block File
sudo vim /etc/nginx/sites-available/site
server { listen 80; server_name www.domain.com domain.com; root /home/www-data/domain/; index index.php index.html index.htm; error_page 404 /404.html; error_page 500 502 503 504; rewrite ^/core/authorize.php/core/authorize.php(.*)$ /core/authorize.php$1; location ~ \..*/.*\.php$ { return 403; } #Block access to hidden directories location ~ (^|/)\. { return 403; } location ~ ^/sites/.*/private/ { return 403; } # No php is touched for static content location / { try_files $uri @rewrite; } # Clean URLs location @rewrite { rewrite ^ /index.php; } # Image styles location ~ ^/sites/.*/files/styles/ { try_files $uri @rewrite; } location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_split_path_info ^(.+\.php)(/.+)$; include fastcgi_params; } location ~* ^/update.php { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/run/php/php7.0-fpm.sock; fastcgi_index update.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/update.php; fastcgi_param SCRIPT_NAME /update.php; } # set client body size to 2M client_max_body_size 2M; } sudo nginx -t sudo systemctl reload nginx
10 Set the created domain configuration as enabled
sudo ln -s /etc/nginx/sites-available/domain.conf /etc/nginx/sites-enabled/domain.conf sudo unlink /etc/nginx/sites-available/default
11 Login as www-data user
sudo su www-data
12 Get at the home folder
cd
13 Create the web folder
mkdir domain
14 Create the composer folder
mkdir composer
15 Get into the composer folder
cd composer
16 Install Composer
# Check for updates at https://getcomposer.org/download/ # Usually execute these commands php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');"
17 Install Drush
# Check for updates at http://www.geoffstratton.com/installing-drush-8 # Usually execute these commands ./composer.phar global require drush/drush
18 Edit the .bashrc file in order to add composer binaries folder into the PATH environment variable
# Adding the composer bin folder into the PATH environment variable export PATH=$PATH:~/.composer/vendor/bin
19 Load the .bashrc configuration again in order to apply last changes
cd source .bashrc
20 Upload the templates
cd mkdir tmp cd tmp wget <link to the template uri>
21 Unzip the template
unzip <template>
22 Move the site files within the domain folder
mv files_for_site/* ~/domain/
23 Load the premade database from the template into the already created database
mysql -u domain -p domain < file_with_sql/template.sql
24 Configure Drupal
cp ~/domain/sites/default/default.settings.php ~/domain/sites/default/settings.php chmod u+w ~/domain/sites/default chmod u+w ~/domain/sites/default/settings.php
25 Configure Drupal settings.php
# Increase memory for drupal, adding the next line within the settings.php ini_set('memory_limit', '1024M'); $settings['trusted_host_patterns'] = array( '^example\.com$', '^.+\.example\.com$', '^example\.org$', '^.+\.example\.org$', );