The default Drupal package in Ubuntu installs Apache, but I prefer nginx as a web server. In this note I’ll describe the steps necessary to get Drupal 7 working.
All variables in square brackets must be replaced by your names or passwords.
The site will be available at the URL [sitename].
Install all necessary packages:
1sudo apt-get install -y nginx php5-fpm php-apc php5-mysql mysql-client-core-5.5 mysql-server php5-gd
During the installation MySQL will ask you for a root password. Remember it; I will refer to it as [mysqlpwd] later.
Login to MySQL console:
1mysql -u root --password=[mysqlpwd]
and issue the following commands (create user, create database, allow user to work with database):
1CREATE USER '[dbuser]'@'localhost' IDENTIFIED BY '[dbpwd]';
2CREATE DATABASE [dbname];
3GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON `[dbname]`.* TO '[dbuser]'@'localhost' IDENTIFIED BY '[dbpwd]';
4FLUSH PRIVILEGES;
5EXIT
Here we will make a configuration file for nginx.
Create a file in the sites-available directory with the content:
1server {
2 listen 80;
3 server_name [sitename];
4 access_log /var/log/[sitename].access.log;
5 error_log /var/log/[sitename].error.log;
6
7 root /srv/[sitename];
8 index index.php;
9
10 location / {
11 try_files $uri $uri/ /index.php;
12 }
13
14 location = /favicon.ico {
15 empty_gif;
16 }
17
18 location ~ \.php$ {
19 include /etc/nginx/fastcgi_params;
20 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
21 fastcgi_pass 127.0.0.1:9000;
22 }
23}
and add a link for nginx to enable the site:
1sudo ln /etc/nginx/sites-available/[sitename] /etc/nginx/sites-enabled/[sitename]
2sudo service nginx restart
We will store Drupal in a folder in /srv. Issue the following commands in bash:
1sudo -s
2cd /srv
3wget https://ftp.drupal.org/files/projects/drupal-7.22.tar.gz
4tar xvf drupal-7.22.tar.gz
5mv drupal-7.22 [sitename]
6chown -R www-data:www-data [sitename]
7exit