I've set my nginx but now every *.php file on my virtual host returns 500 internal server error.
server {
listen tucnak.dev:80; ## listen for ipv4; this line is default and implied
root /home/tucnak/Web/Lab;
index index.php index.html;
server_name tucnak.dev;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.html;
}
location /doc {
root /usr/share;
autoindex on;
allow 127.0.0.1;
deny all;
}
location /images {
root /usr/share;
autoindex off;
}
#error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
location ~ \.php$ {
proxy_pass http://127.0.0.1;
}
location ~ \.php$ {
set $php_root /home/tucnak/Web/Lab;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $php_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Where is my error? My php-file is total correct!
<?php echo("Hello!"); ?>
I am really new at nginx and need help with it. After apache2 - I am confused!
UPD: I think that nginx not successfully gives query for apache. I don't know how to fix it.
I have been googling and testing all the tutorials for distros I came across with and none worked. So I learnt that one must consult the right docs for you distro or it simply will not work. So I have found this one
I have RHE5.7 Tikanga running Apache 2.2. Two sites running on port 8080 and nginx-1.0.14-1.el5.ngx 80. I mean that I have two directories smlinking to /var/www/html/site1 and /var/www/html/site2. Both in php 5.
For those who admin Red Hat sites, this worked for me
$ NameVirtualHost *:8080
<VirtualHost *:8080>
ServerAdmin me@mydomain.com
ServerName localhost
DocumentRoot /var/www/html/
</VirtualHost>
<VirtualHost *:8080>
ServerAdmin me@mydomain.com
ServerName site1
DocumentRoot /var/www/html/site1
</VirtualHost>
<VirtualHost *:8080>
ServerAdmin sleepy@nightmare.com
ServerName site2
DocumentRoot /var/www/html/site2
</VirtualHost>`
/etc/nginx/nginx.conf - amendments On top of this file:
..... $worker_rlimit_nofile 20480;
....
gzip_buffers 32 8k;
gzip_comp_level 6;
gzip_http_version 1.0;
gzip_min_length 1;
The line #include /etc/nginx/conf.d/*.conf has been commented as this was useless for me). All the remained code was unchanged but my IP and servername, in this case I put hostname,and the root instruction remained the same the root /usr/share/nginx/html, which is different from the one in virtual conf file /var/www/html/. My guess is that nginx as front-end does not know (and not even should) where the web files to be served are but Apache.
When I go to any browser and type:
ip shows nginx default page, so i guess it is listening to 80 port; ip/site1 displays site1 ip/site2 displays site2
Any other port but 80 or 8080 displays connection error.
regards.