參考網頁:
1. http://bojack.pixnet.net/blog/post/12983723-%E3%80%90freebsd%E3%80%91%E7%94%A8-ports-%E5%AE%89%E8%A3%9D-apache-%2B-php-%2B-mysql
2. http://blog.yam.com/cola1028/article/6868087
安裝MySQL:以下先示範錯誤的安裝。
# cd /usr/ports/databases/mysql56-server/
# make install clean
............................................
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether -fkeep-inline-functions is supported... yes
configure: creating ./config.status
config.status: creating Makefile
===> Building for binutils-2.23.1
cd . && autogen Makefile.def
autogen: not found
gmake: *** [Makefile.in] Error 127
*** [do-build] Error code 1
Stop in /usr/ports/devel/binutils.
*** [install] Error code 1
Stop in /usr/ports/devel/binutils.
*** [build-depends] Error code 1
Stop in /usr/ports/lang/gcc.
*** [install] Error code 1
Stop in /usr/ports/lang/gcc.
*** [build-depends] Error code 1
Stop in /usr/ports/math/R.
*** [install] Error code 1
Stop in /usr/ports/math/R.
*** [build-depends] Error code 1
Stop in /usr/ports/databases/R-cran-DBI.
*** [_R-cran-DBI.realinstall] Error code 1
Stop in /usr/ports/databases.
# make install clean
===> mysql-server-5.6.11 cannot install: MySQL versions mismatch: mysql55-client is installed and wanted version is mysql56-client.
*** [install] Error code 1
Stop in /usr/ports/databases/mysql56-server.
# make deinstall //因為MySQL5.6與MailScanner、SpamAssassin衝突,所以移除安裝MySQL5.6。
===> Deinstalling for databases/mysql55-client
===> Deinstalling mysql-client-5.5.31
pkg_delete: package 'mysql-client-5.5.31' is required by these other packages
and may not be deinstalled (but I'll delete it anyway):
p5-DBD-mysql-4.023
p5-Mail-SpamAssassin-3.3.2_8
MailScanner-4.84.5_3
安裝MySQL5.5:
root@test:/usr/ports/databases/mysql55-server # make install clean
...........................
===> SECURITY REPORT:
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/usr/local/libexec/mysqld
This port has installed the following startup scripts which may cause
these network services to be started at boot time.
/usr/local/etc/rc.d/mysql-server
If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type 'make deinstall'
to deinstall the port if this is a concern.
For more information, and contact details about the security
status of this software, see the following webpage:
http://www.mysql.com/
===> Cleaning for mysql-client-5.5.31
===> Cleaning for mysql-server-5.5.31
安裝完畢。
不能裝mysql 5.6,會跟MailScanner衝突。
設定MySQL:
root@test:/usr/local/share/mysql # chown -R mysql:mysql /var/db/mysql
root@test:/usr/local/share/mysql # /usr/local/etc/rc.d/mysql-server start
Cannot 'start' mysql. Set mysql_enable to YES in /etc/rc.conf or use 'onestart' instead of 'start'. (因為/etc/rc.conf中的MySQL還沒開起來,所以只能用onestart把MySQL先暫時啟動)
root@test:/usr/local/share/mysql # /usr/local/etc/rc.d/mysql-server onestart
Starting mysql.
root@test:/usr/local/share/mysql # mysqladmin -u root password 'password' (設定MySQL的root密碼)
root@test:/usr/local/share/mysql # 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.31 Source distribution
Copyright (c) 2000, 2013, 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> exit
Bye
root@test:/usr/local/share/mysql # vi /etc/rc.conf
# -- MySQL Settings -- #
mysql_enable="Yes"
mysql_dbdir="/home/mysql"
========這段是抄來的,沒有試過。==========================
其他說明
1.備份資料庫
mysqldump -u [username] -p [databasename] > [backupfile.sql]
2.回存資料檔
mysql -u root -p database < filename.sql
========這段是抄來的,沒有試過。==========================
安裝Apache 22:
# cd /usr/ports/www/apache22
# make install clean
a. 用內訂值安裝就好。
b. 因為有裝MySQL,所以有選mysql選項。
...................................................
===> Correct pkg-plist sequence to create group(s) and user(s)
===> Compressing manual pages for apache22-2.2.24
===> Registering installation for apache22-2.2.24
===> Cleaning for expat-2.0.1_2
===> Cleaning for apr-1.4.6.1.4.1_3
===> Cleaning for pcre-8.32
===> Cleaning for python27-2.7.5
===> Cleaning for automake-1.12.6
===> Cleaning for gdbm-1.9.1
===> Cleaning for db42-4.2.52_5
===> Cleaning for automake-wrapper-20101119
===> Cleaning for apache22-2.2.24
安裝完畢。
安裝php5:
root@test:/usr/ports/lang/php5 # make config install clean
一定記得要勾選此選項喔,不然apache和php互不認得。
APACHE Build Apache module
.....................................
For more information, and contact details about the security
status of this software, see the following webpage:
http://www.php.net/
===> Cleaning for apache22-2.2.24
===> Cleaning for pcre-8.33
===> Cleaning for expat-2.0.1_2
===> Cleaning for apr-1.4.6.1.4.1_3
===> Cleaning for python27-2.7.5
===> Cleaning for automake-1.12.6
===> Cleaning for gdbm-1.9.1
===> Cleaning for db42-4.2.52_5
===> Cleaning for automake-wrapper-20101119
===> Cleaning for php5-5.4.15
安裝完畢。
安裝php5-extensions:
root@test:/usr/ports/lang/php5-extensions # make config install clean
請記得勾選 GD、MBSTRING、MYSQL、MySQLI、ZIP 和 ZLIB。後面就用default就可以了。
......................................
有一段warning很多,不要緊的。
===> Cleaning for libgcrypt-1.5.2
===> Cleaning for libgpg-error-1.11
===> Cleaning for php5-extensions-1.7
安裝完畢。
設定apache和php5:
root@test:/usr/local/etc # cp php.ini-production /usr/local/etc/php.ini
root@test:/usr/local/etc # vi /usr/local/etc/apache22/httpd.conf
#ServerName www.example.com:80
ServerName www.test.com:80 //打開port 80。
# --- Apache Setting --- # //新增下列application。
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
# --- End of Setting --- #
<IfModule dir_module>
DirectoryIndex index.php index.html index.htm
</IfModule>
存檔退出。
新增php測試檔:
root@test:/usr/local/etc # vi /usr/local/www/apache22/data/index.php
<?php phpinfo(); ?>
/usr/local/www/apache22/data/index.php: new file: 2 lines, 21 characters.
設定/etc/rc.conf:
# vi /etc/rc.conf
# -- Apache Settings -- #
apache22_enable="Yes"
apache22_http_accept_enable="YES"
# -- MySQL Settings -- #
mysql_enable="YES"
啟動服務:
root@test:/usr/local/etc # /usr/local/etc/rc.d/apache22 start
Cannot 'start' apache22. Set apache22_enable to YES in /etc/rc.conf or use 'onestart' instead of 'start'.
root@test:/usr/local/etc # /usr/local/etc/rc.d/apache22 onestart
Performing sanity check on apache22 configuration:
httpd: Could not reliably determine the server's fully qualified domain name, using www.test.com for ServerName
Syntax OK
Starting apache22.
httpd: Could not reliably determine the server's fully qualified domain name, using www.test.com for ServerName
修改過httpd.conf中,新增ServerName之後,就不會再出現httpd warning訊息了。
root@test:/usr/local/etc/apache22 # /usr/local/etc/rc.d/apache22 start
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.
停止服務:
# /usr/local/etc/rc.d/apache22 stop
Stopping apache22.
Waiting for PIDS: 40022.
測試apache和php:
http://ip/index.php
因為會露出機器的資料,測試成功後請記得將這個檔案移除或更名。
整個程序大功告成。
正式的網頁內容請放到/usr/local/www/apache22/data下就可以了。
留言列表