WordPress » 2006 » 十月 imag1
 
 
你正在浏览十月, 2006
Windows下打造完美的服务器平台(APACHE+JSP+CGI+PHP+ASP+MYSQL)

需要下载几个软件包:
1. php-5.0.2-Win32
2. apache_2.0.52-win32-x86-no_ssl
3. mysql-5.0.1-alpha-snapshot-win
4.iASP2.1.01
5.jakarta-tomcat-4.1.31
7.j2sdk-1_4_2-windows-i586
8.phpMyAdmin-2.6.0-pl2
9.ActivePerl-5.8.4.810-MSWin32-x86
一、下载软件包:
  1. PHP5 RC3
  PHP 的下载地址为: http://www.php.net/downloads.php,找到如下图位置,下载方框中的两个软件包。其中 PHP 5.0.0RC3 zip package 就是 PHP5 软件包,而 Collection of PECL modules for PHP 5.0.0RC3 则是 PHP5 的 PECL 扩展模块集合包。

2. Apache 2.0.52
  下载 For Windows 的 MSI 安装包,点击以后选择一个镜像进行下载。

3. MySQL 5.0.1
  下载 Without installer 包并保存于本地硬盘 ,如下图所示:

4.jakarta-tomcat-4.1.31
jakarta-tomcat-5.5.3是最新的版本,由于5.5.3版本需要jdk5.0的支持,我下载不到该版本,所以使用的是4.1.31,同样JDK也是使用j2sdk-1_4_2-windows-i586,当然如果你有5.0的版本,安装方法是一样的。

5.iASP2.1.01
一个让APACHE支持ASP的程序.

6.j2sdk-1_4_2-windows-i586
由于JSP页面需要javac来编译运行,因此必须安装JDK(单装JRE不行)。

7.phpMyAdmin-2.6.0-pl2
phpMyAdmin-2.6.0-pl2可以让你在WEB环境下管理MYSQL数据库
8.ActivePerl-5.8.4.810-MSWin32-x86
安装ActivePerl可以让Apache支持CGI和PL的程序
二,安装与配置
1, 安装apache_2.0.52-win32-x86-no_ssl,将其安装在D:\Apache2\文件夹下面,安装过程就不用说了,一路NEXT就可以,安装完了就可以在任务栏的地方看将这样的图标 ,表示已经启动成功。打开网页http://127.0.0.1,出现安装成功的页面。

接下来对 Apache 的配置文件进行配置,使其支持PHP,用记事本打开 D:\Apache2\conf\ (我这里是按照默认安装路径安装,后面的设置按照自己的安装路径做相应的改变) 目录下的 httpd.conf 文件,定位到下面这行:
DirectoryIndex index.html index.html.var
在其后面添加一个 PHP 默认页,通常是 index.php ,如下:
DirectoryIndex index.html index.html.var index.php
为了使 Apache 识别 PHP 的相关扩展名,搜索并定位到下面这个部分:

AllowOverride None
Options None
Order allow,deny
Allow from all

在后面添加如下两行:
AddType application/x-httpd-php .php .phtml .php3 .php4
AddType application/x-httpd-php-source .phps
指定 php 模块,找到并定位到如下这行:
#LoadModule ssl_module modules/mod_ssl.so
在下面添加一行:

LoadModule php5_module D:\PHP\php5apache2.dll
  使它指向 PHP5 目录下的 php5apache2.dll 文件,路径一定要准确。
  为了指定 Apache 识别中文,我们指定 GB2312 为默认编码。应该找到并定位到下面这行

AddDefaultCharset ISO-8859-1
将其修改为:
AddDefaultCharset GB2312
另外,如果要禁止目录浏览,查找并定位到下面这几行:
#……
#一些注释
#……
Options Indexes FollowSymLinks
去掉几行注释下面进跟着的一行的 Indexes 即可,修改后:
#……
#一些注释
#……
Options FollowSymLinks

  OK,保存 httpd.conf 文件后重起 Apache 服务器。

2.安装PHP 5.0.2
将下载来的 PHP5 RC3(php-5.0.0RC3-Win32.zip) 解压缩到 D:\PHP\ 目录下。复制 D:\PHP\ 目录下的 php5ts.dll 文件到 C:\windows\(如果是 windows 2000 操作系统,则为 C:\WINNT\ 目录,下同,不再重复说明) 目录下。
  复制 D:\PHP\ 目录下的下列 dll 文件于 C:\windows\system32\ 目录下:
  fdftk.dll
  fribidi.dll
  gds32.dll
  libeay32.dll
  libintl-1.dll
  libmhash.dll
  libmysql.dll
  libmysqli.dll
  ntwdblib.dll
  ntwdblib.dll
  yaz.dll
  其中 libmysql.dll 为 MySQL 4.1 之前版本的扩展支持,libmysqli.dll 为 MySQL 4.1 之后版本的扩展支持。因为我上面下载的是 MySQL 4.0.20 ,所以其实复制 libmysql.dll 即可。
  复制 C:\PHP5\ 目录下的 php.ini-dist 文件到 C:\windows\ 目录下,并改名为 php.ini ,并用记事本打开编辑:
  定位到下面两行:
; Directory in which the loadable extensions (modules) reside.
extension_dir = “./”
  修改下面一行使它指向 D:\PHP\ext\ 目录,修改后如下:
; Directory in which the loadable extensions (modules) reside.
extension_dir = “D:\PHP\ext\”

测试 PHP 是否配置成功:

  打开记事本,输入如下这行代码:

保存为 phpinfo.php 文件,存放于 Apache2\htdocs\ 目录下,好了,打开浏览器,在地址栏中输入: http://localhost/phpinfo.php 并回车,如果一切顺利的话你将看到下面这个页面,到此 PHP5 的配置大功告成:

3.安装mysql-5.0.1-alpha-snapshot-win
很简单,不多说了。我们假设把它安装在D:\mysql目录下,打开该目录下的bin文件夹,运行winmysqladmin.exe配置mysql

输入管理员的用户名和密码就可以了。
以后每次启动,都可以在服务里面看到MYSQL进程已经打开。

4,安装phpMyAdmin-2.6.0-pl2
phpadmin不需要安装,直接COPY到网页目录下即可,将其命名为phpadmin。打开C:\Windows/php.ini文件, 查找 extension=php_mysql.dll 字串.删除掉前面的 ; 号extension=php_mysql.dll,启动 PHP 对 MYSQL 模块支持.
打开phpmyadmin文件夹下面的config.inc.php3文件,定位到下面的内容:
$cfg[’Servers’][$i][’host’] = ‘localhost’; // MySQL hostname or IP address
$cfg[’Servers’][$i][’auth_type’] = ‘config’; // Authentication method (config, http or cookie based)?
$cfg[’Servers’][$i][’user’] = ‘root’; // MySQL user
$cfg[’Servers’][$i][’password’] = ‘’; // MySQL password (only needed
// with ‘config’ auth_type)
将host,user和password修改成你自己的IP地址,用户和密码,打开网页http://127.0.0.1/phpmyadmin/index.php,如果可以看到下面的页面,恭喜你,安装成功了。

5,安装ActivePerl-5.8.4.810-MSWin32-x86
安装过程很简单,一路NEXT就可以了。我们将其安装在D:\usr下面,注意,ActivePerl-5.8.4.810-MSWin32-x86默认的根目录是Perl文件夹,按照国际上面的惯例,最好是usr作我根目录,以免在以后调试程序时候出现麻烦。
配置Apache让其支持CGI和PL文件。用记事本打开 D:\Apache2\conf\ (我这里是按照默认安装路径安装,后面的设置按照自己的安装路径做相应的改变) 目录下的 httpd.conf 文件,寻找
#ScriptAlias /cgi-bin/ “D:/Apache/cgi-bin/”
把前面的#号去掉 ,把D:/Apache/cgi-bin/新开为你需要支持CGI程序的目录,我设置的是f:/Web/cgi-bin。
寻找

同样,也修改为f:/Web/cgi-bin
寻找
AddHandler cgi-script .cgi
后面加上.pl ,即 AddHandler cgi-script .cgi .pl
OK,自己写个CGI程序测试一下:
#!/usr/bin/perl
print “Content-type: text/html\n\n”;
print “Hello, World.”;
保存为hello.cgi,放置在F:\WEB\CGI-BIN文件夹下面,使用浏览器打开http://127.0.0.1/cgi-bin/hello.cgi,出现如下的页面,安装成功。

6,安装j2sdk-1_4_2-windows-i586
由于安装tomcat前需要安装j2sdk,所以要先安装j2sdk-1_4_2-windows-i586,过程很简单,安装到D:\j2sdk文件夹。
设置环境变量,
JAVA_HOME = D:\j2sdk

在Path最后附加:
Path = ……;%JAVA_HOME%\bin

打开CMD,输入java version,显示下面的内容
java version “1.4.2″
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
输入javac,显示:
C:\Documents and Settings\lin>javac
Usage: javac
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{ lines,vars,source } Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are us
ed
-classpath
Specify where to find user class files
-sourcepath
Specify where to find input source files
-bootclasspath
Override location of bootstrap class files
-extdirs Override location of installed extensions
-d Specify where to place generated class files
-encoding Specify character encoding used by source files
-source Provide source compatibility with specified release
-target Generate class files for specific VM version
-help Print a synopsis of standard options
表示JAVAC也安装成功。
7.安装jakarta-tomcat-4.1.31
jakarta-tomcat不需要安装,下载压缩包以后直接解压到D:\TOMCAT目录下,设置环境变量
TOMCAT_HOME =D:\TOMCAT
打开D:\tomcat\bin目录下的startup.bat启动tomcat,如果出现下图的状态,表示启动成功。如图:

使用MYIE打开 http://127.0.0.1:8080/index.jsp ,可以看到如下的页面,再次恭喜你,tomcat也安装成功。tomcat默认的HTTP端口和用户名可以去D:\tomcat\conf目录下修改server.xml和tomcat-user.xml文件。

整合Apache和Tomcat。用记事本打开 D:\Apache2\conf\ 目录下的 httpd.conf 文件,在最后面增加下面的内容:
LoadModule jk2_module modules/mod_jk2.so

在D:\Apache2\conf目录下新建一个workers2.properties文件,内容如下:
[shm]
info=Scoreboard. Requried for reconfiguration and status with multiprocess servers.
file=anon

# Defines a load balancer named lb. Use even if you only have one machine.
[lb:lb]

# Example socket channel, override port and host.
[channel.socket:localhost:8009]
port=8009
host=127.0.0.1

# define the worker
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
group=lb

# Map the Tomcat examples webapp to the Web server uri space
[uri:/examples/*]
group=lb

[status:]
info=Status worker, displays runtime information

[uri:/jkstatus/*]
info=The Tomcat /jkstatus handler
group=status:

如果懒得写代码,将该文件夹下面的workers2.properties.sample改成workers2.properties即可。
写一个JSP文件,内容如下:

保存放置在D:\tomcat\webapps\examples目录下,打开网页http://127.0.0.1/examples/index.jsp,就可以看到Hello, world.字样,这个效果和使用地址http://127.0.0.1:8080/examples/index.jsp看到的页面是一样的,说明Apache和Tomcat已经整合成功。
5,安装iASP2.1.01
安装过程iASP2.1.01会自动找到JDK的安装路径,所以安装过程很很是简单,我们将其安装在d:/Instant文件夹下面。

主要是后面的配置:
第一步:代理服务(proxy)选择:instant asp native servlet support
第二步:WEB SERVER选择:apache。(可以不管它提示)
第三步:选择apache的配置文件:httpd.conf的位置。我的为:D:\Program Files\Apache Group\Apache2\conf\\httpd.conf
版本选择2.X(根据您的apache版本选择)。
proxy:如果您有固定ip,添入您的固定ip。如果没有,那就添:127.0.0.1。
port: 这是apache与iasp之间的代理接口。使用默认(9098)即可。
server manager port:远程管理端口,选择默认(9095)即可。
第四步:配置完成。

配置完成以后,程序会自动在apache的配置文件httpd.conf最后加入了以下语句:

# iASP Setting
LoadModule iasp_module “d:/Instant/bin/apache/win32/2.0/iasp.dll”

Alias /iasp “d:/Instant”
IaspConfig server “d:/Instant/properties/server.properties”
IaspConfig rules “d:/Instant/properties/rules.properties”

通过更改httpd.conf更改apache的默认首页:

DirectoryIndex index.htm
DirectoryIndex index.php
DirectoryIndex index.asp

更改完毕后,保存,重启apache
执行:开始->程序->Instant ASP 2.1.01->Install iASP as NT Service
这样,iasp就被加到了win2000 server的服务中。

执行:开始->程序->Instant ASP 2.1.01->Start Instant ASP
这样,iasp就被立即打开。apache可以支持asp了!

从新启动Apache,发现如下:

这个主要是因为Iasp还不支持我们用的APACHE版本,问一个朋友要了一个支持apache_2.0.52的iasp.dll,替换d:/Instant/bin/apache/win32/2.0/iasp.dll,从新启动Apache成功,写一个ASP文件保存为index.asp.
Congradulations!
Instant ASP has worked for you!


%>
打开网页http://127.0.0.1/index.asp
出现:

这个iasp.dll不是很好,如果你希望在Apache安装ASP,建议使用Apache低一点的版本,使其有支持的iasp.dll文件.
三,组建自己的网站
1.安装vBulletin 3.0.3,去http://www.newvbb.com/下载NewvBB 团队中文化和功能修改后的NewvBB Core 1.1 Final (vBulletin 简体中文化插件版) 20040921。将得到的压缩包解压至F:\WEB\NEWVBB文件夹。打开http://127.0.0.1/phpmyadmin/index.php,新建一个mysql数据库newvbbcore,如图:

将 includes 目录下的 config.php.new 更名为 config.php,打开该文件夹,修改下面的内容为你自己的个人配置:
$servername = ‘localhost’;//你的IP地址
$dbusername = ‘root’;//mysql数据库用户名
$dbpassword = ‘’;//mysql数据库密码
$dbname = ‘newvbbcore’;//刚刚建立的数据库
打开网页http://127.0.0.1/newvbb/install/install.php,进行安装。接下来就是简单的安装过程,直接点击下一步就可以完成NEWVBB的安装。安装完成以后根据提示删除如下文件:
install/install.php,就可以打开地址http://127.0.0.1/newvbb/index.php观看你的PHP论坛了。

2, 安装leobbs CGI论坛
http://www.leobbs.com/下载最新提供的版本LeoBBSX040926,下载完成后解压,将CGI-BIN文件夹下面的全部文件放置在F:\WEB\CGI-BIN文件夹下面。non-cgi文件夹下面的全部文件放置在F:\WEB\NON-CGI文件夹下面。打开网页:http://127.0.0.1/cgi-bin/install.cgi,就可以看到安装页面,注意下面的安装路径:

点击设定完毕完成LEOBBS的安装,打开网页http://127.0.0.1/cgi-bin/leobbs.cgi可以看见我们的CGI论坛:

3, 安装JSP探针
由于JSP用得不是很,我也很少去关注这方面的代码,所以我们去http://xuyizhi.y365.com 下载怀才不遇 改写的JSP探针-V0.05测试结果,将其放置在D:\tomcat\webapps\examples下面,取名为jspchexk.jsp。打开网页http://127.0.0.1/examples/jspcheck.jsp,得到如下的页面:

至此,我们已经完成了JSP的全部安装工作。

在繁体中文的情况下,撰写blog的界面是乱码,写完的繁体中文内容在其他语言下看也是乱码,有没有办法解决啊?

博客需要支持繁体。请DJ等达人帮忙!

Serendipity

最近请了一个翻译,为考验她的翻译技能,我特意拿了s9y.org首页给她翻译了.下面是翻译效果,请大家给点意见 .

Serendipity-一个采用新型CG网络程序编写语言的博客软件

Serendipity’是一个采用新型CG网络程序编写语言的博客应用软件,它给使用者写网上日记,制作博客或者网页提供便利。default package是为一般的博客使用的,而Serendipity为专业的应用软件使用者提供了灵活的,可展开的,便利的框架。

一般的使用者喜欢采用Serendipity的补丁体系机构轻易地改变博客的外观和内容。用户单击一下就可以安装120多个补丁,这样很快地扩大博客的功能,不必编写代码。

同样地,用户单击一下就可以安装40多个模板,使博客变成用户想要的样子。Serendipity’s的SPARTACUS补丁可以自动检测中心库提供升级服务和新的功能,用户可随时点击。�

高级用户因Serendipity的智能模板的简单操作性和具备证明文件的网络标准对此好评。它使得小修改简易,使用户的创造性得到发挥,完全自主得定制自己的网页。Serendipity的显著支持给了用户尝试的信心。

程序师和其他技术人员觉得Serendipity不仅快截,稳定,而且PHD代码简洁。初学者可以学习Serendipity,高级程序师可以很容易地作复杂的修改。Serendipity采用新型CG网络程序编写语言,它长时间被认为是力量,简洁和速度的结合。SerendipityBSD许可允许全世界的编程师学习它,改进它。

其他博客软件使用者已经该用Serendipity,因为它的用户化和显著的维护系统。用户正利用Serendipity无与伦比的灵活性建立快截简单的CMS网站。

Serendipity的基本特点给每个人提供了方便,无论是博客个人还是专业的网页制作者。

(略)

当然,Serendipity还有其他的特色。

请看看这个网页和这页顶端的附加资源,浏览一下Serendipity世界。你也可以申请属于你自己的Serendipity-博客在Who is using 这个域里。

What to tune in MySQL Server after installation

By Peter Zaitsev, September 29, 2006

My favorite question during Interview for people to work as MySQL DBAs or be involved with MySQL Performance in some way is to ask them what should be tuned in MySQL Server straight after installation, assuming it was installed with default settings.

I’m surprised how many people fail to provide any reasonable answer to this question, and how many servers are where in wild which are running with default settings.

Even though you can tune quite a lot of variables in MySQL Servers only few of them are really important for most common workload. After you get these settings right other changes will most commonly offer only incremental performance improvements.

key_buffer_size - Very important if you use MyISAM tables. Set up to 30-40% of available memory if you use MyISAM tables exclusively. Right size depends on amount of indexes, data size and workload - remember MyISAM uses OS cache to cache the data so you need to leave memory for it as well, and data can be much larger than indexes in many cases. Check however if all of key_buffer is used over time - it is not rare to see key_buffer being set to 4G while combined size of .MYI files is just 1GB. This would be just a waste. If you use few MyISAM tables you’ll want to keep it lower but still at least 16-32Mb so it is large enough to accommodate indexes for temporary tables which are created on disk.

innodb_buffer_pool_size This is very important variable to tune if you’re using Innodb tables. Innodb tables are much more sensitive to buffer size compared to MyISAM. MyISAM may work kind of OK with default key_buffer_size even with large data set but it will crawl with default innodb_buffer_pool_size. Also Innodb buffer pool caches both data and index pages so you do not need to leave space for OS cache so values up to 70-80% of memory often make sense for Innodb only installations. Same rules as for key_buffer apply - if you have small data set and it is not going to grow dramatically do not oversize innodb_buffer_pool_size you might find better use for memory available.

innodb_additional_pool_size This one does not really affect performance too much, at least on OS with decent memory allocators. Still you might want to have it 20MB (sometimes larger) so you can see how much memory Innodb allocates for misc needs.

innodb_log_file_size Very important for write intensive workloads especially for large data sets. Larger sizes offer better performance but increase recovery times so be careful. I normally use values 64M-512M depending on server size.

innodb_log_buffer_size Default for this one is kind of OK for many workloads with medium write load and shorter transactions. If you have update activity spikes however or work with blobs a lot you might want to increase it. Do not set it too high however as it would be waste of memory - it is flushed every 1 sec anyway so you do not need space for more than 1 sec worth of updates. 8MB-16MB are typically enough. Smaller installations should use smaller values.

innodb_flush_logs_at_trx_commit Crying about Innodb being 100 times slower than MyISAM ? You probably forgot to adjust this value. Default value of 1 will mean each update transaction commit (or each statement outside of transaction) will need to flush log to the disk which is rather expensive, especially if you do not have Battery backed up cache. Many applications, especially those moved from MyISAM tables are OK with value 2 which means do not flush log to the disk but only flush it to OS cache. The log is still flushed to the disk each second so you normally would not loose more than 1-2 sec worth of updates. Value 0 is a bit faster but is a bit less secure as you can lose transactions even in case MySQL Server crashes. Value 2 only cause data loss with full OS crash.

table_cache - Opening tables can be expensive. For example MyISAM tables mark MYI header to mark table as currently in use. You do not want this to happen so frequently and it is typically best to size your cache so it is large enough to keep most of your tables open. It uses some OS resources and some memory but for modern hardware it is typically not the problem. 1024 is good value for applications with couple hundreds tables (remember each connection needs its own entry) if you have many connections or many tables increase it larger. I’ve seen values over 100.000 used.

thread_cache Thread creation/destructions can be expensive, which happen at each connect/disconnect. I normally set this value to at least 16. If application has large jumps in amount of concurrent connections and I see fast growth of
Threads_Created variable I boost it higher. The goal is not to have threads created in normal operation.

query_cache If your application is read intensive and you do not have application level caches this can be great help. Do not set it too large as it may slow things down as its maintenance may get expensive. Values from 32M to 512M normally make sense. Check it however after a while and see if it is well used. For certain workloads cache hit ratio is lower than would justify having it enabled.

Note: as you can see all of these are global variables. These variables depend on hardware and mix of storage engines, while per session variables are typically workload specific. If you have simple queries there is no reason to increase sort_buffer_size even if you have 64GB of memory to waste. Furthermore doing so may decrease performance.
I normally leave per session variable tuning to second step after I can analyze workload.

P.S Note MySQL distribution contains bunch of sample my.cnf files which may be great templates to use. Typically they would already be much better than defaults if you chose correct one.

SWiK-Source

WIKI + TAG + OpenSource

SWiK-Source is the source code of the swik.net core engine. It is licensed for distribution under the GNU General Public License v2.

SWiK-Source is meant for people who are curious about the code that powers SWiK, for people who want to try making their own SWiK for their internal use or for some new web site, as well as for use with SourceLabs’ internal and partnering projects.

SourceLabs has released SWiK-Source as a source code release rather than a packaged release: it’s a complicated system built with a lot of assumptions for custom production servers rather than arbitrary or generic systems.

SWiK Source is built on and integrated with the platform combination of PHP, MySQL, and Apache HTTPd. These applications are not packaged as part of the distribution, however SWiK Source requires these and other 3rd party open source components to run properly.
List of components you must either have or obtain and install before setting up SWiK Source:

1. PHP 5.0 (see below for specific configure line)
2. Apache 2.0
3. MySQL 4.1
4. Ruby
5. Java
6. libxml
7. libjpg
8. libpng