===================================
1. 安裝 MySQL
===================================
# cd /usr/ports/databases/mysql55-server
# make install clean
安裝好之後
複製 MySQL 的系統設定檔到 /etc 下
# cp /usr/local/share/mysql/my-midden.cnf /etc/my.cnf
設定 MySQL 資料庫權限,並且啟動它
# chown -R mysql:mysql /var/db/mysql
# echo “mysql_enable=yes” >> /etc/rc.conf
# /usr/local/etc/rc.d/mysql-server start
設定 MySQL Root 的密碼
# mysqladmin -u root password 新密碼
最後我們可以測試登入一下 MySQL,有出現以下畫面就 OK
# mysql -u root -p
Enter password: (請輸入密碼)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.60-log FreeBSD port: mysql-server-5.1.60
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Mysql 安裝完成
===================================
2. 安裝 Apache
===================================
# cd /usr/ports/www/apache22
# make install clean
===================================
3. 安裝 PHP
===================================
# cd /usr/ports/lang/php5
# make config install clean
記得要勾選此選項喔,不然 Apache 會不認得 PHP
APACHE Build Apache module
再安裝 PHP Extensions
# cd /usr/ports/lang/php5-extensions
# make config install clean
建議加勾選 GD、MYSQL、MySQLI、MBSTRING、ZIP 和 ZLIB
===================================
4. 修改設定檔
===================================
首先設定 PHP 的設定檔,以後就是設定 php.ini 這檔
# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
修改 Apache 的設定
# vi /usr/local/etc/apache22/httpd.conf
在最上面加入
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
找到
DirectoryIndex index.html
把它變成
DirectoryIndex index.php index.html index.htm
設定一開機啟動 Apache & MySQL
# vi /etc/rc.conf
加入這三行
apache22_enable="YES"
apache22_http_accept_enable="YES"
mysql_enable="YES"
在 /usr/local/www/apache22/data 裡新增一個檔案叫 index.php,內容如下
<?php phpinfo(); ?>
重開機,大功告成!
沒有留言:
張貼留言