Nginx | Configure Famous Frameworks Routs ( Yii2, Laravel, Drupal, Codeigniter)




Below is a simple Server Configuration for Several Framework Based Projects,
note that the script is designed to have variables that takes the right directives then process the location
change all the variables to what serves your need


server {
 listen 127.0.0.1:80 default_server;
 #listen [::]:80 default_server;
 disable_symlinks off;
 rewrite_log on;
 root /var/www/html;

 # Add index.php to the list if you are using PHP
 index index.html index.php;

 server_name 127.0.0.2 dsb-php5.co;

 # Set CI Folder
 set $ci_app_folder '';
 # Yii Project
 if ($request_uri ~ .*yii_folder_name.*) {
  set $ci_app_folder '/file/location/project1';
  set $bootfile 'index.php?$args';

 }
 # Drupal & Laravel Project
 if ($request_uri ~ .*drupal_folder_name.*) {
  set $ci_app_folder '/file/location/project3';
  set $bootfile 'index.php?$query_string';
 }
 # Codeigniter Project
 if ($request_uri ~ .*codeigniter_folder_name.*) {
  set $ci_app_folder '/file/location/project4';
  set $bootfile 'index.php';
 }

 location / {
  try_files $uri $uri/ $ci_app_folder/$bootfile;
  autoindex on;
 }

 # pass PHP scripts to FastCGI server
 location ~ \.php$ {
  include snippets/fastcgi-php.conf;
  fastcgi_pass 127.0.0.1:9000;
 }

 # deny access to .htaccess files, if Apache's document root
 # concurs with nginx's one
 #
 location ~ /\.ht {
  deny all;
 }
}

Comments

Popular Posts