文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>linux+postgresql+apache+php 安装配置文档 + 测..

linux+postgresql+apache+php 安装配置文档 + 测..

时间:2010-07-14  来源:linscora

Apache當Web Server,SSL則使用mod_ssl的Apache外掛模組,而mod_ssl需要OpenSSL才能工作,所以安裝Linux時必須先安裝好OpenSSL套件(包含Source),不然就先想辦法裝 上吧!

首先要先取得以下檔案:

apache_1.3.23.tar.gz

mod_ssl-2.8.6-1.3.23.tar.gz

php-4.1.1.tar.gz

postgresql-7.2.tar.gz

 

 

然後進行解壓縮工作

tar zxvf apache_1.3.23.tar.gz

tar zxvf mod_ssl-2.8.6-1.3.23.tar.gz

tar zxvf php-4.1.1.tar.gz

tar zxvf postgresql-7.2.tar.gz

 

 

先安裝設定好PostgreSQL

cd postgresql-7.2

./configure --enable-unicode-conversion --enable-locale --enable-multibyte --enable-odbc --with-perl --with-maxbackends=1024

gmake

gmake install

 

接下來需要設定PostgreSQL執行環境

 

將/etc/ld.so.conf加入下列這一行

/usr/local/pgsql/lib

 

然後執行命令

/sbin/ldconfig

 

修改/etc/profile

將PATH的 部分加入/usr/local/pgsql/bin,並加入下列三行

PGLIB="/usr/local/pgsql/lib"

PGDATA="/usr/local/pgsql/data"

export PGLIB PGDATA

 

執行下列命令

mkdir /usr/local/pgsql/data

chown postgres /usr/local/pgsql/data

 

切換User為postgres

執行下列命令用以初始化資料 庫

/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

 

執行下列命令用以啟動PostgreSQL

/usr/local/pgsql/bin/postmaster -i -D /usr/local/pgsql/data&

 

然後在/etc/rc.local加入以下這行,以便機器啟動時就啟動PostgreSQL

su -l postgres -c "/usr/local/pgsql/bin/postmaster -i -D /usr/local/pgsql/data"&

 

 

然後先設定一下Apache,以便進行PHP4的 安裝

cd apache_1.3.33

./configure

./configure --prefix=/usr/local/apache --enable-module=info

cd ..

 

安裝PHP4

cd php-4.1.1

./configure --prefix=/usr/local/php --with-apache=../apache_1.3.33 --with-pgsql=/usr/local/pgsql --enable-trans-sid --enable-ftp --enable-discard-path --enable-url-includes

make

make install

cp php.ini-dist /usr/local/lib/php.ini

cd ..

 

 

安裝mod_ssl

cd mod_ssl-2.8.6-1.3.23

./configure --with-apache=../apache_1.3.33

cd ..

 

 

安裝Apache及產生認證檔案

cd apache_1.3.33

./configure --activate-module=src/modules/php4/libphp4.a --enable-module=ssl

make

make certificate

.....中間會問一堆問題,都是資料性,像是國碼,網站名稱等等......

 

然後會產生三個檔案,這三個檔案要保存並保護好,避免被駭客拿去...

conf/ssl.key/server.key

conf/ssl.crt/server.crt

conf/ssl.csr/server.csr

 

make install

 

然後修改/usr/local/apache/conf/httpd.conf

 

將 DirectoryIndex index.html改成

    DirectoryIndex index.html  index.htm  index.php  index.php3  index.shtml

以支援其他類型的Index

 

將下列註解消掉,並加入.php3字 樣,以支援PHP4

    AddType application/x-httpd-php .php .inc

    AddType application/x-httpd-php-source .phps

 

執行/usr/local/apache/bin/apachectl configtest檢查設定

如果沒問題就執行

/usr/local/apache/bin/apachectl startssl

輸入密碼後就可以啟動Apache+SSL了


注:


$dbconn=pg_connect("host=localhost dbname=dbname user=user_name password=user_password")or die("数据库连接错误");

ordie('Couldnotconnect:'.pg_last_error());





// 执行SQL查询


$query='SELECT*FROMauthors';


$result=pg_query($query)ordie('Queryfailed:'.pg_last_error());





// 用HTML显示结果


echo"<table>\n";


while($line=pg_fetch_array($result,null,PGSQL_ASSOC)){


echo"\t<tr>\n";


foreach($lineas$col_value){


echo"\t\t<td>$col_value</td>\n";


}


echo"\t</tr>\n";


}


echo"</table>\n";





// 释放结果集


pg_free_result($result);





//关闭连接


pg_close($dbconn);


?>


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载