Solaris 10 OS 快速安裝 Apache + Mysql + php

  1. 前言
  2. 設定、測試與啟動 Apache2
  3. 設定、測試與啟動 MySQL
  4. 下載與設定 PHP

前言:

本文的閱讀對象是為已經有 Apache、MySQL 和 php 基本的操作經驗的人員編寫。主要講求正確和快速安裝。 致於,Apache、MySQL 和 php詳細設定、修改方面和軟件測試,在這裡不會詳談。

設定、測試與啟動 Apache2

Solaris 10 已經內置安裝了 Apache 2.xx,只需要做一些設定便可以使用。

1. 首先用 Root 了登入文字模式系統 ( Console Mode )

2. 複制 /etc/apache2/httpd.conf-example 到 /etc/apache2/httpd.conf

cp /etc/apache2/httpd.conf-example /etc/apache2/httpd.conf

3. 編輯 /etc/apache2/httpd.conf

  • 設定你所需要的 ServerName 伺服器名稱,預設為 127.0.0.1
  • 在 ServerAdmin 設定正確的 E-mail 地址

4. 使用以下指令啟動 Apache

svcadm enable apache2

然後,試一試從新啟動 Solaris ,看一看 Apache 能不自動啟動。基本網頁文件位置為 /var/apache2/htdocs 。

設定、測試與啟動 MySQL

Solaris 10 已經內置安裝了 MySQL。安裝者必須要用 Root 身份登入系統。以下的安裝步驟可以在 /usr/sfw/src/mysql/Docs 目錄中找到。

  1. 用 root 身份 login 到 Console mode 中,並且進行資料庫的事前準備。

    # /usr/sfw/bin/mysql_install_db
    Preparing db table
    Preparing host table
    Preparing user table
    Preparing func table
    Preparing tables_priv table
    Preparing columns_priv table
    Installing all prepared tables
    060118 21:24:03 /usr/sfw/sbin/mysqld: Shutdown Complete
    <snip…>
     

  2. 建立 mysql user 和 group ,並且更改資料目錄的群組。

    groupadd mysql
    useradd -g mysql mysql
    chgrp -R mysql /var/mysql
    chmod -R 770 /var/mysql
    # installf SUNWmysqlr /var/mysql d 770 root mysql
     

  3. 預設 MySQL 設定檔位置為 /var/mysql/my.cnf
  4. 複制 MySQL 設定檔到預設位置

    cp /usr/sfw/share/mysql/my-medium.cnf /var/mysql/my.cnf
     

  5. 手動啟動 mysql

    # /usr/sfw/sbin/mysqld_safe –user=mysql &
     

  6. 設定 MySQL 的 root user密碼 ( 下文中的 new-password 為你想要的密碼,你可以自行更改為你喜歡的密碼。因為安全理由,切密不要使用 new-password 為你的密碼,一定要更改 ) 

    cd /usr/sfw/bin
    ./mysqladmin -u root password 'new-password'
    ./mysqladmin -u root -h `hostname` password 'new-password'
     

  7. 測試 MySQL Server

    # ./mysqlshow -p
    Enter password: new-password

    +———–+
    | Databases |
    +———–+
    | mysql     |
    | test      |
    +———–+

    # ./mysql -u root -p
    Enter password: new-password

    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 3 to server version: 4.0.20-standard
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

    mysql> show databases;
    +———–+
    | Databases |
    +———–+
    | mysql     |
    | test      |
    +———–+
    2 rows in set (0.00 sec)

    mysql> quit;
    Bye
     

  8. 設定 Solaris Server 在啟動和關機時,自動運行和停止MySQL Server。

    # ln /etc/sfw/mysql/mysql.server /etc/rc3.d/S99mysql
    ln /etc/sfw/mysql/mysql.server /etc/rc0.d/K00mysql
    # ln /etc/sfw/mysql/mysql.server /etc/rc1.d/K00mysql
    ln /etc/sfw/mysql/mysql.server /etc/rc2.d/K00mysql
    ln /etc/sfw/mysql/mysql.server /etc/rcS.d/K00mysql
     

  9. 然後,試一試從新啟動 Solaris ,看一看 MySQL 能不自動啟動。預設 MySQL 設定檔位置為 /var/mysql/my.cnf 。 

下載與設定 PHP

    1. 用 root 身份 login 到 Console mode 中。
    2. 檢查清楚 PATH 是否包含 /opt/csw/bin 和 /usr/sfw/bin,如果沒有,請自行加上。

      # bash 
      export PS1='\u:\w#'
      root:/# echo $PATH
      /opt/csw/bin:/usr/sfw/bin:/usr/sbin:/usr/bin:/usr/openwin/bin:/usr/dt/bin:/usr/ccs/bin
       

    3. 安裝 pkgutil

      root:/# mkdir /usr/local/src
      root:/# cd /usr/local/src
      root:/usr/local/src# wget http://blastwave.network.com/csw/pkgutil_i386.pkg
      root:/usr/local/src# cp pkgutil_i386.pkg ..
      root:/usr/local/src# pkgadd -d pkgutil_i386.pkg all 

      You may use and copy this software without charge, as you see fit.
      The software is copyright (C) Philip Brown, Nov 2002

      Dont forget to update /opt/csw/etc/pkgutil.conf with your nearest archive site.
      The selected base directory </opt/csw> must exist before installation
      is attempted.

      Do you want this directory created now [y,n,?,q] y
      Using </opt/csw> as the package base directory.
      ## Processing package information.
      ## Processing system information.
      2 package pathnames are already properly installed.
      ## Verifying disk space requirements.
      ## Checking for conflicts with packages already installed.
      ## Checking for setuid/setgid programs.

      This package contains scripts which will be executed with super-user
      permission during the process of installing this package.

      Do you want to continue with the installation of <CSWpkgget> [y,n,?] y

      Installing pkg_get – CSW version of automated package download tool as <CSWpkgget>

      ## Installing part 1 of 1.
      /opt/csw/bin/pkgutil
      /opt/csw/etc/pkgutil.conf.csw
      /opt/csw/share/man/man1m/pkgutil.1m
      /var/pkgutil/admin-fullauto
      [ verifying class ]
      ## Executing postinstall script.

      Installing /opt/csw/etc/pkgutil.conf.csw to pkgutil.conf
      Installation of <CSWpkgget> was successful.

      root:/usr/local/src# cd / 
      root:/#
       

    4. 檢查是否安裝好 pkgutil 和 wget的位置 

      root:/# which pkgutil
      /opt/csw/bin/pkgutil

      root:/# which wget
      /usr/sfw/bin/wget
       

    5. 安裝完整的 wget 軟件

      root:/# pkgutil -i wget

      注意:將會出現大量文字,不用擔心,只要完成安裝就可以。
       

    6. 移除舊版本的 wget

      root:/# cd /usr/sfw/bin
      root:/usr/sfw/bin# mv wget wget.orig
      root:/usr/sfw/bin# exit
      bash
      # export PS1='\u:\w#'
      root:/# 
       

    7. 檢查wget新的位置是否正確

      root:/# which wget
      /opt/csw/bin/wget
       

    8. 檢查 GNU Autoconf 的版本是否為 2.59 或以上

      root:/# which autoconf && autoconf –version | head -2
      /opt/csw/bin/autoconf
      autoconf (GNU Autoconf) 2.59
      Written by David J. MacKenzie and Akim Demaille.

      如果不是為 2.59 或以上版本或根本沒有這個程式,執行以下指令:

      root:/# pkgutil -i autoconf
       

    9. 檢查 GNU automake 的版本是否為 1.8.3 或以上

      root:/# which automake && automake –version | head -2
      /opt/csw/bin/automake
      automake (GNU automake) 1.8.3
      Written by Tom Tromey <tromey@redhat.com>.

      如果不是為1.8.3 或以上版本或根本沒有這個程式,執行以下指令:

      root:/# pkgutil -i automake
       

    10. 檢查 GNU sed version 的版本是否為 4.1.4 或以上

      root:/# which gsed && gsed –version | head -2
      /opt/csw/bin/gsed
      GNU sed version 4.1.4
      Copyright (C) 2003 Free Software Foundation, Inc.

      如果不是為 4.1.4 或以上版本或根本沒有這個程式,執行以下指令:

      root:/# pkgutil -i gsed
       

    11. 檢查 gcc 的版本是否為 3.4.3 或以上

      root:/# which gcc && gcc –version | head -2
      /usr/sfw/bin/gcc
      gcc (GCC) 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
      Copyright (C) 2004 Free Software Foundation, Inc.

      如果不是為 3.4.3 或以上版本或根本沒有這個程式,執行以下指令:

      root:/# pkgutil -i gcc 
       

    12. 檢查 GNU Make 的版本是否為 3.80 或以上

      root:/# which gmake && gmake –version | head -2
      /usr/sfw/bin/gmake
      GNU Make 3.80
      Copyright (C) 2002 Free Software Foundation, Inc.

      如果不是為 3.80 或以上版本或根本沒有這個程式,執行以下指令:

      root:/# pkgutil -i gmake 
       

    13. 檢查 flex version 的版本是否為 2.5.4 或以上

      root:/# which flex && flex –version | head -2
      /usr/sfw/bin/flex
      flex version 2.5.4

      如果不是為 2.5.4 或以上版本或根本沒有這個程式,執行以下指令:

      root:/# pkgutil -i flex 
       

    14. 檢查 GNU Bison 的版本是否為 1.875 或以上

      root:/# which bison && bison –version | head -2
      /usr/sfw/bin/bison
      bison (GNU Bison) 1.875
      Written by Robert Corbett and Richard Stallman.

      如果不是為 1.875 或以上版本或根本沒有這個程式,執行以下指令:

      root:/# pkgutil -i bison 
       

    15. 檢查 GNU M4 的版本是否為 1.4.3 或以上

      root:/# which gm4 && gm4 –version | head -2
      /opt/csw/bin/gm4
      GNU M4 1.4.3
      Written by Rene' Seindal.

      如果不是為 1.4.3 或以上版本或根本沒有這個程式,執行以下指令:

      root:/# pkgutil -i gm4 
       

    16. 檢查 Perl 的版本是否為 5.8 或以上

      root:/# which perl && perl -v | head -2
      /usr/bin/perl 

      This is perl, v5.8.4 built for i86pc-solaris-64int

      如果不是為 5.8 或以上版本或根本沒有這個程式,執行以下指令:

      root:/# pkgutil -i perl 
       

    17. 檢查 GNU zip 的版本是否為 1.3.3 或以上

      root:/# which gunzip && gunzip -V | head -2
      /usr/bin/gunzip
      gunzip 1.3.3-patch.1
      (2002-03-08) 

      如果不是為 1.3.3 或以上版本或根本沒有這個程式,執行以下指令:

      root:/# pkgutil -i gunzip 
       

    18. 檢查 GNU tar 的版本是否為 1.14 或以上

      root:/# which gtar && gtar –version | head -2
      /usr/sfw/bin/gtar
      tar (GNU tar) 1.14
      Copyright (C) 2004 Free Software Foundation, Inc.

      如果不是為 1.14 或以上版本或根本沒有這個程式,執行以下指令:

      root:/# pkgutil -i gtar 
       

    19. 安裝 libxml2 版本 2.6.23

      在安裝 libxml2 之前有一點要特別注意,這程式不可以安裝在需要 mount 的 Driver 上。
      因為,在啟動 Solaris 時,當執行自動啟動 Apache/php 時需要直接使用 libxml2,但這個時候,mount Driver 是還未啟動的。
      很多時候,都有習慣把 /usr/local 放在 mount driver 上。如果你也有這個習慣,請特別注意,不要把 libxml2 安裝在 /usr/local 上。 
      否則,當 Solaris 從啟後, Apache/php 便不能自動啟動,只能人手啟動了。 
      在正常情況下,安裝 libxml2,安裝程式的預設安裝路徑為 /usr/local, 這個安裝路徑是可以更改的。
      以下例子,將會把 libxml2 安裝在 /usr/slocal 上。 

      root:/# cd /usr/local/src
      root:/usr/local/src# wget ftp://xmlsoft.org/libxml2/libxml2-2.6.23.tar.gz

      root:/usr/local/src# mkdir /usr/slocal
      root:/usr/local/src# cp libxml2-2.6.23.tar.gz /usr/slocal/
      root:/usr/local/src# cd /usr/slocal 
      root:/usr/slocal# gunzip -cd libxml2-2.6.23.tar.gz | gtar xvpf –

      root:/usr/slocal# cd libxml2-2.6.23
      root:/usr/slocal/libxml2-2.6.23# ./configure –prefix=/usr/slocal

      root:/usr/slocal/libxml2-2.6.23# gmake 

      root:/usr/slocal/libxml2-2.6.23# gmake install 
       

    20. 如果系統中沒有這個檔案 /etc/apache2/httpd.conf 

      root:/# cp /etc/apache2/httpd.conf-example /etc/apache2/httpd.conf
       

      編輯 /etc/apache2/httpd.conf

      • 設定你所需要的 ServerName 伺服器名稱,預設為 127.0.0.1
      • 在 ServerAdmin 設定正確的 E-mail 地址

       

    21. 下載最新版本的 PHP ( http://www.php.net/downloads.php )

      root:/# cd /usr/local/src
      root:/usr/local/src# wget http://hk.php.net/get/php-5.1.2.tar.gz/from/this/mirror

      root:/usr/local/src# cp php-5.1.2.tar.gz .. 
      root:/usr/local/src# cd .. 
      root:/usr/local# gunzip -cd php-5.1.2.tar.gz | gtar xvpf –

      root:/usr/local# cd php-5.1.2
      root:/usr/local/php-5.1.2# ./configure –with-apxs2=/usr/apache2/bin/apxs \
      –with-mysql=/usr/sfw/ –enable-dbase –with-libxml-dir=/usr/slocal \
      –with-config-file-path=/etc/apache2 –with-gd-dir=/opt/sfw/bin \
      –with-jpeg-dir=/usr/lib –with-png-dir=/usr/lib –with-zlib –enable-mbstring 


      root:/usr/local/php-5.1.2# gmake

      root:/usr/local/php-5.1.2# gmake install 

        
           Installing PHP SAPI module:       apache2handler
           /var/apache2/build/instdso.sh SH_LIBTOOL='/var/apache2/build/libtool' libphp5.la /usr/apache2/libexec
           /var/apache2/build/libtool --mode=install cp libphp5.la /usr/apache2/libexec/
           cp .libs/libphp5.so /usr/apache2/libexec/libphp5.so
           chmod +x /usr/apache2/libexec/libphp5.so
           cp .libs/libphp5.lai /usr/apache2/libexec/libphp5.la
           libtool: install: warning: remember to run `libtool --finish /build/php-5.1.2/libs'
           chmod 755 /usr/apache2/libexec/libphp5.so
           [activating module `php5' in /etc/apache2/httpd.conf]
           Installing PHP CLI binary:        /usr/local/bin/
           Installing PHP CLI man page:      /usr/local/man/man1/
           Installing build environment:     /usr/local/lib/php/build/
           Installing header files:          /usr/local/include/php/
           Installing helper programs:       /usr/local/bin/
             program: phpize
             program: php-config
           Installing man pages:             /usr/local/man/man1/
             page: phpize.1
             page: php-config.1
           Installing PEAR environment:      /usr/local/lib/php/
           [PEAR] Archive_Tar    - installed: 1.3.1
           [PEAR] Console_Getopt - installed: 1.2
           pear/PEAR can optionally use package "pear/XML_RPC" (version >= 1.4.0)
           [PEAR] PEAR           - installed: 1.4.6
           Wrote PEAR system config file at: /usr/local/etc/pear.conf
           You may want to add: /usr/local/lib/php to your php.ini include_path
           Installing PDO headers:          /usr/local/include/php/ext/pdo/
          

      root:/usr/local/php-5.1.2# cp php.ini-dist /etc/apache2/php.ini 
      root:/usr/local/php-5.1.2#
       

    22. 進入 apache2 設定文件目錄

      root:/usr/local/php-5.1.2# cd /etc/apache2
      root:/etc/apache2# 
       

    23. 如果要設定其它 php 的選項,請編輯 /etc/apache2/php.ini
    24. 編輯 httpd.conf 文件

      安裝完 php 後,php 會在 /etc/apache2/httpd.conf 內加入以下句子,請檢查清楚,這句子是否存在:

      LoadModule php5_module libexec/libphp5.so 

      請在 /etc/apache2/httpd.conf 的最後一行手動加入以下句子: 

      AddType application/x-httpd-php .php
       

    25. 啟動 Apache2 和 測試

      svcadm enable apache2
      svcs | grep -i apache2
      online 18:07:10 svc:/network/http:apache2
       

    26. 然後,試一試從新啟動 Solaris ,看一看 Apache2 能不自動啟動。如果不能自動啟動,而只能手動啟動,請看清楚第19項的說明。
      預設 Apache2 設定檔位置為 /etc/apach2/httpd.conf 。

Read more

How to document Home Lab and Network

運維機房和跨域的網路,會遇到各式需求與問題,用對工具才能分析問題,個人覺得最重要的是使用能處理問題的工具。 推薦目前想學和正在使用的平台與軟體,協助將公司/家用機房文件化 佈告欄任務管理 Focalboard 白板可管理任務指派 網路架構文件編寫 netbox 精細管理網路設備與連接線路 IP 資源管理 phpipam 專注網路IP分配 邏輯塊文件編寫 draw.io 視覺化概念圖 機房設備管理 ITDB 管理設備生命週期與使用者

By Phillips Hsieh

如何在Raspberry Pi4上安裝Proxmox for ARM64

第一步 準備好Raspberry Pi 4 / CM4 4GB RAM,這裡要留意CM4如果是買有內建eMMC storage會限制不能使用SD卡開機而限制本地空間容量,如果沒有NAS外接空間或使用USB開機的話,建議買CM4 Lite插上大容量SD卡 第二步 去Armbian官網下載最小化Debian bookworm image https://www.armbian.com/rpi4b/ Armbian 25.2.2 Bookworm Minimal / IOT 然後寫入SD/USB開機碟,寫入方法參考官方文件 https://github.com/raspberrypi/usbboot/blob/master/Readme.md Note: 官方提供的預先設定系統方法,可以在Armbian初次啟動自動化完成系統設定。連結在此 https://docs.armbian.com/User-Guide_Autoconfig/

By Phillips Hsieh

世界越快心越慢

在晚飯後的休息時間,我特別享受在客廳瀏灠youtube上各樣各式創作者的影音作品。很大不同於傳統媒體,節目多是針對大多數族群喜好挑選的,在youtube上我會依心情看無腦的動畫、一些旅拍記錄、新聞時事談論。 尤其在看了大量的Youtube的分享後,我真的感受到會限制我的是我的無知,特別是那些我想都沒想過的實際應用,在學習後大大幫助到我的生活和工作層面。 休息在家時,我喜歡想一些沒做過的菜,動手去設計生活和工作上的解決方案,自己是真的很難閒著沒事做。 如創作文章,陪養新的習慣都能感覺到成長的喜悅,是不同於吃喝玩樂的快樂的。 創作不去限制固定的形式,文字是創作、影像聲音也是創作,記錄生活也是創作,我想留下的就是創造—》實現—》回憶,這樣子的循環過程,在留下的足跡面看到自己一路上的成長、失敗、絕望、重新再來。 雖然大部份的時候去做這些創作也不明白有什麼特別的意義,但不去做也不會留下什麼,所以呀不如反事都去試試看,也許能有不一樣的水花也許有意想不到的結果,投資自己永遠不會是失敗的決定,不是嗎?先問問自己再開始計畫下一步,未來沒人說得準。 像最近看youtube仍大一群人在為DOS開

By Phillips Hsieh

知識管理的三個步驟:一小時學會把知識運用到生活上

摘錄瓦基「閱讀前哨站」文章作為自己學習知識管理的內容 Part1「篩選資訊」 如何從海量資訊中篩選出啟發性、實用性和相關性的精華,讓你在學習過程中不再迷失方向。 1. 實用性 2. 啟發性 Part2「提高理解」 如何通過譬喻法和應用法,將抽象的知識與日常生活和工作緊密結合,建立更深刻的理解。 1. 應用法 2. 譬喻法 Part3「運用知識」 如何連結既有知識,跟自己感興趣的領域和專案產生關聯,讓你在運用知識的路途上游刃有餘。 1. 跟日常工作專案、人際活動產生連結 # 為什麼要寫日記? * 寫日記是為了忘記,忘卻瑣碎事情,保持專注力 * 寫日記就像在翻譯這個世界,訓練自己的解讀能力 * 不只是透過日記來記錄生活,而是透過日記來發展生活 #如何寫日記? * 不要寫流水帳式的日記,而是寫覆盤式的日記 當我們試著記錄活動和感受之間的關聯,有助於辦認出真正快樂的事 日記的記錄方式要以過程為主,而非結果 * 感恩日記的科學建議,每日感恩的案例

By Phillips Hsieh