前言:
本文的阅读对象是为已经有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_dbPreparing 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
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 -pEnter password: new-password+-----------+| Databases |+-----------+| mysql || test |+-----------+#./mysql -u root -pEnter 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.pkg-get
root:/#mkdir /usr/local/srcroot:/#cd /usr/local/srcroot:/usr/local/src#wget http://www.blastwave.org/pkg_get.pkgroot:/usr/local/src#cp pkg_get.pkg ..root:/usr/local/src#pkgadd -d pkg_get.pkg allYou 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:/#
4.检查是否安装好pkg-get和wget的位置root:/#which pkg-get/opt/csw/bin/pkg-get
root:/#which wget/usr/sfw/bin/wget
5.安装完整的wget软件root:/# pkg-get -i wget注意:将会出现大量文字,不用担心,只要完成安装就可以。
6.移除旧版本的wget
root:/#cd /usr/sfw/binroot:/usr/sfw/bin#mv wget wget.origroot:/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:/#pkg-get -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 .如果不是为1.8.3或以上版本或根本没有这个程序,执行以下指令:root:/#pkg-get -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:/#pkg-get -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:/#pkg-get -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:/#pkg-get -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:/#pkg-get -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:/#pkg-get -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:/#pkg-get -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:/#pkg-get -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:/#pkg-get -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:/#pkg-get -i gtar
19.libxml2版本2.6.23libxml2之前有一点要特别注意,这程序不可以安装在需要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/srcroot:/usr/local/src#wget ftp://xmlsoft.org/libxml2/libxml2-2.6.23.tar.gz...
root:/usr/local/src#mkdir /usr/slocalroot:/usr/local/src#cp libxml2-2.6.23.tar.gz /usr/slocal/
root:/usr/local/src#cd /usr/slocalroot:/usr/slocal#gunzip -cd libxml2-2.6.23.tar.gz | gtar xvpf -...
root:/usr/slocal#cd libxml2-2.6.23root:/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.下载最新版本的cd /usr/local/srcroot:/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.2root:/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
22.
23.Installing PHP SAPI module: apache2handler
24./var/apache2/build/instdso.sh SH_LIBTOOL='/var/apache2/build/libtool' libphp5.la /usr/apache2/libexec
25./var/apache2/build/libtool --mode=install cp libphp5.la /usr/apache2/libexec/
26.cp .libs/libphp5.so /usr/apache2/libexec/libphp5.so
27.chmod +x /usr/apache2/libexec/libphp5.so
28.cp .libs/libphp5.lai /usr/apache2/libexec/libphp5.la
29.libtool: install: warning: remember to run `libtool --finish /build/php-5.1.2/libs'
30.chmod 755 /usr/apache2/libexec/libphp5.so
31.[activating module `php5' in /etc/apache2/httpd.conf]
32.Installing PHP CLI binary: /usr/local/bin/
33.Installing PHP CLI man page: /usr/local/man/man1/
34.Installing build environment: /usr/local/lib/php/build/
35.Installing header files: /usr/local/include/php/
36.Installing helper programs: /usr/local/bin/
37.program: phpize
38.program: php-config
39.Installing man pages: /usr/local/man/man1/
40.page: phpize.1
41.page: php-config.1
42.Installing PEAR environment: /usr/local/lib/php/
43.[PEAR] Archive_Tar - installed: 1.3.1
44.[PEAR] Console_Getopt - installed: 1.2
45.pear/PEAR can optionally use package "pear/XML_RPC" (version >= 1.4.0)
46.[PEAR] PEAR - installed: 1.4.6
47.Wrote PEAR system config file at: /usr/local/etc/pear.conf
48.You may want to add: /usr/local/lib/php to your php.ini include_path
49.Installing PDO headers: /usr/local/include/php/ext/pdo/
root:/usr/local/php-5.1.2#cp php.ini-dist /etc/apache2/php.iniroot:/usr/local/php-5.1.2#
50.进入apache2设定文件目录root:/usr/local/php-5.1.2#cd /etc/apache2root:/etc/apache2#
51.如果要设定其它php的选项,请编辑/etc/apache2/php.ini
52.编辑httpd.conf文件php后,php会在/etc/apache2/httpd.conf内加入以下句子,请检查清楚,这句子是否存在:LoadModule php5_module libexec/libphp5.so请在/etc/apache2/httpd.conf的最后一行手动加入以下句子:AddType application/x-httpd-php .php
53.启动Apache2和测试#svcadm enable apache2#svcs | grep -i apache2online 18:07:10 svc:/network/http:apache2
54.然后,试一试从新启动Solaris,看一看Apache2能不自动启动。如果不能自动启动,而只能手动启动,请看清楚第的说明。预设Apache2设定文件位置为/etc/apach2/httpd.conf。