Solved

nginx with multiple websites --need help with phpmyadmin please

Posted on 2015-02-17
5
86 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

691 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