在 FreeBSD 6 上用 Ports 來安裝 Apache+MySQL+PHP

 

cd /usr/ports/www/apache22
make install


Installing /usr/local/etc/rc.d/apache22.sh startup script.
To run apache www server from startup, add apache22_enable="YES"
in your /etc/rc.conf. Extra options can be found in startup script.
===> Compressing manual pages for apache-2.2.2
===> Running ldconfig
/sbin/ldconfig -m /usr/local/lib
===> Registering installation for apache-2.2.2
===> SECURITY REPORT:
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/usr/local/lib/libapr-1.so.2

This port has installed the following startup scripts which may cause
these network services to be started at boot time.
/usr/local/etc/rc.d/apache22.sh

If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type 'make deinstall'
to deinstall the port if this is a concern.

For more information, and contact details about the security
status of this software, see the following webpage:
http://httpd.apache.org/

上面的訊息,提到要開機時馬上啟動 Apache Web Server 可以在 /etc/rc.conf 檔案中加入下面一行
apache22_enable="YES"

手動啟動 Apache Web Servrer 的方法
/usr/local/etc/rc.d/apache22.sh


Apache Web Server 設定檔在 /usr/local/etc/apache22/httpd.conf
根目錄在 /usr/local/www/data

安裝 MySQL(參考 FreeBSD 6.0架設管理與應用)
cd /usr/ports/databases/mysql41-server
make WITH_CHARSET=big5 WITH_XCHARSET=all install clean

在 /etc/rc.conf 中加入下面一行
mysql_enable="yes"


接著您就可以使用下列指令啟動 MySQL
/usr/local/etc/rc.d/mysql-server.sh start

啟動 MySQL 後,我們就可以使用下列指令進入 MySQL 互動式命令列
/usr/local/bin/mysql mysql

若執行成功,你將看到以下訊息:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A


Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 14 to server version: 4.1.13


Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql>


MySQL 剛安裝完成時,並未設定 root 的密碼,因此我們接著要設定 root 的密碼並即時更新設定:

mysql> UPDATE user SET password=password('你的密碼') where user='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0


mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.02 sec)

安裝 PHP
cd /usr/ports/www/mod_php5
make install clean



***************************************************************

Make sure index.php is part of your DirectoryIndex.

You should add the following to your Apache configuration file:

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


***************************************************************
===> Compressing manual pages for mod_php5-5.1.2_1,1
===> Registering installation for mod_php5-5.1.2_1,1
===> SECURITY REPORT:
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/usr/local/libexec/apache22/libphp5.so

If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type 'make deinstall'
to deinstall the port if this is a concern.

For more information, and contact details about the security
status of this software, see the following webpage:
http://www.php.net/

上面那一段訊息,最主要說明二件事,就是讓 index.php 變成預設網頁和把
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

加入 /usr/local/etc/apache22/httpd.conf 之中

安裝 PHP5-Extension
cd /usr/ports/lang/php5-extensions
make install clean

執行了 make install 後,會出現一個選單,請勾選您要編譯成 php5 的模組










安裝 PHP5 的 MySQL 模組
cd /usr/ports/databases/php5-mysql
make install clean

The following line has been added to your /usr/local/etc/php/extensions.ini
configuration file to automatically load the installed extension:


extension=mysql.so

啟動 Apache2.2 會出現如下信息:
No such file or directory: Failed to enable the 'httpready' Accept Filter
No such file or directory: Failed to enable the 'httpready' Accept Filter

解決方法:
需要啟動 accf_http

手動啟動的方式

kldload accf_http

執行這個命令以後,Apache Web Server 就不會顯示錯誤資訊。但怎樣讓它開機就立即執行呢?
修改/boot/loader.conf
vi /boot/loader.conf
加入下面的一行
accf_http_load="yes"

不過網頁執行還是有問題
Init: Session Cache is not configured [hint: SSLSessionCache]

找了老半天,因為我測試的機器是用 DHCP Server 取得 IP,後來把 FreeBSD Server 改成固定 IP,並在 /usr/local/etc/apache22/httpd.conf 中設定改為固定 IP,就正常了!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值