未分類

FreeBSD 6.1 安裝 Apache+MySQL+PHP

FreeBSD 6.1 安裝 Apache+MySQL+PHP

// 安裝 mysql5

# cd /usr/ports/databases/mysql50-server
# make install clean
或想使用 big 編碼
# make WITH_CHARSET=big5 WITH_XCHARSET=all install clean

// 接下來請修改
# vi /etc/rc.conf
// 並加入下列這一行,以讓開機時啟動 MySQL,若不加入的話,連正常啟動都不行
mysql_enable=”yes”

// 啟動 MySQL Server
# /usr/local/etc/rc.d/mysql-server start
Starting mysql.
或者
# /usr/local/share/mysql/mysql.server start
Starting MySQL SUCCESS!

// 關閉 MySQL Server
# /usr/local/etc/rc.d/mysql-server stop
或者
# /usr/local/share/mysql/mysql.server stop

// 測試 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 密碼

方法一:

# /usr/local/bin/mysqladmin -u root password “123456”
或 # /usr/local/bin/mysqladmin -u root -h freebsd.com password “123456”

# /usr/local/bin/mysql -u root -p // 登入方法

方法二:

方法一直接在shell中輸入密碼,指令會被系統記錄下來,比較不安全,安全的方法

# /usr/local/bin/mysql

mysql>use mysql
mysql>update user set password=password(“新密碼”) where user=”root”;
Query OK, 2 rows affected (0.01 sec)
Rows matched: 2 Changed: 2 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> quit
Bye

// 安裝完成後預設資料庫的data放在 /var/db/mysql,若要備份就是備份這個資料夾

// 安裝 Apache Web Server

# cd /usr/ports/www/apache22
# make install clean

// 編輯 rc.conf,加入 apache22_enable=”YES”
# vi /etc/rc.conf
apache22_enable=”YES”

// 啟動 apache22
# /usr/local/etc/rc.d/apache22 start
// 關閉 apache22
# /usr/local/etc/rc.d/apache22 stop

//安裝 PHP5
# cd /usr/ports/lang/php5
# make install clean
必選 [X] APACHE Build Apache module

// 安裝 PHP5-Extensions
# cd /usr/ports/lang/php5-extensions
// 選擇所需要的延伸套件
# make config
[X] BZ2 bzip2 library support
[X] CTYPE ctype functions
[X] DOM DOM support
[X] GD GD library support
[X] GETTEXT gettext library support
[X] HASH HASH Message Digest Framework
[X] ICONV iconv support
[X] MBSTRING multibyte string support
[X] MCRYPT Encryption support
[X] MYSQL MySQL database support
[X] ODBC unixODBC support
[X] PCRE Perl Compatible Regular Expression support
[X] PDO PHP Data Objects Interface (PDO)
[X] POSIX POSIX-like functions
[X] SESSION session support
[X] SIMPLEXML simplexml support
[X] SQLITE sqlite support
[X] TOKENIZER tokenizer support
[X] XML XML support
[X] XMLREADER XMLReader support
[X] XMLWRITER XMLWriter support
[X] ZLIB ZLIB support

// 開始安裝
# make install clean

// 修改 httpd.conf 設定檔
# vi /usr/local/etc/apache22/httpd.conf
ServerAdmin smallken@test.edu.tw
ServerName test.edu.tw:80
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.htm index.html index.pl index.cgi

// 複製 php.ini-dist 成為 php.ini
# cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini

// 確定一下有設定開機時啟動
# vi /etc/rc.conf
mysql_enable=”YES”
apache22_enable=”YES”

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *