apache2.0.58無法支援PHP



贊助商連結


lych911
2006-06-15, 01:50 PM
小弟我安裝好apache2+php5+myslq後,正準備要測試是否有支援php成功,結果開啟phpinfo.php網頁一片空白
phpinfo.php內容如下
<?
phpinfo();
?>
我的安裝過程如下

Apache安裝
#./configure –-prefix=/usr/local/apache2 指定安裝路徑 –-prefix=/usr/local/apache2
#make
#make install
編輯httpd.conf檔案
#/usr/local/apache2/bin/apachectl start

MySql安裝
#./configure –-prefix=/usr/local/mysql –-localstatedir=/usr/local/mysql/data -–with-charset=big5
指定安裝路徑 –-prefix=/usr/local/mysql
指定資料庫存放位置 –-localstatedir=/usr/local/mysql/data預設為/usr/local/var
支援big5中文 –with-charset=big5
#make
#make install
#cp support-files/my-medium.cnf /etc/my.cnf
#cd /usr/local/mysql
如果無mysql組群帳號先新增
#adduser –M mysql
說明:-M 強制!不要建立使用者家目錄
#passwd mysql
#bin/mysql_install_db --user=mysql
#chown -R root .
#chown -R mysql data
#chgrp -R mysql .
啟動mysql
#/usr/local/mysql/bin/mysqld_safe --user=mysql &
停止mysql
#/usr/local/mysql/share/mysql/mysql.server stop
設定mysql密碼
#/usr/local/mysql/bin/mysqladmin -u root password '你的密碼'
連結資料庫:
/usr/local/mysql/bin/mysql -u root –p
輸入密碼
PHP安裝
若要讓PHP支援GD圖形的話,在安裝PHP前要先安裝GD函示庫,必要套件有
zlib-x.x.x
libpng-x.x.x
gd-x.x.x

首先安裝zlib,#不要用--prefix指訂安裝目錄會影響GD
#tar –zxvf zlib-x.x.x
#cd zlib-x.x.x
#./configure
#make
#make install

再來安裝libpng,#不要用--prefix指訂安裝目錄會影響GD
#bzip2 –d libpng-x.x.x.tar.bz2
#tar –xvf libpng-x.x.x.tar
#cd lib-x.x.x
#./configure
#make
#make install

安裝jpeg-6b
首先要到/usr/local目錄下建立幾個目錄
#mkdir jpeg6
#cd jpeg6
#mkdir lib
#mkdir bin
#mkdir man
#mkdir man/man1
#mkdir include
要先建立以上的目錄,這樣在make install時才不會出現錯誤
#tar –zxvf jpegsrc.v6b.tar.gz
#cd jpeg-6b
#./configure –prefix=/usr/local/jpeg6 –-enable-shared --enable-static
#make
#make install

安裝GD函示庫
#tar –zxvf gd-x.x.x.tar.gz
#cd gd-x.x.x
#./configure –prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg6 --with-png --with-zlib
#make
#make install

以上都安裝完成後見開始安裝PHP
# ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql -–prefix=/usr/local/php5 --enable-mbstring --with-gd=/usr/local/gd --with-zlib --with-png --with-jpeg-dir=/usr/local/jpeg6
#make
#make install
# cp php.ini-dist /usr/local/php5/lib/php/php.ini
到此安裝結束

贊助商連結


lych911
2006-06-15, 02:01 PM
以下是我的 http.conf 檔內容
ServerRoot "/usr/local/apache2"

<IfModule !mpm_winnt.c>
<IfModule !mpm_netware.c>
#LockFile logs/accept.lock
</IfModule>
</IfModule>

#
# ScoreBoardFile: File used to store internal server process information.

<IfModule !mpm_netware.c>
<IfModule !perchild.c>
#ScoreBoardFile logs/apache_runtime_status
</IfModule>
</IfModule>

<IfModule !mpm_netware.c>
PidFile logs/httpd.pid
</IfModule>

Timeout 300

KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 15

<IfModule prefork.c>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
</IfModule>

<IfModule worker.c>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>

<IfModule perchild.c>
NumServers 5
StartThreads 5
MinSpareThreads 5
MaxSpareThreads 10
MaxThreadsPerChild 20
MaxRequestsPerChild 0
</IfModule>

<IfModule mpm_winnt.c>
ThreadsPerChild 250
MaxRequestsPerChild 0
</IfModule>

<IfModule beos.c>
StartThreads 10
MaxClients 50
MaxRequestsPerThread 10000
</IfModule>

<IfModule mpm_netware.c>
ThreadStackSize 65536
StartThreads 250
MinSpareThreads 25
MaxSpareThreads 250
MaxThreads 1000
MaxRequestsPerChild 0
MaxMemFree 100
</IfModule>

<IfModule mpmt_os2.c>
StartServers 2
MinSpareThreads 5
MaxSpareThreads 10
MaxRequestsPerChild 0
</IfModule>

#Listen 12.34.56.78:80

Listen 80

# Example:
# LoadModule foo_module modules/mod_foo.so
LoadModule php5_module modules/libphp5.so

<IfModule !mpm_winnt.c>
<IfModule !mpm_netware.c>
User nobody
Group #-1
</IfModule>
</IfModule>

ServerAdmin [email protected]

ServerName www.a-smile.com.tw:80

UseCanonicalName Off

DocumentRoot "/usr/local/apache2/htdocs"

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

<Directory "/usr/local/apache2/htdocs">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

UserDir public_html

DirectoryIndex index.php index.html index.htm


AccessFileName .htaccess

<FilesMatch "^\.ht">
Order allow,deny
Deny from all
</FilesMatch>

TypesConfig conf/mime.types

DefaultType text/plain

<IfModule mod_mime_magic.c>
MIMEMagicFile conf/magic
</IfModule>

HostnameLookups Off

ErrorLog logs/error_log

LogLevel warn

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

CustomLog logs/access_log common

ServerTokens Full

ServerSignature On

Alias /icons/ "/usr/local/apache2/icons/"

<Directory "/usr/local/apache2/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

AliasMatch ^/manual(?:/(?:de|en|es|fr|ja|ko|ru))?(/.*)?$ "/usr/local/apache2/manual$1"

<Directory "/usr/local/apache2/manual">
Options Indexes
AllowOverride None
Order allow,deny
Allow from all

<Files *.html>
SetHandler type-map
</Files>

SetEnvIf Request_URI ^/manual/(de|en|es|fr|ja|ko|ru)/ prefer-language=$1
RedirectMatch 301 ^/manual(?:/(de|en|es|fr|ja|ko|ru)){2,}(/.*)?$ /manual/$1$2
</Directory>

ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"

<IfModule mod_cgid.c>
#Scriptsock logs/cgisock
</IfModule>

<Directory "/usr/local/apache2/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

IndexOptions FancyIndexing VersionSort

AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*

AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core

AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^

DefaultIcon /icons/unknown.gif

ReadmeName README.html
HeaderName HEADER.html

IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t

AddLanguage ca .ca
AddLanguage cs .cz .cs
AddLanguage da .dk
AddLanguage de .de
AddLanguage el .el
AddLanguage en .en
AddLanguage eo .eo
AddLanguage es .es
AddLanguage et .et
AddLanguage fr .fr
AddLanguage he .he
AddLanguage hr .hr
AddLanguage it .it
AddLanguage ja .ja
AddLanguage ko .ko
AddLanguage ltz .ltz
AddLanguage nl .nl
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pl .po
AddLanguage pt .pt
AddLanguage pt-BR .pt-br
AddLanguage ru .ru
AddLanguage sv .sv
AddLanguage zh-CN .zh-cn
AddLanguage zh-TW .zh-tw

LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW

ForceLanguagePriority Prefer Fallback

AddCharset ISO-8859-1 .iso8859-1 .latin1
AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen
AddCharset ISO-8859-3 .iso8859-3 .latin3
AddCharset ISO-8859-4 .iso8859-4 .latin4
AddCharset ISO-8859-5 .iso8859-5 .latin5 .cyr .iso-ru
AddCharset ISO-8859-6 .iso8859-6 .latin6 .arb
AddCharset ISO-8859-7 .iso8859-7 .latin7 .grk
AddCharset ISO-8859-8 .iso8859-8 .latin8 .heb
AddCharset ISO-8859-9 .iso8859-9 .latin9 .trk
AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5 .Big5 .big5
# For russian, more than one charset is used (depends on client, mostly):
AddCharset WINDOWS-1251 .cp-1251 .win-1251
AddCharset CP866 .cp866
AddCharset KOI8-r .koi8-r .koi8-ru
AddCharset KOI8-ru .koi8-uk .ua
AddCharset ISO-10646-UCS-2 .ucs2
AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-8 .utf8

AddCharset GB2312 .gb2312 .gb
AddCharset utf-7 .utf7
AddCharset utf-8 .utf8
AddCharset big5 .big5 .b5
AddCharset EUC-TW .euc-tw
AddCharset EUC-JP .euc-jp
AddCharset EUC-KR .euc-kr
AddCharset shift_jis .sjis

AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php.phtml

AddHandler type-map var

BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0

BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "MS FrontPage" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully
BrowserMatch "^gnome-vfs" redirect-carefully
BrowserMatch "^XML Spy" redirect-carefully
BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully

<IfModule mod_ssl.c>
Include conf/ssl.conf
</IfModule>
請問是哪裡出問題了,之前照這樣方式安裝(之前的是http-2.0.55,php-5.1.2)都正常,但是這次卻不行,請各位指導一下,謝謝。:confused:

hpo14
2006-06-15, 08:56 PM
AddType application/x-httpd-php .php.phtml

中間不是應該要空白嗎?

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

Redeye
2006-06-15, 09:46 PM
為啥不用 ports 裝呢...
freebsd 主機預設的網頁放在 /usr/local/www/data 下.
然後爬一下網頁就會找到很多安裝設定的說明了..

其他設定也都可以用 ports 裝好..
不過現在很多php的相關組態設定都改成在..
/usr/ports/lang/php5-extensions 下選項安裝..

假如很想快速安裝完所有相關伺服程式..
freebsd os 主機有個很方便的ports建議你可以試試看..
# cd /usr/ports/misc/instant-server
# make install clean

這麼簡單就完成了.
這個 ports 會幫你安裝完很多需要的 ports.
以下是我複製來的內容..

instant-server-1.0_2
Instant server installs a typical set of ports for a server
Long description | Sources
Maintained by: [email protected]
Requires: XFree86-libraries-4.5.0, apache-1.3.36, cnews-cr.g_8, cups-base-1.1.23.0_9, cvsup-16.1h_2, expat-2.0.0_1, fontconfig-2.3.2_5,1, freetype2-2.1.10_3, gettext-0.14.5_2, gnutls-1.2.11, isc-dhcp3-server-3.0.4_2, jpeg-6b_4, libgcrypt-1.2.2_1, libgpg-error-1.3, libiconv-1.9.2_2, pcre-6.6_1, pkg-config-0.20_2, png-1.2.8_3, popt-1.7_1, postfix-2.2.10_1,1, rc_subr-1.31_1, samba-2.2.12_2, squid-2.5.14_1, tiff-3.8.2, traceroute-991603

其他的設定說明找找教學網頁說明如法砲製就成了.good luck!!

lych911
2006-06-16, 03:47 PM
恩~解決了,多謝指教^^