Duceswild

Information Technology/Network +1
Server에 관련한 내용들을 헤집고 다니고, stackoverflow, microsoft 를 비롯해 다른 분들 posting도 헤집고 다녔었다. 

그 중, Server configuration file,  Apache Documentation과 많은 대화를 심도 있게 나누었다. 


사실 그걸 올리고 있다.

그냥 ctrl+f로 원하는 것만 살짝 찾고 나가려고 했는데, 

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.

이것은 main Apache HTTP server의 설정 파일입니다. 서버에 이것의 지시를 전달하는 명령들을 포함하고 있습니다. 

(좋아..)

# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.

그냥 이것들이 무엇을 하는지 이해하지 않고 단순하게 지시만 읽지 마세요. 만약에 확실하지 않으면 온라인 문서를 참조하세요. 경고했습니다.

.
.
.
.
.


그래서 이걸 다 읽었다. 이걸 다 긁어 올리면 너무 기니까, 지금도 기니까.. 개중 몇개만 짚어보면 아래와 같다.

아, 그 전에 먼저.. 

Java나 PHP, JavaScript처럼 여기에도 주석이있는 모양이다. #을 쓰는데,  혹여나 이 파일을 건드릴때, 입력한게 뭔가 꼬였다 싶으면, 해당 문구 앞에 #을 처리하면 간단하게 넘어갔다. 

살펴보면, 


서버의 경로

# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "C:/Bitnami/wampstack-7.1.12-0/apache2"

보통 찾아다니면 server의 경로를 구체적으로 이렇게 지정해줘야 한다는 얘기가 있었다. 그런데.. 보통 server의 경로는 이렇게 구체적으로 지정되어있다. 


Apache가 default값 대신에 특정 IP주소나 port를 읽도록 해주는 것

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

온같 IP 주소를 다 읽는 대신에 특정한 것만 읽도록 하라는 것.. 
위와같이 'Listen 80' 으로 되어있다. 



Server관리자 관련

# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
# ServerAdmin jaehyun2016@naver.com

굳이 꼭 쓰지는 않아도 됀다. 그냥 이메일 주소를 적어놓았는데, 위의 예제와 같이 your-domain.com 에는 정말 순수하게 jaehyun2016@your-domain으로 적을 사람은 그리 없겠지만, 
그냥 썼다가, 그냥 지워보았다 (앞에 #을 넣어서.)



ServerName 관련

# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName localhost:80
localhost:80

실은, 수업중에는 여기에 DNS를 넣으라는 이야기가 없었다. 뭐 다른 말로는 이걸 건드린 적은 없다는 뜻이기도 하다. 
그래도 혼자 읽다가 수정을 몇번 해보았는데, 위의 지시를 보면, 
ServerName은 server에게 이름과 포트를 전달해서 자기를 알아보게 해주고, 종종 자동으로 정의되지만, 시작하는 동안 문제발생을 막기 위해 분명하게 지정해줄 것을 권합니다.
만약 당신의 host가 등록된 DNS 이름이 없으면, IP 주소를 치세요.

그래서 그냥 저대로... 다시 돌려놓았다.  


문서경로

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "C:/Bitnami/wampstack-7.1.12-0/apache2/htdocs"
<Directory "C:/Bitnami/wampstack-7.1.12-0/apache2/htdocs">
 
쉽게 문서경로라고 하지만, 실상 이 안에서 만들어지는 요청들이 동작하게 된다는 거다. WAMP를 받고, HTML이나, PHP등을 만들어서 동작시키려면, 일단
기본적으로 지정된 경로인 "C:/Bitnami/wampstack-7.1.12-0/apache2/htdocs"  htdocs 안에서 만들어야 한다. 혹, 반대로 다른 곳에 있는 파일을 동작시키고 싶다면, 
위의 경로를 변경해줘야 한다. 당장 내 문제가 그게 아니니까, 일단 넘어가준다. 


시작할때 나타내줄 문서. (요청받았을 때 Apache가 보여줄 file)

# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index1.php
</IfModule>

수업중에는 이상하게 나만 다른 페이지로 넘어가나..했는데, 그리고 생활코딩 수업에서는 index.html 파일을 지웠는데, 
이렇게 하는 방법이 있었다. 
위의 DirectoryIndex 에 index.html 을 지우고, index1.php 파일만 남겨놓는것.. 
그럼 port번호까지 입력해서 실행하면, index1.php가 실행이 된다는 뜻이다. 


그다지 도움이 안되었지만.. 그럼에도 도움이 언젠가는 될 error.log 파일, access.log 파일

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog "logs/error.log"

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    CustomLog "logs/access.log" common

실은 Error에 관련한 걸 찾아보다가, 

[Sat Feb 17 04:37:47.772873 2018] [ssl:warn] [pid 15836:tid 524] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Feb 17 04:37:47.929140 2018] [ssl:warn] [pid 15836:tid 524] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Feb 17 04:37:47.944806 2018] [mpm_winnt:notice] [pid 15836:tid 524] AH00354: Child: Starting 64 worker threads.

이런 문구들을 자꾸 보게 되서 화면도 안뜨고, '일시적인 DNS 오류 일 수도 있습니다.', 'SSL에 문제가.. ', '접근 권한이 필요합니다.' 이래놓아서.. 
헤메다가 훑어보게 되었는데, 덕분에, 그래도 조금이나마 살펴볼 시간도 되었고, 가상 host도 살짝 본 것 같고, 나중에 써먹기 좋을 듯 하다. Apache Server page에 누가 한글로도 적어놓았다. (그런데 이해하기가 그렇게 편하지는 않다.)

실은 error.log는 PHP로 문구를 작성하고 뭔가 잘못되었을 때 잘못된 부분을 보여주는 데에는 꽤 유용하다. 
Atom에서 어디가 잘못되었다고 얘기를 해주는건 아니다보니, 화면이 출력이 되지 않을 때, 뭐가 잘못되었는지, 하나하나 복기해보는 것도 좋지만, 그 복기하는 시간을 
Eclipse 처럼은 아니더라도, (이거야 왠만해서는 밑줄 그어주고 하니까..) 줄여줄 수 있다. 

이렇게..

[Sat Feb 17 22:46:38.423292 2018] [php7:crit] [pid 15824:tid 1272] [client 192.168.0.1:64715] PHP Parse error:  syntax error, unexpected '");\r' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ')' in C:\\Bitnami\\wampstack-7.1.12-0\\apache2\\htdocs\\index1.php on line 19