Solved

nginx with multiple websites --need help with phpmyadmin please

Posted on 2015-02-17
5
79 Views
Last Modified: 2016-05-27
CENTOS 7
NGINX
PHP-FPM

  I currently have one website named 'paperwork' successfully running in nginx, but need to add phpmyadmin as well.  Phpmyadmin was running in apache fine, but I switched to nginx.  I would like my 'paperwork' site to run on port '8888' and 'phpmyadmin' to run on port '80'.  Both of my services, 'nginx' and 'php-fpm' start fine without issues.

I have two '.conf' files in my '/etc/nginx/conf.d' folder and have that path included in my 'nginx.conf' file.

files I have in that folder:  'paperwork.conf' (this 'paperwork' site works just fine) & 'phpmyadmin.conf'

The current path to 'phpmyadmin' is '/usr/share/phpMyAdmin'

When I try to go to the 'phpmyadmin' site 'http://192.168.1.44/phpmyadmin' it comes back with a blank page.

in '/var/log/nginx/error.log', that file contains no errors
2015/02/17 08:39:17 [notice] 31891#0: signal process started

Open in new window


in 'var/log/phpMyAdmin.error.log' - this contains
2015/02/17 09:19:40 [error] 31893#0: *8 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 10.10.51.100, server: localhost, request: "GET /phpMyAdmin/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "192.168.1.44"

Open in new window


Help please!

my '/etc/nginx/nginx.conf' file contents:

user  nginx;
worker_processes  2;

error_log  /var/log/nginx/error.log;

pid        /run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    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;

    keepalive_timeout  65;

    include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;

    index   index.html index.htm;
}

Open in new window


my '/etc/php-fpm./www.conf' file contains:

user = nginx
group = nginx
listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660

Open in new window


Here is the contents of '/etc/nginx/conf.d/paperwork.conf':
server {
    listen       8888;
    server_name  localhost;
    set  $root_path '/var/www/html/paperwork/frontend/public';
    root  $root_path;

    index  index.php index.html index.htm;

    try_files $uri $uri/ @rewrite;

    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=/$1;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_split_path_info       ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
        root $root_path;
    }
    location ~ /\.ht {
        deny all;
    }
}

Open in new window


here is the content of 'phpmyadmin.conf'
server{
    listen 80;
    server_name localhost;
    access_log /var/log/phpMyAdmin.access_log;
    error_log /var/log/phpMyAdmin.error_log;

    location /phpMyAdmin {
      alias /usr/share/phpMyAdmin;
      index  index.html index.htm index.php;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME /usr/share/phpMyAdmin$fastcgi_script_name;
    }

}

Open in new window

0
Comment
Question by:doc_jay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:R. Toby Richards
ID: 40614778
For one thing, Nginx is case sensitive. You should be browsing to http://192.168.1.44/phpMyAdmin
0
 

Author Comment

by:doc_jay
ID: 40614782
I've tried that as well, same result.
0
 
LVL 5

Accepted Solution

by:
R. Toby Richards earned 500 total points
ID: 40614791
I believe your server section requires a root path directive.
0
 

Author Comment

by:doc_jay
ID: 40614842
I do believe your right!  thanks, all works as expected now.

One other thing, how can I call the 'phpmyadmin' site with 'http://my.ip.address/pma' instead?

I tried changing this:

location /phpMyAdmin {
      alias /usr/share/phpMyAdmin;
      index  index.html index.htm index.php;
    }

Open in new window


location /pma {
      alias /usr/share/phpMyAdmin;
      index  index.html index.htm index.php;
    }

Open in new window


..but as you probably already knew, it didn't work  ;-)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
The viewer will learn how to dynamically set the form action using jQuery.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question