nginx上配置phpmyadmin

在ubuntu上使用ppa安装nginx,默认的路径是在/usr/share/nginx

这里列出一些配置文件内容:

1.nginx.conf

user www-data;
worker_processes 4;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

pid /var/run/nginx.pid;

events {
use epoll;
worker_connections 1024;
}
http {
include 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 logs/access.log combined;
client_max_body_size 8m;

sendfile on;
tcp_nopush on;
tcp_nodelay on;

#keepalive_timeout 0;
keepalive_timeout 65;
server_names_hash_bucket_size 128;
variables_hash_max_size 1024;

gzip on; #开启gzip压缩输出
gzip_min_length 1k; #最小压缩文件大小
gzip_buffers 4 16k; #压缩缓冲区
gzip_http_version 1.1; #压缩版本
gzip_comp_level 2; #压缩等级
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;

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

}

2.site-available/default

server {
listen 80;

root /var/www;
index index.php index.html index.htm;

server_name localhost;

location / {
try_files $uri $uri/ =404;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

location ~ /\.ht {
deny all;
}
}

3.安装phpmyadmin

sudo apt-get install phpmyadmin

安装后在/usr/share/phpmyadmin,做一个链接到 /var/www :

ln -s /usr/share/phpmyadmin /var/www/phpmyadmin