NginX

Virtual Hosts

NginX Virtual hosts

#### /etc/nginx/sites-available/loc_adsuu_www.conf ####

#redirect to www
server {
  server_name adsuu.loc;
  return 301 $scheme://www.$host$request_uri;
}


server {
    
  ############### General Settings ####################
    listen   80;
    server_name  www.adsuu.loc;
    root    "/homemiko/com_adsuu/www/pub/";
  index  index.php index.html;
    charset utf-8;
    autoindex on;
  error_log "/homemiko/com_adsuu/logs/www_adsuu_com_error.log";
  #access_log "/homemiko/com_adsuu/logs/www_adsuu_com_access.log";

  ############### deny access to apache .htaccess files ####################
  location ~ /\.htaccess {
    deny all;
   }
    
  ################# PHP ###################
    location ~ \.php$ {
      try_files $uri =404;
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass unix:/var/run/php5-fpm.sock;
      #fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fastcgi_params;
  }

}

 

Ubuntu 12.04

1. Create file /etc/nginx/sites-available/loc_adsuu_www.conf

2. Cretae symbolic link of that file into /etc/nginx/sites-enabled/ directory

3. File /etc/nginx/nginx.conf must have line:

include /etc/nginx/sites-enabled/*;

4. Restart NginX and php-fpm

#service nginx restart

#service php5-fpm restart

5. inside file /etc/hosts put:

127.0.0.1 adsuu.loc

127.0.0.1 www.adsuu.loc

6. Type in browser's addres bar: http://adsuu.loc . It should redirect into http://www.adsuu.loc

7. To test PHP create phpinfo.php file with <?php phpinfo(); ?>