安裝網絡服務器在FreeBSD 6.0與亞帕基印第安人2.2, MySQL 5.0和PHP 5 -第5部分
安裝亞帕基印第安人2.2, MySQL 5和PHP 5在FreeBSD 6.0為一臺可靠的網絡服務器
第5部分-安裝PHP超文件前處理器寫電影腳本的語言5和PHP 5引伸
- 安裝輸入以下命令在FreeBSD OS命令行,等待早先命令在跑下個命令之前完成:
CD的/usr/ports/lang/php5
做安裝乾淨 - 如果您被提示,精選的「用途亞帕基印第安人2.x改為」。
- 繼續通過以下命令安裝PHP5引伸和模塊使能模塊的支持在亞帕基印第安人:
CD的/usr/ports/lang/php5-extensions
做設置 - 在選擇為php5引伸1.0菜單,選擇您可以用Apache Web Server使用的所有PHP引伸和模塊。 這是配置的部分為PHP,您需要使能PHP特點進來模塊,例如能力處理用戶會話,協調與數據庫和許多其他。 缺省引伸例如ctype作用支持、回鍋碎肉消息摘要框架支持、會議支持和等被選擇了。 其他普遍的引伸您很可能在使用是MySQL數據庫支持和GD圖書館支持。 用途空格鍵選擇的或unselect引伸和新聞進入,當做。
- 繼續php5引伸的設施以以下命令:
做安裝乾淨
- 如果有任何消息流行音樂,并且提示選擇有些選擇或配置的您,您能通過按接受缺省設置進入。 也許提示您為行動的有些模塊包括php5-gd、php5-mbstring和php5-sqlite。
- 編輯亞帕基印第安人配置文件為了使Apache Web Server裝載PHP模塊,當初始化:
- 去亞帕基印第安人配置文件地點由CD的/usr/local/etc/apache2/
- 由vi httpd.conf編輯亞帕基印第安人配置文件
- 搜尋LoadModule線,在最後LoadModule線以後,但在同一個部分之內,增加以下2條線:
AddType application/xhttpdphp .php
AddType application/x httpd php來源.phps
- 任意地,拷貝/usr/local/etc/php.ini-recommended或/usr/local/etc/php.ini-dist對/usr/local/etc/php.ini (在同樣目錄),將使您調整和改變PHP行為缺省設置。
- 開始亞帕基印第安人HTTP網絡服務器通過使用apachectl開始(或重新開始亞帕基印第安人HTTP網絡服務器通過使用apachectl再開始)。 apachectl位於/usr/local/sbin,如果您遇到命令沒被發現的問題,嘗試改變目錄到它的地點。
- PHP5完成的設施。
網絡服務器設定了與FreeBSD與亞帕基印第安人、MySQL和PHP。 The document root of the web server (where you should put your HTML and PHP files is at /usr/local/www/apache22/data/ and you will need a SecureFTP (SFTP) client such as WinSCP to upload your files to web server securely.
IMPORTANT: This is a machine translated page which is provided "as is" without warranty. Machine translation may be difficult to understand. Please refer to original English article whenever possible.
Share and contribute or get technical support and help at My Digital Life Forums.
Related Articles
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 - Part 4
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 - Part 3
- Easily Set Up Web Server with XAMPP
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 1
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 3
- FreeBSD Apache HTTP Accept Filter Error
- Using phpMyAdmin for Effective MySQL Management in Windows XP
- PHP 5 Unable to Open HTTP Request Stream with fopen or fsockopen Functions
- Enable Logging of Slow Queries (Slow Query Log) in MySQL Database
- Enable MySQL InnoDB Storage Engine Support in XAMPP Installation
























May 24th, 2006 10:23
Hi, I am trying to install, php5 with apache2.2 on freebsd 6.1. I have followed the instructions on this page. I can get apache running well, but php will not interpret any pages. I have a file; info.php with in it, but when I load it from a browser it tries to *download* the php file not display it. Furthermore, the httpd.conf does not have a entry to load the php module as a shared object. should it? its as if apache has not idea how to process php’s. Any guideance would be appreciated!
kind regards
May 24th, 2006 10:30
Did you add the followng lines to your httpd.conf?
AddType application/x- httpd-php . php
AddType application/x- httpd-php-source . phps
Normally, ports installation will auto update the httpd.conf with php5 load module. Check if your httpd.conf has the following line, if not try to add:
LoadModule php5_module libexec/apache22/libphp5.so
May 24th, 2006 11:54
Yes, I certainly did add the AddType’s
the php5 port installation did not auto update httpd.conf with ‘LoadModule php5_module libexec/apache22/libphp5.so’. I would manually add it but the libphp5.so does not exist in the mentioned directory. Any idea’s? I installed from the /usr/ports/lang/php5 port. I heard using /usr/ports/www/mod_php5 port may work. Would/should it make any difference?
May 24th, 2006 16:01
Hi Bruce, you may give mod_php5 a try, but I think you will lose some functionalities such as command line CLI. Or else try to make clean in php5 first. Reinstalling from Apache again worth a try too. Note that you should install Apache first, and php5 will detect which version of Apache you’re running.
May 24th, 2006 16:11
Beside, make sure you updated to latest ports tree with portsnap or cvsup.
May 29th, 2006 20:59
You might missed to install the php for apache, only cgi and cli.
CD /usr/ports/php5
make config
then
make install clean
mayby you have to do
make deinstall && make reinstall
June 4th, 2006 10:48
When you add the following lines to httpd.conf file, make sure you removed the extra spaces (there are 2 extra spaces in the original article, following doesnt’t have).
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
June 7th, 2006 05:21
I’m having the same problem as Bruce above. I’m using FreeBSD 6.1, Apache 2.2, and PHP 5.1.4. My ports tree is fresh and synched.
I installed the PHP5 port with Apache module support. The installation completes without complaining, but there is no Apache module built. The file /usr/local/libexec/apache22/libphp5.so does not exist. It doesn’t exist anywhere else in the filesystem either. Something is broken with this port. I see source files in the work directories , like /usr/ports/lang/php5/work/php-5.1.4/sapi/apache that look appropriate to this module… but are not getting compiled. Any insights?
June 9th, 2006 20:41
Ahmet gave a working answer. I was having the same problems, until I noticed the extra space before the file extention, now everything works like a charm!
June 9th, 2006 20:59
Thanks for point out, has since corrected the error.
August 28th, 2006 10:55
Recompile php5 with ‘Apache Module’ included.
‘cd /usr/ports/lang/php5′
‘make deinstall’ ignore warnings
‘make config’ make sure to select apache module
‘make install’
September 26th, 2006 16:37
I’ve Done it successfully. It doesnt work..
How do i access it?
ive typed http://192.168.1.9
November 29th, 2006 10:32
Had run into the same problem as those above with the extra spaces in the AddType declaration but solved it before looking at the comments. Would recommend updating the article as, all in all, this is a great tutorial. Thanks.
Ben
November 29th, 2006 12:35
Thanks Ben, have since corrected the error.
January 6th, 2007 16:50
I’m running into the same issue. My php files are trying to download instead.
I’ve gone over everything three and four times yet nothing.
I’ve checked the additional spaces as well and no luck.
Any assistance is appreciated!!
January 9th, 2007 22:05
I had same issue.
Try make config and unselect CGI and be sure to select APACHE.
Check at end of install that you have a line like:chmod 755 /usr/local/libexec/apache22/libphp5.so
I config without CLI ang CGI.
March 16th, 2007 08:28
Trying to install the package php5 without port sources via
pkg_add -r php5
only this doesnt install the apache module by the looks of it..
nor does it build it..
I dont want the sources on the server because it is to be a production server.. i’m gunna try a reinstall…
March 16th, 2007 08:36
reinstall was unsuccessful
April 18th, 2007 05:40
I uninstalled, reinstalled making double sure to include the Apache model, still no dice. So I uninstalled again and reinstalled without CLI and CGI and it still would startup no errors, but it would list the directories in document source and would treat cgi files as text files. All my configs were in order, so I thought maybe it needed a reboot… and walah. Working like a charm.
I think Unix is for massochists =)
April 18th, 2007 05:42
edit.. I meant ” .. would treat PHP files as text files ..” and not CGI.
Long day =0
September 14th, 2007 17:03
I’ve been trying to install Timetrex and it requires Apache, php and postgresql. Postgresql is not a problem because I install it from source. But as you can see from above, the FreeBSD ports system is so often in a state of flux that you’re not guaranteed anything that will work.
On this issue, the bosses, and I myself got so fed up with the results from FreeBSD that we installed Fedora and then took the vendors installation file, which only works on Linux and got on with the task.
With so many dependencies and librairies to update, the FreeBSD ports system as left me feeling very cautious about using it and it harkens me back to the old M$ “dll - hell” days when Windows 3x and Win9x were such a pain to deal with.
November 30th, 2007 09:57
This series of articles has been very, very helpful. Many thanks for your contribution!
December 11th, 2007 20:53
Should the problem with downloadable sourcecodes exist for anyone else, if it was just a problem occurring from localhost, changing the listening port from the default 80 to *:80 might help. It is highly likely that in the above mentioned cases Apache had not much to do with serving the files on localhost.
Fedora does not have less dependancies, they are just handeld elswehere out of user eyes.
Understanding the package & port system and when and why to update is part of the game.
For those who go for Fedora on servers, you might opt for ubuntu instead. it’s easy and fast as well as free.
May 10th, 2008 01:44
Lol, you should put this somewhere…
Befor testing… REBOOT! XD
30 minutes lost trying to fix apache + php and all that was required was reboot ¬¬