1. 安裝MySQL 5.5。

root@ns2:/usr/home/user # cd /usr/ports/databases/mysql55-server
root@ns2:/usr/ports/databases/mysql55-server # make install clean

使用default值安裝。

.......................

===>  Cleaning for libffi-3.2.1
===>  Cleaning for py27-pytz-2014.10,1
===>  Cleaning for mysql55-server-5.5.41

設定SQL:

root@ns2:/usr/ports/databases/mysql55-server # chown -R mysql:mysql /var/db/mysql

root@test:/usr/local/share/mysql # vi /etc/rc.conf
# -- MySQL Settings -- #
mysql_enable="Yes"
mysql_dbdir="/home/mysql"

 

啟動MySQL:

root@ns2:/usr/ports/databases/mysql55-server # /usr/local/etc/rc.d/mysql-server start
Starting mysql.

  如果沒有寫rc.conf這一段,會出現下列警告:

  root@ns2:/usr/ports/databases/mysql55-server # /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'.

  root@ns2:/usr/ports/databases/mysql55-server # /usr/local/etc/rc.d/mysql-server onestart
  Starting mysql.

 

設定密碼:

root@ns2:/usr/ports/databases/mysql55-server # mysqladmin -u root password 'password'
root@tea:/usr/ports/databases/mysql55-server # 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.41 Source distribution

Copyright (c) 2000, 2014, 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> \q
Bye

MySQL安裝完成。

 

2. 安裝Apache24:

root@ns2:/usr/ports/databases/mysql55-server # cd /usr/ports/www/apache24
root@tea:/usr/ports/www/apache24 # make install clean
........................
因為我不小心勾了java,變成安裝起來要好幾小時... 好想中斷啊!可以不用裝java喔!

http://httpd.apache.org/
===>  Cleaning for autoconf-2.69
===>  Cleaning for apr-1.5.1.1.5.4
===>  Cleaning for pcre-8.35_2
===>  Cleaning for m4-1.4.17_1,1
===>  Cleaning for help2man-1.43.3_1
===>  Cleaning for gmake-4.1_1
===>  Cleaning for autoconf-wrapper-20131203
===>  Cleaning for gdbm-1.11_2
===>  Cleaning for db5-5.3.28_2
===>  Cleaning for p5-Locale-gettext-1.05_4
===>  Cleaning for gmake-lite-4.1_1
===>  Cleaning for openjdk-7.71.14_1,1
===>  Cleaning for zip-3.0_1
===>  Cleaning for unzip-6.0_2
===>  Cleaning for cups-client-1.7.3_4
===>  Cleaning for libX11-1.6.2_2,1
===>  Cleaning for libXext-1.3.3,1
===>  Cleaning for libXi-1.7.4,1
===>  Cleaning for libXrender-0.9.8_2
===>  Cleaning for libXt-1.1.4_2,1
===>  Cleaning for libXtst-1.2.2_2
===>  Cleaning for alsa-lib-1.0.28
===>  Cleaning for fontconfig-2.11.1,1
===>  Cleaning for freetype2-2.5.5
===>  Cleaning for javavmwrapper-2.5
===>  Cleaning for dejavu-2.34_4
===>  Cleaning for java-zoneinfo-2014.j
===>  Cleaning for mDNSResponder-561.1.1
===>  Cleaning for bigreqsproto-1.1.2
===>  Cleaning for xcmiscproto-1.2.2
===>  Cleaning for xextproto-7.3.0
===>  Cleaning for xtrans-1.3.5
===>  Cleaning for kbproto-1.0.6
===>  Cleaning for inputproto-2.3.1
===>  Cleaning for xf86bigfontproto-1.2.0
===>  Cleaning for xorg-macros-1.19.0
===>  Cleaning for libXau-1.0.8_2
===>  Cleaning for libXdmcp-1.1.1_2
===>  Cleaning for xproto-7.0.26
===>  Cleaning for libxcb-1.11
===>  Cleaning for libXfixes-5.0.1_2
===>  Cleaning for renderproto-0.11.1
===>  Cleaning for libSM-1.2.2_2,1
===>  Cleaning for recordproto-1.14.2
===>  Cleaning for mkfontdir-1.0.7
===>  Cleaning for mkfontscale-1.1.1_1
===>  Cleaning for libcheck-0.9.14
===>  Cleaning for xcb-proto-1.11
===>  Cleaning for libpthread-stubs-0.3_6
===>  Cleaning for python2-2_3
===>  Cleaning for libxslt-1.1.28_6
===>  Cleaning for fixesproto-5.0
===>  Cleaning for libICE-1.0.9,1
===>  Cleaning for libfontenc-1.1.2_2
===>  Cleaning for libgcrypt-1.6.2
===>  Cleaning for libgpg-error-1.17
===>  Cleaning for apache24-2.4.10_2
root@tea:/usr/ports/www/apache24 #

 

如果沒選Java,一下就裝好了:

===> 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/apache24/mod_cgid.so

      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/apache24
/usr/local/etc/rc.d/htcacheclean

      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://httpd.apache.org/
===>  Cleaning for apache24-2.4.10_2
root@tea:/usr/ports/www/apache24 #

如果沒有需要MySQL和PHP,請直接安裝apache後,將httpd.conf修改如下:

ServerAdmin admin@company.com
ServerName www.company.com:80

<IfModule dir_module>
    DirectoryIndex index.htm index.html
</IfModule> 

存檔退出。

root@tea:/usr/local/www/apache24/data # /usr/local/etc/rc.d/apache24 start    <<<啟動apache。
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.

再到Browser輸入http://ip/index.html,會看到很大的:It's Works!!

就表示apache安裝成功了。



3. 安裝PHP5:

root@tea:/usr/ports/www/apache24 # cd /usr/ports/lang/php5
root@tea:/usr/ports/lang/php5 # make config 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/bin/php
/usr/local/bin/php-cgi
/usr/local/sbin/php-fpm

      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/php-fpm

      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.php.net/
===>  Cleaning for php5-5.4.36

 

3.1. 加裝php module:

因為新版不會自己裝php5的Module,所以後面要自己裝:

root@tea:/usr/ports/lang/php5 # cd /usr/ports/www/mod_php5
root@tea:/usr/ports/www/mod_php5 # make install clean

..........................

http://www.php.net/
===>  Cleaning for php5-5.4.36
===>  Cleaning for mod_php5-5.4.36,1

root@tea:/usr/ports/www/mod_php5 # cd /usr/local/libexec/apache24/
root@tea:/usr/local/libexec/apache24 # ls
httpd.exp                       mod_lbmethod_bybusyness.so
libphp5.so                      mod_lbmethod_byrequests.so

↑裝完之後才會有php5的module。

 

3.2 加裝MySQL的連結,如果沒用到也可以不用裝。
root@tea:/usr/ports/lang # cd php5-extensions/
root@tea:/usr/ports/lang/php5-extensions # make config install clean

請記得勾選 GD、MBSTRING、MYSQL、MySQLI、ZIP 和 ZLIB。後面就用default就可以了。

......................................
===>  Cleaning for sqlite3-3.8.7.4
===>  Cleaning for libXaw-1.0.12_2,2
===>  Cleaning for printproto-1.0.5
===>  Cleaning for libXmu-1.1.2_2,1
===>  Cleaning for libXp-1.0.2_2,1
===>  Cleaning for php5-extensions-1.7
root@tea:/usr/ports/lang/php5-extensions #


4. 設定httpd:

root@tea:/usr/ports/lang/php5-extensions # cd /usr/local/etc
root@tea:/usr/local/etc # cp php.ini-production /usr/local/etc/php.ini
root@tea:/usr/local/etc # vi /usr/local/etc/apache24/httpd.conf

修改下面二行:

ServerAdmin admin@company.com
ServerName www.company.com:80

找到AddType的段落中,加入下面二段:

# --- Inserted by Ariel @ 2015-1-14 --- #
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

<IfModule dir_module>
    DirectoryIndex index.php index.htm index.html
</IfModule>

存檔退出。

 

5. 修改rc.conf,不然只能onestart:

設定/etc/rc.conf: root@ns2:/usr/local/etc # vi /etc/rc.conf
# -- Apache Settings -- #
apache24_enable="Yes"
apache24_http_accept_enable="YES"

# -- MySQL Settings -- #
mysql_enable="Yes"
mysql_dbdir="/home/mysql"

 

6. 新增php測試檔:

root@ns2:/usr/local/etc # vi /usr/local/www/apache22/data/index.php

<?php phpinfo(); ?>

/usr/local/www/apache22/data/index.php: new file: 1 lines, 20 characters.

 

7. 啟動/停止apache:

root@tea:/usr/local/www/apache24/data # /usr/local/etc/rc.d/apache24 start
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.

root@tea:/usr/local/www/apache24/data # /usr/local/etc/rc.d/apache24 stop
Stopping apache24.
Waiting for PIDS: 87568.


8. 打開Browser,輸入http://ip/index.php

有看到php的紫藍色格子表示安裝成功。成功後記得將index.php移除,以免機器資訊外洩!

 

Apache24+MySQL55+PHP5全體安裝完成。

 

, , ,

貓熊麗麗 發表在 痞客邦 PIXNET 留言(0) 人氣()