Amazon Web Services - AWS EC2 - Ubuntu 14.04
NginX installation and configuration
This chapter describes how to setup NginX on Ubuntu 14.04.
1. Installation
# yum install nginx
# service nginx start | stop | status
2. Configure website
# cd /etc/nginx/sites-available
# vim com_brvno_www.conf
#redirect to www
server {
server_name brvno.com;
return 301 $scheme://www.$host$request_uri;
}
server {
############### General Settings ####################
listen 80;
server_name www.brvno.com;
root "/homemiko/com_brvno/www/public_html/";
index index.php index.html;
charset utf-8;
autoindex on;
error_log "/homemiko/com_brvno/logs/www_brvno_com_error.log";
#access_log "/homemiko/com_adsuu/logs/www_adsuu_com_access.log";
#error page
error_page 404 /404.shtml;
################# Includes ###################
include /etc/nginx/includes/htaccess.conf;
include /etc/nginx/includes/php.conf;
}
# mkdir ../includes
# vim ../includes/htaccess.conf
#### /etc/nginx/includes/htaccess.conf
#deny access to Apache's .htaccess files
location ~ /\.htaccess {
deny all;
}
# vim ../includes/php.conf
#### /etc/nginx/includes/php.conf ####
# enabling PHP through php-fpm
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
Create sym link
# ln -s /etc/nginx/sites-available/com_brvno_www.conf ../sites-enabled/com_brvno_www.conf
# service nginx restart