【问题标题】:How to install postgresql and phppgadmin with nginx?如何使用 nginx 安装 postgresql 和 phppgadmin?
【发布时间】:2019-10-31 17:19:16
【问题描述】:

我需要在 ubuntu 16(AWS) 下安装 nginx 的 postgresql 和 phppgadmin 我安装了软件包:

$ sudo apt-get -y install postgresql postgresql-contrib phppgadmin
Reading package lists... Done
Building dependency tree       
Reading state information... Done
phppgadmin is already the newest version (5.1+ds-1ubuntu1).
postgresql is already the newest version (9.5+173ubuntu0.2).
postgresql-contrib is already the newest version (9.5+173ubuntu0.2).
0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.

在 phpinfo 中我看到已安装驱动程序 http://ec2-18-224-82-207.us-east-2.compute.amazonaws.com/info.php

PostgreSQL driver for PDO   Edin Kadribasic, Ilia Alshanetsky
PostgreSQL  Jouni Ahto, Zeev Suraski, Yasuo Ohgaki, Chris Kings-Lynne

但是在 url 中运行 phppgadmin,例如: http://ec2-18-224-82-207.us-east-2.compute.amazonaws.com/phppgadmin 我得到了错误:

404 Not Found
nginx/1.10.3 (Ubuntu)

搜索决定我发现 /etc/nginx/sites-available/phppgadmin 目录,但是:

$ cd /etc/nginx/sites-available
ubuntu@ip-172-31-34-88:/etc/nginx/sites-available$ ls -la
total 16
drwxr-xr-x 2 root root 4096 Jun 18 05:15 .
drwxr-xr-x 6 root root 4096 Jun 12 15:46 ..
-rw-r--r-- 1 root root 2327 Jun 17 12:02 default
-rw-r--r-- 1 root root 2074 Jun 12 15:49 default.bak

我必须采取哪些步骤来运行 phppgadmin 和 laravel 5 应用程序?

【问题讨论】:

    标签: nginx ubuntu-16.04 phppgadmin


    【解决方案1】:

    1.安装

    首先,安装 postgreSQL 和 phpPgAdmin。

    sudo apt-get update
    sudo apt-get install postgresql postgresql-contrib phppgadmin php5-fpm
    

    然后,让我们安装 Nginx。

    sudo apt-get install nginx
    

    这应该会自动启动 Nginx 作为 Web 服务器。你也可以输入这个来启动服务。

    sudo service nginx start
    

    2。设置 PostgreSQL 和 phpPgAdmin

    首先以 Postgres 用户身份登录,然后创建一个新的 Postgres 角色(用户)

    sudo su postgres
    createuser -P --interactive
    

    --interactive - 添加一些初始权限 -P - 表示分配密码

    phpPgAdmin 的默认安装会自动连接到 PostgreSQL 服务器。除非您修改了任何配置,否则您可以保持原样。

    3.设置 Nginx

    首先,让我们添加一个符号链接到您打算放置所有 Web 文件的目录。

    sudo ln -s /usr/share/webapps/phppgadmin /path/to/your/www
    

    接下来,让我们为 phpPgAdmin 创建一个服务器块。使用以下内容创建文件 /etc/nginx/sites-available/phppgadmin。

    # Server block for phppgadmin service
    server{
            server_name     phppgadmin.example.com;
            root            /path/to/your/www/phppgadmin;
    
            access_log      /var/log/phppgadmin/access.log;
            error_log       /var/log/phppgadmin/error.log;
    
            location ~ \.php$ {
                    try_files $uri =404;
                    fastcgi_split_path_info ^(.+\.php)(/.+)$;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_index index.php;
                    fastcgi_param SCRIPT_FILENAME /path/to/your/www/postgres$fastcgi_script_name;
                    include /etc/nginx/fastcgi_params;
            }
    }
    

    默认情况下,Nginx 包含文件夹/etc/nginx/sites-enabled 中的所有服务器。因此,让我们为我们创建的新服务器添加一个符号链接,让 nginx 知道我们的新服务器!

    sudo ln -s /etc/nginx/sites-available/phppgadmin /etc/nginx/sites-enabled/
    

    现在剩下要做的就是重新启动/重新加载 Nginx,我们的 phpPgAdmin 已经准备就绪!

    sudo service nginx restart
    

    确保您已将这些内容包含在 nginx.conf 文件中。

    index   index.php index.htm index.html;
    root    /usr/share/nginx/html;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-01
      • 1970-01-01
      • 2019-04-14
      • 1970-01-01
      • 2018-02-22
      相关资源
      最近更新 更多