centos 使用yum 安裝自訂安裝postgresql和postgis擴充已經phpPgAdmin

來源:互聯網
上載者:User

標籤:centos   yum   postgresql   postgis   phppgadmin   

  1. 系統資訊;

    #head -1  /etc/issue

    CentOS release 6.5 (Final)

  2. 安裝postgresql9.3版本;

    #rpm -ivh http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm

    # yum install postgresql93 postgresql93-server postgresql93-libs postgresql93-contrib postgresql93-devel

  3. 自訂資料庫資料路徑;

    因為本地硬碟儲存不靠譜,所以將資料放於一個本環境中已有的nfs儲存中,本機已經將nfs掛載於/storage目錄,若無此需求的預設即可;

    #vim /etc/init.d/postgresql-9.3

    PGDATA=/var/lib/pgsql/9.3/data

    PGLOG=/var/lib/pgsql/9.3/pgstartup.log

    PGUPLOG=/var/lib/pgsql/$PGMAJORVERSION/pgupgrade.log

    將以上三個路徑修改為自訂路徑如下:(實際只需要修改PGDATA參數即可)

    PGDATA=/storage/pgsql/9.3/data

    PGLOG=/storage/pgsql/9.3/pgstartup.log

    PGUPLOG=/storage/pgsql/$PGMAJORVERSION/pgupgrade.log

  4. 初始化&啟動資料庫&加入開機自啟動&查看資料庫狀態;

    #service postgresql-9.3 initdb    #初始化

    !初始化成功後所有資料庫的設定檔全部都在剛才自訂的目錄內/storage/pgsql/9.3/data

    #service postgresql-9.3 start     #啟動

    #chkconfig postgresql-9.3 on      #加入開機自啟動

    #service postgresql-9.3 status    #查看當前postgresql啟動並執行狀態,如下即可

    postgresql-9.3 (pid  5093) is running...

  5. 設定資料庫可以使用windows下的pgAdmin工具或其他工具串連;

    #cd /storage/pgsql/9.3/data

    #vim postgresql.conf

    取消#listen_addresses = ‘localhost‘ 行注釋並修改為listen_addresses = ‘*‘

    #vim pg_hba.conf 

    在行尾 加入“host   all   all   0.0.0.0/0   md5”   表示允許所有主機均可串連

    #su postgres

    $psql -p 5432

    $alter user  postgres with password ‘123456’  #設定postgres 使用者密碼

    $\q

    $\exit

    # service postgresql-9.3 restart

    # service postgresql-9.3 reload

    postgresql資料庫已經裝好了,並且可以正常使用,如:

    650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/58/98/wKiom1S01KaDbYjMAAPYNdqDk8k961.jpg" title="pgsqlAdmin.png" alt="wKiom1S01KaDbYjMAAPYNdqDk8k961.jpg" />

  6. 安裝postgis擴充&使用postgis擴充;

    #yum install postgis2_93

    #su postgres  

    $psql -p 5432

    $CREATE  EXTENSION postgis;

    CREATE EXTENSION

    $\q

    $\exit

  7. 安裝postgis後,資料庫的變化-;

    650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/58/95/wKioL1S01yOxzM_GAARHlDyaX0g140.jpg" title="postgis.png" alt="wKioL1S01yOxzM_GAARHlDyaX0g140.jpg" />#會增加響應的函數

  8. 安裝phpPgAdmin-方便從web頁面管理postgresql資料庫(類似phpmyadmin);

    #yum list | grep phpPgAdmin   #(查看一下你的源是有這個包)

    phpPgAdmin.noarch                         5.1-1.rhel6                    @pgdg93

    #yum install phpPgAdmin httpd

    #vim  /etc/httpd/conf.d/phpPgAdmin.conf  作如下修改: 

    ‘‘‘

    Alias /phpPgAdmin /usr/share/phpPgAdmin

    <Location /phpPgAdmin>

        Order deny,allow

        #Deny from all

        #Allow from 192.168.0.0/16

        Allow from all

        #Allow from ::1

        # Allow from .example.com

    </Location>

    ‘‘‘

    service  httpd  restart

    chkconfig  httpd on

 9.  現在可以使用http://x.x.x.x/phpPgAdmin  訪問管理頁面:

     #登入可能會失敗 因為SELLinux可能限制使用者串連到PostgreSQL,只需輸入以下命令更改即可

     #執行這個命令”setsebool -P httpd_can_network_connect_db 1“成功後 即可登入

    650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/58/95/wKioL1S02bLRqiUQAAP4BBynk4Q952.jpg" title="postsql.jpg" alt="wKioL1S02bLRqiUQAAP4BBynk4Q952.jpg" />

本文出自 “雲中山” 部落格,請務必保留此出處http://jiapeng.blog.51cto.com/6706171/1603590

centos 使用yum 安裝自訂安裝postgresql和postgis擴充已經phpPgAdmin

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.