歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Unix知識 >> BSD

FreeBSD下安裝apache2+mysql5+php5


除了perl,其他用的都是源碼包安裝的
環境是在freebsd6.0下
裝完freebsd之後,可能是我編譯perl的時候不對,所以就用ports自帶的perl了
perl在/usr/ports/lang下面
我裝的5.8
cd /usr/ports/lang/perl5.8
make
make test
make install
裝完perl就繼續裝mysql
下載的是mysql-5.0.24.tar.gz
安裝
代碼:
# tar -zxvf mysql-5.0.24.tar.gz
# cd mysql-5.0.24
# ./configure --prefix=/usr/local/mysql
# make
# make install
# make clean
創建mysql用戶
代碼:
# pw group add mysql
# pw user add mysql -g mysql
初始化表
代碼:
# /usr/local/mysql/bin/mysql_install_db --user=mysql
設置目錄訪問權限
代碼:
# cd /usr/local/mysql
# chown -R root . (設定root可以訪問/usr/local/mysql目錄)
# chown -R mysql var (設定mysql用戶能訪問/usr/local/mysql/var目錄,該目錄中存放mysql的數據庫文件)
# chown -R mysql var/. (設定mysql用戶能訪問/usr/local/mysql/var目錄下的所有文件)
# chown -R mysql var/mysql/. (設定mysql用戶能訪問/usr/local/mysql/var/mysql目錄下的所有文件)
# chgrp -R mysql . (設定mysql組能訪問/usr/local/mysql目錄)
運行
代碼:
使用命令 # /usr/local/mysql/bin/mysqld_safe --user=mysql & 測試安裝是否成功
如果顯示
[1]
# Starting mysqld daemon with database from /usr/local/mysql/var
表示安裝成功
開機自動啟動mysql
代碼:
在/usr/local/etc/rc.d目錄中編輯文件 mysql_start.sh ,內容如下
#! /bin/sh
/usr/local/mysql/bin/mysqld_safe &
設置文件權限為可執行
# chmod +x mysql_start.sh
Apache2 的安裝
下載的是httpd-2.0.58.tar.gz
代碼:
# tar -zxvf httpd-2.0.58.tar.gz
# cd httpd-2.0.58
# ./configure --prefix=/usr/local/apache2 --enable-shared=max --enable-module=rewrite --enable-so
# make
# make install
# make clean
開機自動加載apache服務
代碼:
在/usr/local/etc/rc.d目錄中編輯文件 apache_start.sh
#! /bin/sh
/usr/local/apache2/bin/httpd -k start
設置文件權限
# chmod +x apache_start.sh
PHP5 的安裝
因為我要用到GD庫等一堆東西,所以加載的比較多一點
libxml2安裝
源代碼:libxml2-2.6.22.tar.gz
安裝
代碼:
# tar -zxvf libxml2-2.6.22.tar.gz
# cd libxml2-2.6.22
# ./configure
# make
# make install
# make clean
zlib安裝
源代碼:zlib-1.2.3.tar.gz
安裝
代碼:
# tar -zxvf zlib-1.2.3.tar.gz
# cd zlib-1.2.3
# ./configure
# make
# make install
# make clean
libpng安裝
源代碼:libpng-1.2.9.tar.gz
安裝
代碼:
# tar -zxvf libpng-1.2.9.tar.gz
# cd libpng-1.2.9
# cp scripts/makefile.std makefile
編輯 makefile 將 prefix 改為 prefix=/usr/local/libpng2
# make
# mkdir /usr/local/libpng2
# make install
# make clean
jpeg安裝
源代碼:jpegsrc.v6b.tar.gz
安裝
代碼:
# tar -zxvf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6 --enable-shared
# make
# mkdir /usr/local/jpeg6
# mkdir /usr/local/jpeg6/include
# mkdir /usr/local/jpeg6/lib
# mkdir /usr/local/jpeg6/bin
# mkdir /usr/local/jpeg6/man
# mkdir /usr/local/jpeg6/man/man1
# make install-lib
# make install
# make clean
GD安裝
源代碼:gd-2.0.33.tar.gz
安裝
代碼:
# tar -zxvf gd-2.0.33.tar.gz
# cd gd-2.0.33
# ./configure --prefix=/usr/local/gd2 --with-zlib --with-png=/usr/local/libpng2 --with-jpeg=/usr/local/jpeg6
編輯 Makefile 231行 將
CPPFLAGS = -I/usr/local/jpeg6/include
改為
CPPFLAGS = -I/usr/local/jpeg6/include -I/usr/local/libpng2/include
# make
# make install
# make clean
libiconv安裝
源代碼:libiconv-1.9.2.tar.gz
安裝
代碼:
# tar -zxvf libiconv-1.9.2.tar.gz
# cd libiconv-1.9.2
# ./configure --prefix=/usr/local/libiconv
# make
# make install
# make clean
將iconv.h連接到php的安裝源程序中,否則會php make會出錯
# cd /usr/home/ty/php-5.1.4/ext/iconv/
#這裡的php-5.1.4就是下面解壓縮的路徑
# link /usr/local/libiconv/include/iconv.h iconv.h
開始安裝PHP5
源代碼:php-5.1.4.tar.gz
安裝
代碼:
# tar -zxvf php-5.1.4.tar.gz
# cd php-5.1.4
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-xml --with-mysql=/usr/local/mysql --with-zlib --with-jpeg-dir=/usr/local/jpeg6 --with-png-dir=/usr/local/libpng2 --with-iconv=/usr/local/libiconv --with-config-file-path=/usr/local/lib --disable-debug --enable-safe-mode --enable-trans-sid --enable-memory-limit --enable-short-tags --disable-posix --enable-exif --enable-ftp --enable-sockets
# make
# make install
# make clean
# cp /usr/src/php-5.1.4/php.ini-dist /usr/local/lib/php.ini
把php加到apache裡去
代碼:
添加
AddType application/x-httpd-php .php
然後放個test.php文件上去測試看看成功
vi /usr/local/apache2/htdocs/test.php
PHP 代碼:
phpinfo();
?>
Copyright © Linux教程網 All Rights Reserved