freeBSD5.4下安裝配置apache2+php5+mysql5過程(freebsd9.3安裝教程)
2024-02-21
更新時(shí)間:2024-02-21 00:16:28作者:未知
1.下載:mysql-standard-5.0.12-beta-freebsd5.3-i386.tar.gz
2.下載:php-5.0.5.tar.gz
3.下載:httpd-2.0.54.tar.gz
4.所下載的壓縮包上傳到系統(tǒng)的FTP上。
5.安裝MYSQL:
#tar zxvf mysql-standard-5.0.12-beta-freebsd5.3-i386.tar.gz
#mv mysql-standard-5.0.12-beta-freebsd5.3-i386 mysql //把文件改成mysql
#cp -r mysql /usr/local //把mysql目錄拷貝到/usr/local目錄下
#cd /usr/local/mysql
#pw groupadd mysql
#pw useradd mysql -g mysql
#chown -R root .
#chown -R mysql data
#chgrp -R mysql .
#scripts/mysql_install_db --user=mysql
#cd /usr/local/mysql/bin
#./mysqld_safe --user=mysql //啟動(dòng)mysql服務(wù)
如果沒有問題的話,應(yīng)該會(huì)出現(xiàn)類似這樣的提示:
# Starting mysqld daemon with databases from /usr/local/mysql/var
這就證明你安裝成功了,如果出現(xiàn):
[1] 42264
# Starting mysqld daemon with databases from /usr/local/mysql/var
040818 10:53:45 mysqld ended
則證明你的mysql運(yùn)行不來,請查看錯(cuò)誤日志: /usr/local/mysql/data/*.err 然后確定安裝是否成功,如果沒有成功,請檢查上面的步驟是否正確.
6.寫一個(gè)腳本放到 /usr/local/etc/rc.d目錄下,用來運(yùn)行mysql,我們寫一個(gè)腳本mysql.sh
#! /bin/sh
/usr/local/mysql/bin/mysqld_safe&
那么以后reboot系統(tǒng)后都能啟動(dòng)mysql了.
7.安裝APACHE:
#tar zxvf httpd-2.0.54.tar.gz
#cd httpd-2.0.54
#./configure --prefix=/usr/local/apache --enable-shared-max --enable-module=so --with-mpm=worker --enable-rewrite
#make
#make install
8.寫一個(gè)腳本放到 /usr/local/etc/rc.d目錄下,用來運(yùn)行apache,我們寫一個(gè)腳本apache.sh
#! /bin/sh
/usr/local/apache/bin/httpd -k start&
那么以后reboot系統(tǒng)后都能啟動(dòng)apache了.
Apache通過 /usr/local/apache/bin/apachectl stop/start/restart來控制啟動(dòng)或者停止.
然后你可以通過 http://localhost/ 來測試apache是否安裝成功,如果出現(xiàn)apache的頁面則安裝成功.
9.安裝GD:
#cd /usr/ports/graphics/gd
#make install
10.安裝LIBXML2:
#cd /usr/ports/textproc/libxml2
#make install
11.安裝PHP:
#tar zxvf php-5.0.5.tar.gz
#cd php-5.0.5
#./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-mysql=/usr/local/mysql --enable-track-vars --enable-inline-optimization --enable-bcmath --with-zlib --with-png --with-gd --with-jpeg --enable-gd-native-ttf --with-ttf --with-freetype --enable-memory-limit --enable-ftp
#make
#make install
#cp php.ini-dist /usr/local/apache/conf/php.ini
12.整合apache+php的環(huán)境:
首先,設(shè)置apache的php訪問能力。
#ee /usr/local/apache/conf/httpd.conf
加入以下內(nèi)容:
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
AddType application/x-httpd-php .php .php5 .php4 .php3
隨后設(shè)置網(wǎng)站默認(rèn)啟動(dòng)頁允許為index.php。同樣在httpd.conf里編輯,不必退出。找到
DirectoryIndex index.html index.html.var
添加index.php進(jìn)去,為:DirectoryIndex index.php index.html index.html.var
13.修改php.ini文件:
#ee /usr/local/apache/conf/php.ini
display_error=off
globals=on
14.現(xiàn)在apache就能夠運(yùn)行php了,寫個(gè)文件測試一下,在/usr/local/apache/htdocs目錄下,新建一個(gè)phpinfo.php文件,
文件中只有一行代碼:
<?
phpinfo();
?>
保存此文件, 在你的瀏覽器中輸入http://localhost/phpinfo.php,你應(yīng)該看到PHP的系統(tǒng)信息。
至此就完成了APACHE2+PHP5+MYSQL5基本架設(shè)完成,如果需要PHP支持ZEND的話,可以用以下方法加上ZEND的支持。
附加:ZendOptimizer安裝
首先下載zendFOR FREEBSD壓縮包,要執(zhí)行以下命令,否則會(huì)提示錯(cuò)誤的
ln -s /lib/libm.so.3 /lib/libm.so.2
或者用以下方法:
ee /etc/libmap.conf
libm.so.2 libm.so.3
#tar -zxxvf ZendOptimizer-2.5.10-freebsd5.1-i386.tar.gz
#cd ZendOptimizer-2.5.10-freebsd5.1-i386
#sh ./install.sh
=================================
PORTS安裝:
cvsup -h cvsup.freebsd.org /usr/share/example/cvsup/ports-supfile #同步ports
cd /usr/ports/databases/mysql50-server/
make install clean # n長的編譯過程
rehash
cp /usr/local/share/mysql/my-small.cnf /etc/my.cnf #由于我這臺(tái)機(jī)器以pgsql為主所以使用小內(nèi)存模式
mysql_install_db -u mysql ; mysqld_safe -u mysql &
cd /usr/ports/www/apache2/
make install clean
cd ../mod_php5
make install clean
在/usr/local/etc/apache/httpd.conf中加一句:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps #可不加
rehash
apachectl start
echo "<?php phpinfo() ?>" > /usr/loacl/www/data/info.php
如果啟動(dòng)成功并能顯示lynx http://localhost/info.php說明基本的 php+apache2已經(jīng)工作正常!
cd /usr/port/lang/php5-extensions/
make install clean #如果第一次安裝會(huì)出現(xiàn)提示框,否則先make conf設(shè)置
選擇需要的模塊,安裝樓主要求mysql gd libxml等,當(dāng)然也可以選擇必須的,日后再添加。
apachectl restart
如果lynx http://localhost/info.php有改動(dòng),恭喜你!安裝成功??!
后續(xù)工作:
echo ' mysql_enable = "YES" ' >> /etc/rc.conf
echo ' apache2_enable="YES" ' >> /etc/rc.conf
#以便開機(jī)后自動(dòng)啟動(dòng)mysql apache