Solved

nginx with multiple websites --need help with phpmyadmin please

Posted on 2015-02-17
5
45 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
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

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

Author Comment

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

Accepted Solution

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

Author Comment

by:doc_jay
Comment Utility
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

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Join & Write a Comment

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
The viewer will learn how to count occurrences of each item in an array.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now