GNU/Linux >> Linux の 問題 >  >> Cent OS

CentOSへのPostgreSQLとphpPgAdminのインストール

はじめに

PostgreSQLは、強力なオープンソースのオブジェクトリレーショナルデータベースシステムです。 Linux、UNIX(AIX、BSD、HP-UX、SGI IRIX、Mac OS、Solaris、Tru64)、WindowsOSを含むすべての主要なオペレーティングシステムで動作します。
データベースを操作する非常に効率的な方法を提供します。 PostgreSQLのように、データベースの作成、テーブル、データベースの変更、データベースのエクスポート/インポートなど。

PostgreSQLをインストール

1。 PostgreSQLリポジトリのダウンロードページ(http://yum.postgresql.org/repopackages.php)に移動し、サーバーアーキテクチャに応じてPostgreSQLリポジトリを追加します。

CentOS 6.x 64ビットの場合:

PostgreSQL 9.4 Release : rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm

PostgreSQL 9.5 Release : rpm -Uvh http://yum.postgresql.org/9.5/redhat/rhel-6-x86_64/pgdg-centos95-9.5-1.noarch.rpm

CentOS 7 64ビットの場合:

PostgreSQL 9.4 Release : rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm

PostgreSQL 9.5 Release : rpm -Uvh http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-1.noarch.rpm

2.コマンドを使用してリポジトリリストを更新します:

yum update

3.次のコマンドを使用してpostgresqlをインストールします。

For PostgreSQL 9.4:
 yum install postgresql94-server postgresql94-contrib
For PostgreSQL 9.5
 yum install postgresql95-server postgresql95-contrib

4.次のコマンドを使用してpostgresqlデータベースを初期化します:

CentOS 6.xシステムの場合:

For PostgreSQL 9.4
 service postgresql-9.4 initdb
For PostgreSQL 9.5
 service postgresql-9.5 initdb

CentOS 7システムの場合:

For PostgreSQL 9.4
 /usr/pgsql-9.4/bin/postgresql94-setup initdb
For PostgreSQL 9.5
 /usr/pgsql-9.5/bin/postgresql95-setup initdb

5. postgresqlサービスを開始し、再起動するたびに自動的に開始するようにします。

CentOS 6.xシステムの場合:

For PostgreSQL 9.4
 service postgresql-9.4 start
 chkconfig postgresql-9.4 on
For PostgreSQL 9.5
 service postgresql-9.5 start
 chkconfig postgresql-9.5 on

CentOS 7システムの場合:

For PostgreSQL 9.4
 systemctl start postgresql-9.4
 systemctl enable postgresql-9.4
For PostgreSQL 9.5
 systemctl start postgresql-9.5
 systemctl enable postgresql-9.5

PostgreSQLコマンドプロンプトにアクセス

デフォルトのデータベース名とデータベースユーザーは「postgres」です。 postgresユーザーに切り替えてpostgresql関連の操作を実行します:

1. postgresqlプロンプトにログインし、次のコマンドを入力します:

su - postgres
 psql

2。次のコマンドでpostgresSQLパスワードを設定します:

Sample Output:

 postgres=# \password postgres
 Enter new password:
 Enter it again:
 postgres=# \q

3。 posgresqlプロンプトを終了するには、\ qに続いて終了し、ターミナルに戻ります。

新しいユーザーとデータベースを作成する

たとえば、パスワード「centos」を使用して「e2enetworks」という新しいユーザーを作成し、「mydb」というデータベースを作成してみましょう。

Switch to postgres user:
 $ su - postgres
Create user e2enetworks:
 $ createuser  e2enetworks
Create database:
 $ createdb mydb

次に、psqlプロンプトにログインし、パスワードを設定して、e2enetworksのデータベースmydbへのアクセスを許可します。

$ psql#
psql (9.4.0)
 Type "help" for help.postgres=# alter user e2enetworks with encrypted password 'centos';
 ALTER ROLEpostgres=# grant all privileges on database mydb to e2enetworks;
 GRANT
 postgres=#

phpPgAdminを使用してPostgreSQLを管理する

phpPgAdminは、PosgreSQLを管理するためにPHPで記述されたWebベースの管理ユーティリティです。

1.次のコマンドを入力します:

yum install epel-release
 yum update

2.ここで、phpPgAdminをインストールし、次のコマンドを入力します。

yum install phpPgAdmin

注: phpPgAdminでは大文字と小文字が区別されます。上記のコマンドに示すように、大文字と小文字を正しく使用してください。

デフォルトでは、ローカルシステムからのみhttp:// localhost/phpPgAdminを使用してphppgadminにアクセスできます。リモートシステムにアクセスするには、以下の次の手順を実行します。

3.ファイル/etc/httpd/conf.d/phpPgAdmin.confを編集します:

vim /etc/httpd/conf.d/phpPgAdmin.conf

以下に示すように変更を加えます:

Alias /phpPgAdmin /usr/share/phpPgAdmin

<Location /phpPgAdmin>
 <IfModule mod_authz_core.c>
 # Apache 2.4
 Require all granted
 #Require host example.com
 </IfModule>
 <IfModule !mod_authz_core.c>
 # Apache 2.2
 Order deny,allow
 Allow from all
 # Allow from .example.com
 </IfModule>
 </Location>

4。 Apacheサービスを開始または再起動します:

On CentOS 6.x systems:
 service httpd start
 chkconfig httpd on
On CentOS 7 systems:
 systemctl enable httpd
 systemctl start httpd

phpPgAdminの構成:

1.ファイル/etc/phpPgAdmin/config.inc.phpを編集し、次の変更を行います。これらのオプションのほとんどは自明です。それらを注意深く読んで、なぜこれらの値を変更するのかを理解してください。

vim /etc/phpPgAdmin/config.inc.php

以下に示すように変更を加えます:

$conf['servers'][0]['host'] = 'localhost';
 $conf['extra_login_security'] =false;
 $conf['owned_only'] =true;

2。ファイルを保存して閉じます。 postgresqlサービスとApacheサービスを再起動します。

次に、ブラウザを開いて、 http:// ip-address / phpPgAdminに移動します。
phpPgAdmin画面が表示されます。


Cent OS
  1. Centos6へのTomcat8のインストール

  2. CentOS7へのMariaDBのインストール

  3. CentOS、RedHat、FedoraへのJAVA8JDKのインストール

  1. CentOS7にPostgreSQLをインストールする方法

  2. Ubuntu15.04にPostgresqlとphpPgAdminをインストールする方法

  3. CentOS6でのJAVAおよびJBoss7Finalのインストールとセットアップ

  1. Centos8にPostgres13をインストールして設定する方法

  2. Centos8へのphp7xのインストールと設定

  3. Centos4.8およびGlibc2.5?