操做系統:CentOS php
安裝包:httpd(首選yum), php(包括php以及php-pgsql,php-mbstring,首選yum), phppgadmin , postgresql 。 linux
1、配置php項目部署環境 web
1. 關閉Centos默認的selinux: sql
vi /etc/selinux/config SELINUX=disabled 重啓計算機: /sbin/init 6
2. 安裝apache(手動安裝文件,如:httpd-2.4.4.tar.gz或yum安裝都可) shell
[root@localhost conf]#yum install httpd 默認會安裝到/etc/httd/下面 [root@localhost conf]# which httpd /usr/sbin/httpd
安裝完畢後,能夠先啓動服務service httpd start, 數據庫
而後到瀏覽器輸入地址:http://host:80,正常會出現apache test page的網頁。 apache
3. 安裝php(手動或者yum安裝) 瀏覽器
[root@localhost conf]#yum install php [root@localhost conf]# which php /usr/bin/php [root@localhost conf]#yum install php-pgsql [root@localhost conf]#yum install php-mbstring
2、安裝並配置postgresql數據庫 iview
1. 正常安裝postgresql,能夠經過安裝包安裝或者源碼編譯安裝。 dom
2. 修改pg_hba.conf配置文件,使得數據庫能夠容許外部訪問。
具體能夠配置爲:
# TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all md5 # IPv4 local connections: host all all 127.0.0.1/32 md5 host all all 0.0.0.0/0 md5 # IPv6 local connections: host all all ::1/128 trust host all all 0.0.0.0/0 trust
3、部署並配置phPgAdmin
1. 下載:phpPgAdmin-5.1.tar.gz ,並解壓到到/var/www/ phpPgAdmin-5.1目錄下;
2. 配置所管理的數據庫的參數:
[root@web-dev-machine phppgadmin]# vi /var/www/phppgadmin/conf/config.inc.php
其中必須修改的是:
$conf['extra_login_security'] = false;
其餘的能夠根據所管理的PostgreSQL數據庫的安裝狀況類配置,如:
// Display name for the server on the login screen $conf['servers'][0]['desc'] = 'PostgreSQL'; // Hostname or IP address for server. Use '' for UNIX domain socket. // use 'localhost' for TCP/IP connection on this computer $conf['servers'][0]['host'] = '192.168.100.101'; // Database port on server (5432 is the PostgreSQL default) $conf['servers'][0]['port'] = 5432; // Database SSL mode // Possible options: disable, allow, prefer, require // To require SSL on older servers use option: legacy // To ignore the SSL mode, use option: unspecified $conf['servers'][0]['sslmode'] = 'allow'; // Change the default database only if you cannot connect to template1. // For a PostgreSQL 8.1+ server, you can set this to 'postgres'. $conf['servers'][0]['defaultdb'] = 'template1'; // Specify the path to the database dump utilities for this server. // You can set these to '' if no dumper is available. $conf['servers'][0]['pg_dump_path'] = '/opt/pg932/bin/pg_dump'; $conf['servers'][0]['pg_dumpall_path'] = '/opt/pg932/bin/pg_dumpall';
注意:以上pg_dump_path和pg_dumpall_path在phpPgAdmin中執行導出數據庫時才調用,因此一開始配置錯誤可能不會看到報錯,執行導出時就會報錯。
4、配置php 項目源文件目錄以及監聽端口
vi /etc/httpd/conf/httpd.conf
首先找到端口(默認爲80,根據實際狀況,可改可不改)
# Listen: Allows you to bind Apache to specific IP addresses and/or # ports, in addition to the default. See also the <VirtualHost> # directive. # # Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses (0.0.0.0) # #Listen 12.34.56.78:80 Listen 80
而後是php的文件目錄(必須添加本身的項目的目錄,能夠直接添加到配置文件最後邊)
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased # CGI directory exists, if you have that configured. # <Directory "/var/www/cgi-bin"> AllowOverride None Options None Order allow,deny Allow from all </Directory> #liuyy #phpPgAdmin Alias /phppgadmin "/var/www/phpPgAdmin" <Directory "/var/www/phpPgAdmin"> Options Indexes Multiviews AllowOverride None Order allow,deny Allow from all </Directory>
注意:/phppgadmin纔是在瀏覽器中要輸入的地址,而不是文件名(phpPgAdmin)自己。
5、以上配置完畢後,在terminal中重啓apache服務:service httpd restart
到瀏覽器中輸入地址:http://ip:port/ phppgadmin (默認端口80 能夠省略)
正常會出現phppgadmin的管理界面。