I have been trying to get this to work for hours now!
I would like to set up a simple web server. My web files shall be in /var/www
. I also want to have phpmyadmin. I created a directory /var/phpmyadmin
. Now I want to acces the normal web files in the standard way.
For instance: The file /var/www/test.php
should be accesible with http://localhost/test.php
.
The phpmyadmin part should be acces like this: http://localhost/phpmyadmin
. With the config below I get a 404. Also with this URL: http://localhost/phpmyadmin/index.php
For this I created this file in the sites-availble folder of nginx:
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default_server ipv6only=on; ## listen for ipv6
root /var/www;
index index.html index.htm index.php;
try_files $uri $uri/ $uri/index.html $uri/index.htm $uri/index.php;
# This didn't work
location /phpmyadmin/ {
alias /var/phpmyadmin;
}
# And this did neither. (Never used both at the same time!)
location /phpmyadmin/ {
root /var;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
What am I doing wrong?
Edit:
Interesting to note is that this works (The root directory works (http://localhost
)):
root /var/www/htdocs;
index index.php index.html index.htm;
location /phpmyadmin/ {
root /var/www/phpmyadmin;
}
And this doesn't:
index index.php index.html index.htm;
location / {
root /var/www/htdocs;
}
location /phpmyadmin/ {
root /var/www/phpmyadmin;
}
phpmyadmin still doesn't work!