1、环境
1)ubuntu 12.10
2)安装的是openresty
3)安装过程如下
./configure --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_postgres_module --add-module=../fastdfs-nginx-module/src
make
sudo make install
4)配置文件
nginx.conf文件如下
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
upstream database {
postgres_server 127.0.0.1 dbname=test
user=test password=test;
}
server {
location / {
postgres_pass database;
postgres_query "SELECT * FROM cats";
}
}
}
2、出错
1)启动nginx
sudo /usr/local/nginx/sbin/nginx
2)出错提示
nginx: [emerg] unknown directive "postgres_server" in /usr/local/nginx/conf/nginx.conf:20
3、解决
启动位置错了,把刚才的nginx.conf配置文件放到/usr/local/openresty/nginx/conf下,然后
sudo /usr/local/openresty/nginx/sbin/nginx启动,就不会出错了