성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Java - How to use the Foreign Funct...
[정성태] 제가 큰 실수를 했군요. ^^; Delegate를 통한 Bein...
[정성태] Working with Rust Libraries from C#...
[정성태] Detecting blocking calls using asyn...
[정성태] 아쉽게도, 커뮤니티는 아니고 개인 블로그입니다. ^^
[정성태] 질문이 잘 이해가 안 됩니다. 우선, 해당 소스코드에서 ILis...
[양승조
] var대신 dinamic으로 선언해서 해결은 했습니다. 맞는 해...
[양승조
] 또 막혔습니다. ㅠㅠ var list = props[i].Ge...
[양승조
] 아. 감사합니다. 어제는 안됐던것 같은데....정신을 차려야겠네...
[정성태] "props[i].GetValue(props[i])" 코드에서 ...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>아파치 서버 2.4를 위한 mod_aspdotnet 마이그레이션</h1> <p> 지난 글에서 소개한,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > 아파치 서버에서 ASP.NET을 실행하는 mod_aspdotnet 모듈 ; <a target='tab' href='http://www.sysnet.pe.kr/2/0/11290'>http://www.sysnet.pe.kr/2/0/11290</a> </pre> <br /> mod_aspdotnet 모듈이 현재 개발자의 사정인지 2009년 이래로 더 이상 업데이트가 안되고 있습니다. 그래서, 별로 기능 업데이트를 할 수는 없지만 Apache 2.4에서도 돌아갈 수 있게끔 변경한 버전을 다음의 github에 배포했습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > stjeong/mod_aspdotnet ; <a target='tab' href='https://github.com/stjeong/mod_aspdotnet'>https://github.com/stjeong/mod_aspdotnet</a> </pre> <br /> 개인적으로도 사실 시간이 많지 않아 별로 기능 업데이트를 할 생각은 없지만 그래도 누군가 contributor로 참여해 기능을 추가할 수 있는 여지는 남기는 것이 좋을 것 같아 repo를 열었습니다. (관심있으신 분은 참여를! ^^)<br /> <br /> <hr style='width: 50%' /><br /> <br /> 우선, 소스코드는 다음의 마지막 snapshot을 이용했습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > mod-aspdotnet-code-222.zip ; <a target='tab' href='https://sourceforge.net/p/mod-aspdotnet/code/HEAD/tarball'>https://sourceforge.net/p/mod-aspdotnet/code/HEAD/tarball</a> </pre> <br /> Apache 2.4 지원을 위해 xampp를 이용해 설치한 아파치 서버의 include, lib 폴더를 사용했습니다.<br /> <br /> 나머지 작업은 이제 Apache 2.4로 소스코드를 마이그레이션하는 건데요. 다음의 문서에 따라 은근히 변한 것이 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > API Changes in Apache HTTP Server 2.4 since 2.2 ; <a target='tab' href='https://httpd.apache.org/docs/2.4/developer/new_api_2_4.html'>https://httpd.apache.org/docs/2.4/developer/new_api_2_4.html</a> </pre> <br /> 우선, remote_ip와 remote_addr 필드가 변경되었습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > conn_rec->remote_ip and conn_rec->remote_addr ==> conn_rec->client_ip and conn_rec->client_addr </pre> <br /> 또한, ap_log_... 관련 함수에 3번째 인자로 module_index가 추가되었습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > #ifdef DOXYGEN AP_DECLARE(void) ap_log_rerror(const char *file, int line, <span style='color: blue; font-weight: bold'>int module_index</span>, int level, apr_status_t status, const request_rec *r, const char *fmt, ...); #else #ifdef AP_HAVE_C99 /* need additional step to expand APLOG_MARK first */ #define ap_log_rerror(...) ap_log_rerror__(__VA_ARGS__) #define ap_log_rerror__(file, line, mi, level, status, r, ...) \ do { if (APLOG_R_MODULE_IS_LEVEL(r, mi, level)) \ ap_log_rerror_(file, line, mi, level, status, r, __VA_ARGS__); \ } while(0) #else #define ap_log_rerror ap_log_rerror_ #endif AP_DECLARE(void) ap_log_rerror_(const char *file, int line, <span style='color: blue; font-weight: bold'>int module_index</span>, int level, apr_status_t status, const request_rec *r, const char *fmt, ...) __attribute__((format(printf,7,8))); #endif </pre> <br /> 아파치 모듈 인덱스는 소스 코드에 AP_DECLARE_MODULE를 해주면 된다고 해서 포함시켰습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > #ifdef AP_DECLARE_MODULE AP_DECLARE_MODULE(mod_aspdotnet); #endif </pre> <br /> 그 외에 다음과 같은 컴파일 오류가 발생했는데요.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Error C2079 'apr_sockaddr_t::sin6' uses undefined struct 'sockaddr_in6' mod_aspdotnet e:\git_clone\mod_aspdotnet\trunk\apache2_4_include\apr_network_io.h 269 </pre> <br /> mod_aspdotnet.cpp 파일에 ws2tcpip 헤더 파일을 추가하는 것으로 해결했습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > #include <ws2tcpip.h> </pre> <br /> 위의 작업까지만 해주면 일단 Apache 2.4 지원을 위한 마이그레이션은 대충 완료됩니다.<br /> <br /> <hr style='width: 50%' /><br /> <br /> 문제는, Visual Studio 2017에서 빌드하는 경우 C++/CLI 프로젝트의 어셈블리가 .NET 4.0에 의존성을 갖는다는 점입니다. 이 때문에 <a target='tab' href='http://www.sysnet.pe.kr/2/0/11289'>Apache.Web.dll이 .NET 2.0 GAC가 아니라 .NET 4.0 GAC에 등록</a>됩니다.<br /> <br /> 따라서, Apache 2.4에서 .NET 2.0~3.5용의 ASP.NET을 구동하는 경우 crash가 발생하는데 디버깅을 해 보니 다음의 라인에서 발생합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > static apr_status_t asp_net_stop(void *dummy) { <span style='color: blue; font-weight: bold'>global_conf->pHostFactory->Destroy(); // pHostFactory == nullptr</span> if (global_conf->pHostFactory) { global_conf->pHostFactory->Release(); } if (global_conf->pCorRuntime) { global_conf->pCorRuntime->Stop(); global_conf->pCorRuntime->Release(); } // ...[생략]... } </pre> <br /> 이 상태에서 아파치 에러 로그(\xampp\apache\logs)는 다음과 같이 보여줍니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > [Wed Aug 30 17:14:16.117970 2017] [core:notice] [pid 16020:tid 544] mod_aspdotnet: CorBindToRuntimeEx has loaded version v2.0.50727 of the .NET CLR engine. ed Aug 30 17:16:00.679504 2017] [core:error] [pid 1764:tid 584] (-2146304894)Unknown error: mod_aspdotnet: Could not create the .NET interface for the Apache.Web.HostFactory. [Wed Aug 30 17:16:00.679504 2017] [core:crit] [pid 1764:tid 584] (-2146304894)Unknown error: mod_aspdotnet: Failed to start Asp.Net Apache.Web host factory AH00016: Configuration Failed Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Apache.Web, Version=2.4.0.2199, Culture=neutral, PublicKeyToken=9b9b842f49b86351' or one of its dependencies. The system cannot find the file specified. File name: 'Apache.Web, Version=2.4.0.2199, Culture=neutral, PublicKeyToken=9b9b842f49b86351' at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark) at System.Activator.CreateInstance(String assemblyName, String typeName) at System.AppDomain.CreateInstance(String assemblyName, String typeName) </pre> <br /> 위의 오류를 해결하기 위해 CLR 4를 로드하도록 변경했고 하위 호환성으로 .NET 2.0~3.5용의 ASP.NET이 동작하게 되어 있습니다.<br /> <br /> 단지, 현재 .NET 2.0~3.5만 설치된 환경에서 ASP.NET을 Apache 2.4에서 구동하는 방법은 없습니다. 만약 원한다면 Visual Studio 2008 설치 후 소스코드를 빌드하시면 됩니다.<br /> <br /> <hr style='width: 50%' /><br /> <br /> 위의 작업을 모두 마치고 나면 바이너리에 대한 마이그레이션은 전부 끝나지만 아쉽게도 httpd.conf에 대한 변경 사항이 Apache 2.4에서 달라진 것이 있어 기존의 mod_aspdotnet 사용 방법의 문서대로 하면 다음과 같은 오류가 발생합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > [Thu Aug 31 11:22:44.772053 2017] [authz_core:error] [pid 22704:tid 2724] [client ::1:63160] AH01630: client denied by server configuration: C:/temp/xampp/aspdocs/test.aspx </pre> <br /> 웹 브라우저 화면에는 이런 메시지가 뜹니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > 접근이 거부됨! 요청한 객체에 접근할 수 있는 권한이 없습니다. 읽기 보호가 되어 있거나 웹서버가 읽을 수 없도록 되어 있습니다. 만약 이것이 서버 오류라고 생각되면, 웹 관리자에게 연락하시기 바랍니다. Error 403 localhost Apache/2.4.27 (Win32) OpenSSL/1.0.2l PHP/7.1.8 mod_aspdotnet/2.4 </pre> <br /> 문제는 다음의 설정이었는데,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > <Directory "c:/temp/xampp/aspdocs"> Options FollowSymlinks ExecCGI Order allow,deny Allow from all DirectoryIndex index.htm index.aspx index.asp </Directory> </pre> <br /> 아래의 문서에 보면 2.4에서 바뀌었다고 합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Client denied by server configuration ; <a target='tab' href='https://wiki.apache.org/httpd/ClientDeniedByServerConfiguration'>https://wiki.apache.org/httpd/ClientDeniedByServerConfiguration</a> </pre> <br /> 따라서, mod_aspdotnet for Apache 2.4의 경우 다음과 같은 식으로 .conf 파일을 변경해야 합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > LoadModule aspdotnet_module modules/mod_aspdotnet.so AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj licx rem resources resx soap vb vbproj vsdisco webinfo <IfModule mod_aspdotnet.cpp> AspNetMount /aspdocs "c:/temp/xampp/aspdocs" Alias /aspdocs "c:/temp/xampp/aspdocs" <Directory "c:/temp/xampp/aspdocs"> Require all granted </Directory> AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4" <Directory "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles"> Options FollowSymlinks Order allow,deny Allow from all </Directory> </IfModule> </pre> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
7164
(왼쪽의 숫자를 입력해야 합니다.)