主頁 > 知識(shí)庫 > Freebsd7.0+Apache2.2+MySQL5+PHP5安裝配置

Freebsd7.0+Apache2.2+MySQL5+PHP5安裝配置

熱門標(biāo)簽:檢查注冊(cè)表項(xiàng) IT外包 免費(fèi)建站 呼叫中心解決方案 集時(shí)通訊 美團(tuán) 蘋果 呼叫外包

一、安裝apache2.2.8
首先去http://www.apache.org 網(wǎng)站上下載apache2.2.8源碼包
解壓縮
#tar zxvf httpd-2.2.8.tar.gz
得到 httpd-2.2.8文件夾
#cd httpd-2.2.8
配置
#./configure --prefix=/usr/local/apache --enable-so --enable-module=rewrite
編譯
#make
安裝
#make install
安裝完成
測(cè)試一下安裝效果
#cd /usr/local/apache
#cd bin
# ./apachectl start
httpd: apr_sockaddr_info_get() failed for
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Thu Apr 03 09:37:41 2008] [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter
出現(xiàn)上述提示
#vi /usr/local/apache/conf/httpd.conf
修改SeverName一項(xiàng)即可解決(1)錯(cuò)誤提示
產(chǎn)生(2)的原因是:FreeBSD 系統(tǒng)還提供了http filter,會(huì)自動(dòng)過濾掉不完整的HTTP請(qǐng)求。
解決方法:
kldload accf_http
修改/boot/defaults/loader.conf中,以便下次啟動(dòng)自動(dòng)裝載模塊
accf_http_load="YES"
在瀏覽器是輸入http://serverip
出現(xiàn) "It works!" 表明apache安裝成功
二、安裝MySQL
下載MySQL源碼包
# ls
httpd-2.2.8.tar.gz      mysql-5.0.51.tar.gz
解壓縮
#tar zxvf   mysql-5.0.51.tar.gz
# cd mysql-5.0.51
配置
#./configure --prefix=/usr/local/mysql
編譯
#make
編譯時(shí)間可能需要較長時(shí)間,請(qǐng)耐心等待。
安裝
#make install
創(chuàng)建MySQL組
# pw groupadd mysql
創(chuàng)建MySQL用戶
# pw useradd mysql -g mysql -d /usr/local/mysql/ -m mysql
修改MySQL用戶密碼
#passwd mysql
建立用戶后我們就初始化表 (注意:必須先執(zhí)行本步驟后才能進(jìn)行以下步驟)
# ./scripts/mysql_install_db --user=mysql        #初試化表并且規(guī)定用mysql用戶來訪問
初始化表以后就開始給mysql和root用戶設(shè)定訪問權(quán)限, 我們先到安裝mysql的目錄:
# cd /usr/local/mysql
然后設(shè)置權(quán)限
# chown -R root .                #設(shè)定root能訪問/usr/local/mysql
# chown -R mysql var             #設(shè)定mysql用戶能訪問/usr/local/mysql/var ,里面存的是mysql的數(shù)據(jù)庫文件
# chown -R mysql var/.           #設(shè)定mysql用戶能訪問/usr/local/mysql/var下的所有文件
# chown -R mysql var/mysql/.     #設(shè)定mysql用戶能訪問/usr/local/mysql/var/mysql下的所有文件
# chgrp -R mysql .               #設(shè)定mysql組能夠訪問/usr/local/mysql
設(shè)置完成后,基本上就裝好了,好了,我們運(yùn)行一下我們的mysql:
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
出現(xiàn)如下提示:
#  /usr/local/mysql/bin/mysqld_safe --user=mysql &
[2] 7022
# Starting mysqld daemon with databases from /usr/local/mysql/var
# ps -ef
ps: Process environment requires procfs(5)
  PID  TT  STAT      TIME COMMAND
1040  v0  Is+    0:00.00  /usr/libexec/getty Pc ttyv0
  723  v1  Is+    0:00.00  /usr/libexec/getty Pc ttyv1
  724  v2  Is+    0:00.00  /usr/libexec/getty Pc ttyv2
  725  v3  Is+    0:00.00  /usr/libexec/getty Pc ttyv3
  726  v4  Is+    0:00.00  /usr/libexec/getty Pc ttyv4
  727  v5  Is+    0:00.00  /usr/libexec/getty Pc ttyv5
  728  v6  Is+    0:00.00  /usr/libexec/getty Pc ttyv6
  729  v7  Is+    0:00.00  /usr/libexec/getty Pc ttyv7
7022  p0  S      0:00.01  /bin/sh /usr/local/mysql/bin/mysqld_safe --user=mysql
7038  p0  R+     0:00.00  ps -ef
上述信息表明MySQL安裝成功
為了每次系統(tǒng)重啟后都能運(yùn)行mysql,可以寫一個(gè)腳本放到 /etc/rc.d目錄下,用來運(yùn)行mysql,我們寫一個(gè)腳本mysql_start.sh
#! /bin/sh
/usr/local/mysql/bin/mysqld_safe&
然后保存到/etc/rc.d目錄下,那么以后reboot系統(tǒng)后都能啟動(dòng)mysql了.
MySQL的安裝是最順利的一個(gè)
三、安裝PHP
去http://www.php.net網(wǎng)站上去下載php-5.2.5的源碼包
解壓縮
#tar zxvf php-5.2.5.tar.gz
#cd php-5.2.5
配置
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql
出現(xiàn)如下錯(cuò)誤提示:
Sorry, I cannot run apxs.  Possible reasons follow:
1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
The output of /usr/local/apache/bin/apxs follows:
./configure: /usr/local/apache/bin/apxs: not found
configure: error: Aborting
表明沒有安裝perl
下載perl進(jìn)行安裝(去http://www.perl.com下載最新版本,我從別的網(wǎng)站下載了個(gè)5.8版本make時(shí)死活過不去)
#tar xzvf perl-5.10.0.tar.gz
#sh Configure -de
#make
#make test
#make install
安裝完perl后還是提示上述錯(cuò)誤,
我就去apche的源程序中又來了一次下面的動(dòng)作
配置
#./configure --prefix=/usr/local/apache --enable-so --enable-module=rewrite
編譯
#make
安裝
#make install
后重新configure php時(shí)出現(xiàn)如下錯(cuò)誤:
configure: error: xml2-config not found. Please check your libxml2 installation.
安裝libxml2
#tar zxvf libxml2-2.6.31.tar.gz
#cd libxm2-2.6.31
#./configure
#make
#make install
安裝libxml2后,重新configure php 出現(xiàn)如個(gè)錯(cuò)誤提示:
configure: error: Please specify the install prefix of iconv with --with-iconv=DIR>
#tar zxvf libiconv-1.10.tar.gz
#cd libiconv-1.10
#./configure
#make
#make install
注意:我開始的時(shí)候安裝的 libiconv-1.11結(jié)果安裝完成后,重起啟動(dòng)時(shí)出現(xiàn)問題(用戶就是登錄不去,不是是系統(tǒng)的bug還是軟件的兼容性不好,后來用單用戶進(jìn)入,刪除了/usr/local/下的libiconv相關(guān)文件才得以登錄系統(tǒng),從出現(xiàn)這個(gè)問題到解決這個(gè)問題花了我半天的時(shí)間,大家一定要記住這個(gè)教訓(xùn))
安裝完libxml2后重新configure php
這樣再configure php時(shí)結(jié)果還提示錯(cuò)誤,具體的信息忘記記下來了,大體的意思是說沒有找到iconv和libiconv請(qǐng)reinstall iconv,這時(shí)候已經(jīng)是晚上10點(diǎn)多了,我怒了,決定試一下ports安裝iconv和libiconv.(這下子我是實(shí)在沒有耐心了)
#whereis iconv
根據(jù)提示到相應(yīng)的目錄下iconvpath指相應(yīng)的目錄(當(dāng)時(shí)系統(tǒng)提示的信息具體是什么我記不清了)
#cd iconvpath
然后開始安裝
#make install clean
執(zhí)行上述命令時(shí)出/usr/ports/distfiles下沒有找到文件,然后出現(xiàn)一個(gè)連接到ftp下載的信息,沒辦法我這個(gè)機(jī)器不能上外面,我只能用另一臺(tái)機(jī)器上那個(gè)ftp上下載軟件然后再放到/usr/ports/distfiles這里,重新make install clean 結(jié)果又提示缺少什么軟件,我就這樣一個(gè)一個(gè)的下載下來放到/usr/ports/distfiles里面
按照上述的方式又安裝了libiconv
本已經(jīng)編譯安裝了perl 后來一想反正是要ports,就再ports一下這個(gè)perl吧
就這樣又ports安裝了perl一次.
這一切準(zhǔn)備完畢
再重新開始的信息configure PHP
這一次沒問題了
過幾分鐘后出現(xiàn)如下提示:
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you d#loadModule php4_module  modules/libphp4.so not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+
Thank you for using PHP.
這次終于沒有錯(cuò)誤了
繼續(xù)一口氣做完吧
編譯php
#make
#make test
#make install
#cp php.ini-dist /usr/local/php/lib/php.ini
上述這幾步就是有些耗時(shí)間,不過再也沒有出現(xiàn)這樣的那樣的錯(cuò)誤,這一點(diǎn)讓我很欣慰.
安裝完成
接下來的事情就簡(jiǎn)單了
四、整合apache和php
為了讓Apache能夠直接解析php,我們還要進(jìn)行一些配置
首先進(jìn)入apache的配置文件目錄:
# cd /usr/local/apache/conf
# vi httpd.conf
在httpd.conf文件中,添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
應(yīng)該將以上兩句添加在其他AddType之后。
確保文件中有以下一句話,沒有就自己添加在所有LoadModule之后。
LoadModule php5_module  modules/libphp5.so
若存在loadModule php4_module  modules/libphp4.so請(qǐng)將此句注釋掉因?yàn)槲覀儼惭b的是php5
在下面中添加index.php
IfModule dir_module>
    DirectoryIndex index.php index.html
/IfModule>
至此,配置結(jié)束!
在/usr/local/apache/htdocs中新建一個(gè)頁面info.php
?php
phpinfo();
?>
在瀏覽器中中輸入http://serverip/info.php
看一下輸出,看看是否是自己想要的結(jié)果
配置完成!

標(biāo)簽:信陽 安康 眉山 邢臺(tái) 營口 韶關(guān) 泰州 宿遷

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Freebsd7.0+Apache2.2+MySQL5+PHP5安裝配置》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266