I've successfully installed wordpress on an Amazon EC2 instance. It was working, however the apache service kept slowing down my machine and causing excess instances. Because of this, I have decided to switch to NGINX. It is already installed on my server. It is partially configured but I cannot get it fully working.
I am receiving 403 forbidden when accessing any folder directly and 502 bad gateway error when accessing and files directly.. Just so you know, I have 1 elastic IP and multiple domains that all point to that IP.
What I need is each domain to point to a different subdirectory or "root", with the first domain pointing to the highest level directory I.e:
domain1 > /var/www domain2 > /var/www/domain2.com domain3 > /var/www/domain3.com
Here is my nginx.conf file:
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
index index.php index.html index.htm;
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 10;
gzip on;
gzip_disable "msie6";
gzip_proxied any;
gzip_comp_level 3; #You can vary this. 1 is least compression, 9 is most. I'll keep it low, since we have low CPU power.
gzip_buffers 16 8k;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
server {
listen 80;
server_name www.mysites.com;
access_log /var/www/access.log;
error_log /var/www/error.log;
root /var/www/myfolder/mysites.com;
# Pass PHP scripts to PHP-FPM
location ~* \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
}