nginx hanging for subdomain - php

I'm having some trouble getting nginx to work on a subdomain. I have two conf files in /etc/nginx/conf.d/ as follows (some details in the first redacted):
mydomain.conf: the site proper, server_name of mydomain.com and www.mydomain.com:
server {
listen 80;
root /var/www/sites/mydomain;
index index.php;
server_name mydomain.com www.mydomain.com;
access_log /var/log/nginx/mydomain.access.log;
error_log /var/log/nginx/mydomain.error.log;
...
}
phpmyadmin.conf:
server {
listen 80;
root /var/www/sites/phpmyadmin;
index index.php;
server_name pma.mydomain.com;
access_log /var/log/nginx/phpmyadmin.access.log;
error_log /var/log/nginx/phpmyadmin.error.log;
location / {
index index.php;
}
location ~* \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Currently, /var/www/sites/phpmyadmin just contains an index.php with <?php phpinfo(): ?> in it and nothing else. This is on an EC2 instance and I'm trying to load the pages from another computer, wherein both mydomain.com and pma.mydomain.com are set to its IP address in my /etc/hosts.
Navigating to mydomain.com works perfectly fine, PHP works, etc. However when I navigate to the subdomain, it hangs. For any other subdomain the connection immediately fails (there are no DNS records). But for pma it simply doesn't load.
My log files for pma are empty and unhelpful. I have no idea how to debug this silent failure and it's driving me insane.

Probably an issue with the FastCGI handler (are you using php-fpm?) running at 127.0.0.1:9000 - is it running and accepting connections?
Debug it by SSHing to that machine and running:
curl -vv http://127.0.0.1:9000/
What happens?

Related

Cannot pass parameter 1 by reference error when migrating my Joomla website from Apache to NginX

I'm getting this error when I serve my Joomla on server_name www.domain.com. No error if I serve the same Joomla directory with server_name test.domain.com
I have a production server that is on an AWS EC2 instance and run smoothly the last years under Apache web server and I'm trying to migrate the whole Joomla installation to be served by an NginX/PHP container on a different environment.
So I just got the files and the database and start testing. Everything was fine when I was testing on www.dev.domain.com (development environment as well to test.domain.com (production environment).
The problem popped up when I changed to www.domain.com
I've tried different server_names.
I've tried to serve an index.html file instead of my original index.php file and works fine even if I place it at the end of the URL manually or even if I set it into my nginx.conf as index;
Joomla backend (administration) works fine on www.domain.com/administrator
I tried server_name domain.com www.domain.com test.domain.com; into my configuration but only test.domain.com was functional.
*In cases with no error, the site is fully functional
server {
listen 80;
server_name domain.com www.domain.com test.domain.com;
server_name_in_redirect off;
root /var/www/html;
index index.php;
access_log /logs/access.log;
location ~ [^/]\.php(/|$) {
proxy_cache my_cache;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_param HTTP_PROXY "";
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
server_tokens off;
try_files $uri $uri/ /index.php?$args;
}
}
I was expecting the site to run smoothly with no issues as it was served fine under test.domain.com server_name but I got the error bellow:
0 Cannot pass parameter 1 by reference Please try one of the following
pages: HOME PAGE
Problem Solved.
There was a published Virtual Domain into my Joomla installation. A setting configured from my predecessor system administrator or maybe my company's web developers.
So, I unpublished that through my.domain.com/administrator console components->Virtual Domains and everything went smooth as well with my
server_name www.domain.com
You should upgrade Virtual Domains component for Joomla from 1.3.1 to 1.3.2.
1.3.2 version works with PHP7.

Serving domain and sub-domain with Nginx and php-fpm

Basically I need to logically separate 2 sites on one hosting and one domain name registered.
Firstly, I've set up a sub-domain using CNAME record. Then I've created 2 files for domain and sub-domain (no syntax errors, nginx restarted after changes):
subdomain.conf
server {
listen 80;
server_name sub.domain.com;
index index.php index.html;
root /web/www/sub.domain.com;
access_log off;
server_tokens off;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/webserv/var/php-cgi.sock;
fastcgi_index index.php;
include /webserv/nginx/conf/fastcgi.conf;}}
domain.conf
server {
listen 80;
server_name domain.com;
index index.php index.html;
root /web/www/domain.com;
access_log off;
server_tokens off;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/webserv/var/php-cgi.sock;
fastcgi_index index.php;
include /webserv/nginx/conf/fastcgi.conf;}}
But only one of them is working, and a request in browser to the other doesn't even get to nginx, and eventually it says the page load time was too long. What is the easiest way of doing this? Should several instances of nginx, php-fpm be used?
Your configuration looks fine, if the seconde file was enabled and wrong nginx would have triggered a server error, but from what you are saying the problem come from your domain name, maybe it is missconfigured or has not yet been propagated.
Resolved, it wasn't working as I was using google public DNS on local machine(who would have thought)

Vagrant setup for nginx load balancing with a php site

I've looked up a few topics on here around this, but none of the solutions I've found so far seem to work.
I have 3 boxes created via a Vagrantfile with puppet modules, which have nginx and php installed. I've created a simple webpage to output the host name statically, plus php info.
On the load balancer I have the following code for /etc/nginx/sites-available/127.0.0.1 (note this is now the default site and linked setup through my Vagrantfile)
# vagrant/puppet/modules/nginx/files/loadBalancer/127.0.0.1
upstream backend {
server 192.168.205.20; #ip of second machine
server 192.168.205.30; #ip of third machine
}
server {
listen 80;
server_name _;
root /var/www/app;
index index.php;
location / {
try_files $uri /index.php;
proxy_pass http://backend;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
The two additional hosts which host this web app, have the following file for their /etc/nginx/sites-available/127.0.0.1
# vagrant/puppet/modules/nginx/files/127.0.0.1
server {
listen 80;
server_name _;
root /var/www/app;
index index.php;
location / {
try_files $uri /index.php;
proxy_pass http://backend;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
However, this results in only one page coming up (the load balancers, it never alternates to the other two like it should).
I have also tried passing in the backend upstream as the fastcgi_pass but this causes a 502 bad gateway. Is there something I am misunderstanding as far how this should function? Any help would really be appreciated!

Laravel does not appear when browsing VPS's IP

I've just installed Laravel 4 with nginx on my ubuntu vps following this tutorial:
https://www.digitalocean.com/community/articles/how-to-install-laravel-with-nginx-on-an-ubuntu-12-04-lts-vps
Evertything seemed to be installed fine, however when browsing it's ip adress, I still get:
It works!
This is the default web page for this server. The web server software is running but no content has been added, yet.
I thought this could have something to do with the virtual host, but that one seems to be configured correctlt aswell
server {
listen 80 default_server;
root /var/www/laravel/public/;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
# pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Would anynone know what I'm doing wrong?
Thank you!
Your web server should point to the /public folder not the root of your laravel application.
That is /var/www/laravel/public not /var/www/laravel/.
Also make sure you restart your server to load up configuration files.

NGINX server is downloading php files

i'm trying to setup nginx on my vps and i made it however when i'm try to use .php files it download then instead of runing them. This is my nginx.conf
server {
listen 80;
server_name site;
root /var/www/;
index index.php index.html;
}
Any ideas how to fix it?
(i have php5-fpm installed)
For pass the PHP scripts to FastCGI you must add this into server config:
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
You really need to enable php-cgi/fast-cgi or -cli depending on your server/vps configuration.
share with us more information to be able to help you (like config files etc.)

Categories