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

ubuntu安装nginx、php、mysql

nginx是高性能的网站服务,发音为 engine x,网站为:http://wiki.nginx.org
在linux下安装nginx、php、mysql这套方案可以简称为lnmp或lemp。

os: ubuntu 13.10 64bit
nginx: 1.2.6-1ubuntu3.3
php5-fpm: 5.4.9-4ubuntu2.4
mysql: 5.5.34-0ubuntu0.13.04.1

1.安装nginx

sudo apt-get install nginx
如果要安装最新稳定版,可以用ppa的源
注意:使用ppa配置文件的值有点不一样,建议下载nginx源代码,使用里面的配置文件。
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx

2.安装php5

sudo apt-get install php5-fpm

常用的扩展

sudo apt-get install  php-mysql php-curl php-gd php-intl php-pear php-imagick php-xmlrpc php-memcache php-imap

不常用的扩展

sudo apt-get install php5-mcrypt php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy

安装完扩展之后需要重启一下fpm : sudo service php5-fpm restart

如果php5-mcrypt没生效,则需要在/etc/php5/fpm/conf.d中做个链接:

sudo ln -s ../../mods-available/mcrypt.ini 20-mcrypt.ini

3.为nginx启用php支持

修改/etc/nginx/sites-available/default,加亮的为修改的部分

server {
listen 80;

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

server_name localhost;

location / {
try_files $uri $uri/ /index.php;
}

location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}

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_index index.php;
include fastcgi_params;
}

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

配置完后重启nginx。

4.安装mysql-server

sudo apt-get install mysql-server

5.nginx的配置文件说明
http://my.oschina.net/winHerson/blog/143781
http://my.oschina.net/u/586648/blog/146824