跳至主要内容

Mysql+Apache

设定、测试与启动 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 。

设定、测试与启动 MySQLSolaris 10 已经内置安装了 MySQL。安装者必须要用 Root 身份登入系统。以下的安装步骤可以在 /usr/sfw/src/mysql/Docs 目录中找到。

1. 用 root 身份 login 到 Console mode 中,并且进行数据库的事前准备。# /usr/sfw/bin/mysql_install_dbPreparing db tablePreparing host tablePreparing user tablePreparing func tablePreparing tables_priv tablePreparing columns_priv tableInstalling all prepared tables060118 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-passwordWelcome to the MySQL monitor. Commands end with ; or /g.Your MySQL connection id is 3 to server version: 4.0.20-standardType '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 。 下载与设定 PHP1.用 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/bin3.安装 pkg-getroot:/# 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 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 installationis attempted.
Do you want this directory created now [y,n,?,q] yUsing 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-userpermission 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.confInstallation of was successful.
root:/usr/local/src# cd / root:/#
4.检查是否安装好 pkg-get 和 wget的位置 root:/# which pkg-get/opt/csw/bin/pkg-getroot:/# which wget/usr/sfw/bin/wget
5.安装完整的 wget 软件root:/# pkg-get -i wget注意:将会出现大量文字,不用担心,只要完成安装就可以。
6.移除旧版本的 wgetroot:/# 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/autoconfautoconf (GNU Autoconf) 2.59Written 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/automakeautomake (GNU automake) 1.8.3Written by Tom Tromey <tromey@redhat.com>.如果不是为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/gsedGNU sed version 4.1.4Copyright (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/gccgcc (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/gmakeGNU Make 3.80Copyright (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/flexflex 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/bisonbison (GNU Bison) 1.875Written 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/gm4GNU M4 1.4.3Written 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/gunzipgunzip 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/gtartar (GNU tar) 1.14Copyright (C) 2004 Free Software Foundation, Inc.如果不是为 1.14 或以上版本或根本没有这个程序,执行以下指令:root:/# pkg-get -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/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/slocal root:/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. 下载最新版本的 PHP ( http://www.php.net/downloads.php )root:/# 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
Installing PHP SAPI module: ....................

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/apache2root:/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 apache2online 18:07:10 svc:/network/http:apache2
26. 然后,试一试从新启动 Solaris ,看一看 Apache2 能不自动启动。如果不能自动启动,而只能手动启动,请看清楚第19项的说明。预设 Apache2 设定文件位置为 /etc/apach2/httpd.conf 。

-----------------------------------------------
总结,其实很多人不用apache而用tomcat来做这个事情,但是很平常的就是其实apache在静态处理页面上来说其实不错。
而同时我们在使用mysql开始的时候也非常的方便,首先只要建立他自己的固有表,然后在建立mysql用户就可以,然后将conf文件拷到启动目录下,最后就是手工启动一次就好了,在做好link就可以了。
但是有一点很奇怪,当我做第一次启动的时候发现其实他没有真正的完全做好,还是有点问题的,比如最常见的就是在/tmp/mysql.sock这个文件不存在,因为这个文件是在my.conf这个文件下指定目录位置的,而且mysql的启动有很大一部分需要他的帮助,如果它没有被创建的话那么整个sql就等于没有起来。
后来的话,我先把已经起来的mysqld全部都kill掉,先停掉然后在起来。 然后在用命令手工启动一次,突然就可以了。。 不知道为什么。

评论

此博客中的热门博文

Python学习笔记20100117

映射list   Dictionary 是用{}. list 是一那个[]. turple是用() 当你定义过dictionary后,你可以使用d.keys(), d.values(),d.items()将定义后的时候分别显示出来 当然可以将list里的值加减乘除,也可以如一般的定义直接重新复制这个list. 链接与分割字符串的 li=";", join(li) 则显示的就是 分隔符为;的数 如果使用li=li.split(";")则将刚刚;的分隔符删除,而split里也可定义域,如li.split(";",1)   自省 <---这是啥 之前在使用的时候发觉有些书本上的模块不能调用,很多是py脚本定义过的函数。 下载该脚本s,然后上传至指定位置。 >>>import sys >>>sys.path >>>sys.path.append("绝对位置")然后就能调用这些脚本和参数了。 删除 >>>sys.path.pop() 定义一个参数是 def info(test, test1=10.test2=12): info是函数名,test是必备参数,因为没有定义值,test1和test2是可选参数,定义了初始值   以上是外部函数的调用,下面转到内部函数 内部函数有type,str,dir及其他   ---type 返回任意字符的类型,模块也可以。types模块 >>> type(1) <type 'int'> >>> li=[] >>> type(li) <type 'list'> >>> import odbchelper >>> type(odbchelper) <type 'module'> >>> type(sys) <type 'module'> >>> import types ...

Python学习笔记20100128

methodList = [method for method in dir(object) if callable(getattr(object, method))] ###插一句, ifconfig pcn0 unplumb 去禁solaris的网卡plumb起网卡   and, or  已经and-or一起用。 and 两者为真,print第二个数,一个为假一个为真返回假,三者为真返回最后一个真。 or 两个为真,返回第一个, 一个为假一个为真返回真,三者为假返回最后一个假   lambda可快速定义最小值函数   g = lambda x:x*2 g(3) 6 (lambda x:x*2)(3)   doc string print getattr(object,mothod).__doc__   ljust ljust 用空格填充字符串以符合指定的长度。info 函数使用它生成了两列输出并将所有在第二列的 doc string 纵向对齐。 如果小于的话不会从中截断   -----面向对象 首先导入,你可以选择import module or from module import module 如果你要经常访问模块的属性和方法,且不想一遍又一遍地敲入模块名,使用 from module import。 如果你想要有选择地导入某些属性和方法,而不想要其它的,使用 from module import。 如果模块包含的属性和方法与你的某个模块同名,你必须使用 import module 来避免名字冲突   -----类的定义 class Lofs    pass   这个类的名字是 Loaf,它没有从其它类继承。 类名通常是第一个字母大写,如:EachWordLikeThis,但这只是一个习惯,不是一个必要条件。   这个类没有定义任何方法或属性,但是从语法上,需要在定义中有些东西,所以你使用 pass。这是一个 Python 保留字,仅仅表示 “向前走,不要往这看”。它是一条什么都不做的语句,当你删空函数或类时,它是一个很好的占位符。   你可能猜...

Back to Blog again

     My last blog was almost 6 years again.  lots of things happening those years. like marriage, and move to another country, simply relocation, something is very big in my life.      Back to now,  I guess it is a very good time to start with the blog again. no matter daily life or the tech parts.      These blog may or will contains various languages, Chinese, English or Few Japanese. The first thing, I change the profile to Kamata life, Kamata is Japanese words. "鎌田"  as Kanji. why this change happened, due to we will move from Tamagawa "玉川" to Kamata very soon. I hope I can start to write this not daily, but I hope I can do this continuously.