免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1691 | 回复: 0
打印 上一主题 下一主题

Solaris 10 OS 快速安裝 Apache + Mysql + php [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-11-14 17:29 |只看该作者 |倒序浏览

前言:
本文的閱讀對象是為已經有 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 目錄中找到。
  • 用 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
  • 建立 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
  • 預設 MySQL 設定檔位置為 /var/mysql/my.cnf
  • 複制 MySQL 設定檔到預設位置
    # cp /usr/sfw/share/mysql/my-medium.cnf /var/mysql/my.cnf
  • 手動啟動 mysql
    # /usr/sfw/sbin/mysqld_safe --user=mysql &
  • 設定 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'
  • 測試 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
  • 設定 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
  • 然後,試一試從新啟動 Solaris ,看一看 MySQL 能不自動啟動。預設 MySQL 設定檔位置為 /var/mysql/my.cnf 。
    下載與設定 PHP
  • 用 root 身份 login 到 Console mode 中。
  • 檢查清楚 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
  • 安裝 pkg-get
    root:/# mkdir /usr/local/src
    root:/# cd /usr/local/src
    root:/usr/local/src# wget http://www.blastwave.org/pkg_get.pkg
    root:/usr/local/src# cp pkg_get.pkg ..
    root:/usr/local/src# pkgadd -d pkg_get.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/pkg-get.conf with your nearest archive site.
    The selected base directory  must exist before installation
    is attempted.
    Do you want this directory created now [y,n,?,q] y
    Using  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  [y,n,?] y
    Installing pkg_get - CSW version of automated package download tool as
    ## Installing part 1 of 1.
    /opt/csw/bin/pkg-get
    /opt/csw/etc/pkg-get.conf.csw
    /opt/csw/share/man/man1m/pkg-get.1m
    /var/pkg-get/admin-fullauto
    [ verifying class  ]
    ## Executing postinstall script.
    Installing /opt/csw/etc/pkg-get.conf.csw to pkg-get.conf
    Installation of  was successful.
    root:/usr/local/src# cd /
    root:/#
  • 檢查是否安裝好 pkg-get 和 wget的位置
    root:/# which pkg-get
    /opt/csw/bin/pkg-get
    root:/# which wget
    /usr/sfw/bin/wget
  • 安裝完整的 wget 軟件
    root:/# pkg-get -i wget
    注意:將會出現大量文字,不用擔心,只要完成安裝就可以。
  • 移除舊版本的 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:/#
  • 檢查wget新的位置是否正確
    root:/# which wget
    /opt/csw/bin/wget
  • 檢查 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:/# pkg-get -i autoconf
  • 檢查 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 .
    如果不是為1.8.3 或以上版本或根本沒有這個程式,執行以下指令:
    root:/# pkg-get -i automake
  • 檢查 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:/# pkg-get -i gsed

  • 檢查 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:/# pkg-get -i gcc
  • 檢查 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:/# pkg-get -i gmake
  • 檢查 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:/# pkg-get -i flex
  • 檢查 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:/# pkg-get -i bison
  • 檢查 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:/# pkg-get -i gm4
  • 檢查 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:/# pkg-get -i perl
  • 檢查 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:/# pkg-get -i gunzip
  • 檢查 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:/# pkg-get -i gtar
  • 安裝 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
  • 如果系統中沒有這個檔案 /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 地址

  • 下載最新版本的
    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#
  • 進入 apache2 設定文件目錄
    root:/usr/local/php-5.1.2# cd /etc/apache2
    root:/etc/apache2#
  • 如果要設定其它 php 的選項,請編輯 /etc/apache2/php.ini
  • 編輯 httpd.conf 文件
    安裝完 php 後,php 會在 /etc/apache2/httpd.conf 內加入以下句子,請檢查清楚,這句子是否存在:
    LoadModule php5_module libexec/libphp5.so
    請在 /etc/apache2/httpd.conf 的最後一行手動加入以下句子:
    AddType application/x-httpd-php .php
  • 啟動 Apache2 和 測試
    # svcadm enable apache2
    # svcs | grep -i apache2
    online 18:07:10 svc:/network/http:apache2
  • 然後,試一試從新啟動 Solaris ,看一看 Apache2 能不自動啟動。如果不能自動啟動,而只能手動啟動,請看清楚第
    19項
    的說明。
    預設 Apache2 設定檔位置為 /etc/apach2/httpd.conf 。

    本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/85517/showart_1415094.html
  • 您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP