Archive

‘專業技術’ 分類過的Archive

如何調整Windows上的Tomcat服務參數

2009年5月9日 尚無評論

如果要調整安裝在Windows 上Tomcat服務的參數可以在console mode執行以下指令即可進行更改啟動參數

C:\> tomcat6 //US//Tomcat6 –Description=”Apache Tomcat Server – http://tomcat.apache.org/ ” \
C:\> –Startup=auto –Classpath=%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\bin\bootstrap.jar \
C:\> –JvmMx=512

重點在於使用 //US// (Update service parameters)  指令進行更新參數作業,可使用詳細參數如下:

ParameterName Default Description
–Description Service name description (maximum 1024 characters)
–DisplayName ServiceName Service display name
–Install procrun.exe //RS//ServiceName Install image
–Startup manual Service startup mode can be either auto or manual
–DependsOn List of services that this service depend on. Dependent services are separated using either # or ; characters
–Environment List of environment variables that will be provided to the service in the form key=value. They are separated using either # or ; characters
–User User account used for running executable. It is used only for StartMode java or exe and enables running applications as service under account without LogonAsService privilege.
–Password Password for user account set by –User parameter
–JavaHome JAVA_HOME Set a different JAVA_HOME then defined by JAVA_HOME environment variable
–Jvm auto Use either auto or specify the full path to the jvm.dll. You can use the environment variable expansion here.
–JvmOptions -Xrs List of options in the form of -D or -X that will be passed to the JVM. The options are separated using either # or ; characters.
–Classpath Set the Java classpath
–JvmMs Initial memory pool size in MB
–JvmMx Maximum memory pool size in MB
–JvmSs Thread stack size in KB
–StartImage Executable that will be run.
–StartPath Working path for the start image executable.
–StartClass Class that will be used for startup.
–StartParams List of parameters that will be passed to either StartImage or StartClass. Parameters are separated using either # or ; character.
–StartMethod Main Method name if differs then main
–StartMode executable Can one of jvm java or exe
–StopImage Executable that will be run on Stop service signal.
–StopPath Working path for the stop image executable.
–StopClass Class that will be used on Stop service signal.
–StopParams List of parameters that will be passed to either StopImage or StopClass. Parameters are separated using either # or ; character.
–StopMethod Main Method name if differs then main
–StopMode executable Can one of jvm java or exe
–StopTimeout No Timeout Defines the timeout in seconds that procrun waits for service to exit gracefully.
–LogPath working path Defines the path for logging
–LogPrefix jakarta_service Defines the service log filename
–LogLevel INFO Defines the logging level and can be either error, info, warn or debug
–StdOutput Redirected stdout filename
–StdError Redirected stderr filename

請依版本參考相關文件:
http://tomcat.apache.org/tomcat-5.5-doc/windows-service-howto.html
http://tomcat.apache.org/tomcat-6.0-doc/windows-service-howto.html

Categories: 系統設定 Tags: , ,

Appserv 2.5.10 virtualhost setting

2009年4月10日 3 則評論

最近升級了一台主機的web server
採用的是appserv包裝好的 apache套件
先前都是它apache 1.3 的套件,很容易一安裝就可以上工了

而這次改用他最新版本(使用的是v2.5.10), 主要不一樣是採用了apache 2.x的
一樣也是很容易安裝上去,相關的搭配一樣都包裝好了
真是方便呀!!

不過,在使用上發覺有點不太一樣,我的問題是出在apache上

原本virtualhost 是寫在httpd.conf裡
不過在apache 2.x之後,分割了很多檔案

所以要在extra/httpd-vhosts.conf 裡面去去寫virtualhost 的設定描述

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.x
DocumentRoot “C:/Apache2.2/docs/dummy-host2.x”
ServerName dummy-host2.x
ErrorLog “logs/dummy-host2.x-error.log”
CustomLog “logs/dummy-host2.x-access.log” common
</VirtualHost>


而寫完後重啟,什麼 怎麼還是沒有反應呢?????
原來~~~在httpd.conf裡 include httpd-vhosts.conf 這段設定是被註解掉的
所以,我改了沒反應嘛~~真是豬頭( 都分割好了~~幹嘛不全都include 呢真是不便呀)

好,再次調整後~~重啟…怎麼說權限不足呢  =.=|||
沒想到要針對 virtualhost的目錄去開放權限才行..
(記得以也apache 1.3不用呀~~不過有可能先前都是指virtualhost 指向www/之中吧所以已經設定過了)

所以再設定目錄權限

<Directory “C:\www\www1”>
   Options FollowSymLinks
   AllowOverride None
   Order allow,deny
   Allow from all
</Directory>


好,再次重啟~~這下終於都ok 啦!!
雖然遇到小小問題,不過還是很不錯用啦~~

在這裡有發現當設定virtualhost後,原本default document root 會沒有用
就是說用IP連線時不會指到default document root,這我印象中就和apache 1.3不同了吧

如果和我有一樣的需求,想用IP 指到default page的話,那就是再設定一個virtualhost就好!只是這個不要加上 servername就行啦!!

後語: 
沒想到我用了apahce 1.3的version那麼久呀~~不知是食古不化
還是對它有信心~~不過我能確信~~一定是懶啦~^^

以下是在解惑時有參考過的網址啦:
http://blog.egtravel.tw/2008/10/wordpress/appserv-virtualhost-setup/
http://www.walkone.com.tw/blog/index.jsp?user_id=wolfphp&subject_id=4443

Categories: 系統設定 Tags: , ,

VB.NET 播MP3

2009年3月20日 尚無評論

最近要用.Net 做的簡單的小AP,發現元件很多但不知如何播放MP3,原本預設提供的元件只能播放WAV檔,去找了一下資料,顯示於下面,方便自己學習及提供給大家

目前都是要透過winmm.dll 的library來達到,使用方式還算容易啦,就照copy & paste 就可以執行啦!!

Public Class Form1

   ' 宣告 API
   Private Declare Function mciSendStringA Lib “winmm.dll” _
       (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
       ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer

   Private Sub Button1_Click(ByVal s As Object, ByVal e As EventArgs) Handles Button1.Click
       PlayMidiFile(“C:\死了都要愛.mp3”) ' 播放 MP3 音樂
       '或
       'PlayMidiFile(“C:\頑皮豹.mid”) ' 播放 MIDI 音樂
   End Sub

   Private Sub Button2_Click(ByVal s As Object, ByVal e As EventArgs) Handles Button2.Click
       StopMidi() ' 停止播放
   End Sub

   Private Sub Button3_Click(ByVal s As Object, ByVal e As EventArgs) Handles Button3.Click
       PauseMidi() ' 暫停播放
   End Sub

   Private Sub Button4_Click(ByVal s As Object, ByVal e As EventArgs) Handles Button4.Click
       ContinueMidi()  ' 繼續播放
   End Sub

   Private Function PlayMidiFile(ByVal MusicFile As String) As Boolean
       If System.IO.File.Exists(MusicFile) Then
           mciSendStringA(“stop music”, “”, 0, 0)
           mciSendStringA(“close music”, “”, 0, 0)
           mciSendStringA(“open ” & MusicFile & ” alias music”, “”, 0, 0)
           PlayMidiFile = mciSendStringA(“play music”, “”, 0, 0) = 0
       End If
   End Function

   Private Function StopMidi() As Boolean
       StopMidi = mciSendStringA(“stop music”, “”, 0, 0) = 0
       mciSendStringA(“close music”, “”, 0, 0)
   End Function

   Private Function PauseMidi() As Boolean
       Return mciSendStringA(“pause music”, “”, 0, 0) = 0
   End Function

   Private Function ContinueMidi() As Boolean
       Return mciSendStringA(“play music”, “”, 0, 0) = 0
   End Function

End Class

資料來源:http://blog.blueshop.com.tw/hammerchou/archive/2008/10/24/57452.aspx

原本以為上面的範例不能背景重複播放音樂,但是小弟的程式有誤,一切正常

Imports System
Imports System.Runtime.InteropServices
Imports System.Resources
Imports System.IO

Public Class Sound

Private Shared SND_ASYNC As Integer = 1
Private Shared SND_MEMORY As Integer = 4

Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As Byte(), ByVal hModule As Integer, ByVal dwFlags As Integer) As Integer

Public Shared Sub PlayWavResource(ByVal wav As String)

' get the namespace
Dim strNameSpace As String = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString()

' get the resource into a stream
Dim resourceStream As Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(strNameSpace + "." + wav)
If resourceStream Is Nothing Then Exit Sub

' bring stream into a byte array
Dim wavData As Byte()
ReDim wavData(CInt(resourceStream.Length))
resourceStream.Read(wavData, 0, CInt(resourceStream.Length))

' play the resource
PlaySound(wavData, 0, SND_ASYNC Or SND_MEMORY)
End Sub
End Class

http://www.gringod.com/2005/01/21/playing-a-wav-from-a-resource-in-vbnet/
使用MP3的音樂是比播WAV麻煩,包含這些資源檔封裝後是不可以播放的~真是太可惜了(有可能是小弟才疏學淺,如其它大大知道,再和小弟說一下)

仔細想想,十幾年沒碰VB啦~~(幾年前還有用C寫一個小程式呢)

Categories: .NET Tags: , , ,

用 iptables 阻擋 ip

2009年3月18日 尚無評論

最近發現這幾天有一個怪怪的主機好像在試著用字典攻擊的方式
一直重複的try 系統登入,所以還是把他的IP封鎖好了!!
在Linux平台上,要鎖IP可以透過用 iptables 阻擋 ip
假如要阻擋某個 ip 存取 Linux 伺服器,可以用以下指令:

iptables -A INPUT -s ip_address -j DROP

這時 ip_address 便不可以存取伺服器,要禁止連線到 ip_address,可以這樣:

iptables -A OUTPUT -d ip_address -j DROP

Categories: 系統設定 Tags: ,

如何用javascript控制css margin-left 參數

2009年2月12日 尚無評論

最近有case要用javascript控制css margin-left 參數

用了以下的語法控制,是沒有用的

function
setMargin()
{
document.getElementById(“Picture”).style.margin-left =
“200px”;
}


去查了一下,才知-這個符號是要拿掉才行的

function
setMargin()
{
document.getElementById(“Picture”).style.marginLeft =
“200px”;
}


這個命名的小小注意事項,看來沒有常用的人,會一直忘掉要這樣調整的
寫下來怕忘了

資料來源:
http://bytes.com/groups/javascript/527124-how-set-margin-left-ie-w-javascript

Categories: Java Script Tags: ,
分頁: 上一頁 1 2 3 ... 10 11 12 13 14 15 16 ... 26 27 28 下一頁