Setup Nginx drupal and phpmyadmin on ubuntu 16.04 & RHEL
How to setup nginx webserver with drupal installation & phpmyadmin I assume that you have already install nginx web server on Ubuntu 16.04/RHEL
As nginx is web server for serving static content on web, but as we are going to use it with drupal 7.x/8.x we need addition service for php support i.e php-fpm
- Open terminal by alt+ctrl T and cd /etc/nginx/conf.d
- Create default.conf as
# Default server configuration
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# Allow phpmyadmin to access from nginx
location /phpmyadmin {
root /usr/share;
index index.php;
try_files $uri $uri/ /phpmyadmin/index.php$args$is_args;
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share;
}
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
sudo apt-get install php7.0-fpm php7.0-cli php7.0-gd php7.0-mysql php7.0-xml -y
We will configure Nginx to use php-fpm to serve HTTP requests for PHP pages by editing "/etc/php/7.0/fpm/php.ini" file:
sudo vi /etc/php/7.0/fpm/php.ini and replace cgi.fix_pathinfo=1 with cgi.fix_pathinfo=0
In this tutorial we are taking drupal-dev.com as our domain for drupal installation:
/var/www/drupal-dev.com/public
cd /etc/nginx/conf.d create a config file like drupal-dev.conf will contain:
server {
listen 80;
server_name www.drupal-dev.com;
# rewrite ^/(.*) http://drupal-main.com/$1 permanent;
}
server {
listen 80;
server_name drupal-dev.com;
root /var/www/drupal-dev.com/public/;
index index.php;
# For Drupal >= 7 clean url
location / {
try_files $uri /index.php?$query_string;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
127.0.0.1 localhost
127.0.1.1 drupal-dev.com www.drupal-dev.com
restart nginx by sudo service nginx restart and visit your site: http://drupal-dev.com
-:Done:-
Comments
Post a Comment
There is comment posted on your blog, chandu7929@blogpost.com