[warn] _default_ VirtualHost overlap on port 80, the first has precedence

리눅스/APACHE|2015. 1. 16. 16:34
반응형

NameVirtualHost 이 활성화 되지 않은 상태에서
VirtualHost *:80 가 여러개 등록되었을경우 나타나는 에러메세지입니다.

httpd.conf 파일에서

NameVirtualHost *:80 부분이 활성화 되었는지 확인해보고 주석처리 되어있다면 주석해제를 합니다.

등록한 VirtualHost 항목과 NameVirtualHost항목을 동일하게 맞추어줍니다.

예1) NameVirtualHost *
        <VirtualHost *>
        <VirtualHost *>

예2) NameVirtualHost *:80
        <VirtualHost *:80>
        <VirtualHost *:80>

반응형

댓글()

apache 2.2.x 설치중 libexpat.so 에러

리눅스/APACHE|2015. 1. 16. 16:33
반응형

에러 메세지
/usr/lib/libexpat.so: could not read symbols: File in wrong format


해결방안
./configure --with-expat=builtin 추가

반응형

댓글()

Warning: Cannot modify header information - headers already sent by

리눅스/APACHE|2015. 1. 16. 16:32
반응형

소스 에러 출력 메세지가 아래와 같을때


Warning: Cannot modify header information - headers already sent by (output started at /home/yourdomain/public_html/test.php:3) 



소스 상단에 아래 코드를 삽입해봅니다.


ob_start();



반응형

댓글()

보안서버 ssl 키, csr 및 crt 파일 생성

리눅스/APACHE|2015. 1. 16. 16:32
반응형

1 . 키 생성
# openssl genrsa -des3 -out /usr/local/apache/conf/yourdomain.key 1024
키 패스워드 입력

 

2. csr 생성
# openssl req -new -key /usr/local/apache/conf/yourdomain.key > /usr/local/apache/conf/yourdomain.csr
방금 전 생성한키 패스워드 입력

Contry Name : KR  
Stat or Province Name : SEOUL (입력예시)  
Locality Name : Kangnamgu (입력예시)

Organization Name : yourcompany (입력예시)  --> 회사명

Organization Unit Name : yourteam (입력예시)  --> 부서명

Common Name : www.yourdomain.com (입력예시)  --> ssl적용할 도메인 정확히 적어야 합니다.

나머지는 그냥 엔터치고 넘어가도 됩니다.

 

3. 생성된 csr파일을 vi로 열어서
-----BEGIN CERTIFICATE REQUEST----- 부터 -----END CERTIFICATE REQUEST-----의 내용을
복사해서 해당 업체에 보내시면 됩니다.


* CRT 파일 만들기

테스트 용으로 아래와 같이 생성이 가능합니다.

# openssl req -x509 -key /usr/local/apache/conf/yourdomain.key -in /usr/local/apache/conf/yourdomain.csr -out /usr/local/apache/conf/yourdomain.crt -days 3650



반응형

댓글()

도메인 리다이렉트(포워딩) 설정

리눅스/APACHE|2015. 1. 16. 16:32
반응형

아파치의 virtual host 형식으로 아래 항목처럼 추가해주면 됩니다.

<VirtualHost *:80>
     ServerName 
www.new-yourdomain.co.kr            # 본 도메인을 입력하면 아래 주소로 포워딩
     ServerAlias new-yourdomain.co.kr                           # 본 도메인을 입력하면 아래 주소로 포워딩
     Redirect / 
http://www.old-yourdomain.com/       # 이곳으로 포워딩, 주소도 자동 변경
</VirtualHost>

반응형

댓글()

아파치 로그 쌓이지 않게하는 방법

리눅스/APACHE|2015. 1. 16. 16:32
반응형
아파치 설정 파일을 열고

# vi /usr/local/apache2/conf/httpd.conf


아래 옵션으로 된 부분을 주석 처리 합니다.

# ErrorLog /logs/error_log   // 또는 주석 없이 /dev/null 처리 가능
# CustomLog logs/access_log common 


반응형

댓글()

아파치 웹서버 기본 출력 캐릭터셋 변경

리눅스/APACHE|2015. 1. 16. 16:31
반응형
아파치 웹서버 기본 출력 언어셋을 utf-8 이 아닌 euckr 방식으로 사용하고 싶을경우, 아래 옵션을 httpd.conf 에 추가해주세요.
AddDefaultCharset  EUC-KR
만약 AddCharset  EUC-KR  .euc-kr 이 없다면 함께 추가해 주세요.

 

반응형

댓글()

아파치 최대 동시 접속자수(max_clients) 수정

리눅스/APACHE|2015. 1. 16. 16:31
반응형

1. 아파치 2.0.xx 버전

기본 동시접속자수는 최대 256명. 이를 더 많은 숫자로 변경하기 위해서는 아래 파일 수정 후 재펌파일이 필요하다.

/apache/../server/mpm/prefork/prefork.c 파일에서
#define DEFAULT_SERVER_LIMIT 256    // 원하는 최대 접속자를 입력한다.

위에서 숫자 부분을 적당하게 늘려주고

/apache/../server/mpm/worker/worker.c 파일에서
#define DEFAULT_SERVER_LIMIT 16    // 아래 계산법 참고

위에서 숫자 부분을 적당하게 늘려준다.

예를 들어 prefork.c 파일에서 1280으로 늘려주었다면, worker.c 파일은 20으로 늘려주는데, 그 이유는 아래와 같다.

worker 방식은 기본적으로 16개의 child process와 그 안에 64개의 thread를 생성가능하므로, 16*64 = 1024가 된다. 따라서 prefork.c 파일에서 1280으로 늘려주게 되면, worker.c는 1280/64 = 20이 되므로 20으로 수정해 줘야 똑같이 1280명의 동시접속자가 가능하게 된다.


-----------------------------------------------------------------------------

[참고]

1. prefork.c 파일과 worker.c 파일을 같이 늘려줘야 합니다.

 

2. worker 의 경우 아래와 같은 방법으로 수정합니다. (prefork 는 MaxClients 만 늘려주면 됩니다.)

 <IfModule worker.c>
StartServers         1024    // 기본값이 2 입니다.
MaxClients         65536    // 이처럼 최대 접속자를 높게 재설정할 경우 아래 계산법을 따릅니다.
ThreadsPerChild     64    // 프로세스당 쓰레드 수입니다. 기본값이 25 이며, 최대 64 까지 가능합니다.
</IfModule>

 

공식 : MaxClients / ThredsPerChild =< StartServers

           MaxClients 를 정하고 ThreadsPerChild 를 나누면 StartServers 값이 나옵니다.


- 내용추가 (글쓴이)

-----------------------------------------------------------------------------

 


2. 아파치 1.3.xx 버전

기본 동시접속자수는 최대 256명인데, 이는 MaxClients에 입력가능한 최대치를 말합니다.
256명 이상의 동시접속을 허용하고자 할 경우에는 아파치를 다시 재 컴파일해야 합니다.
아파치 디렉토리로 이동하여 ../src/include 안의 httpd.h 에서 다음과 같은 부분을 찾아
값을 높여 주시면 됩니다.

 

#define HARD_SERVER_LIMIT 512    // 원하는 최대 접속자를 입력한다.

 

위와같이 설정 한 후 http.h 파일을 재컴파일해야 정상적으로 적용이 됩니다.

만약 클라이언트가 512명 이상의 접속을 넘어서 이루어질 경우에는 다음과 같은 메시지가 
로그파일에 남게 되며, 클라이언 트는 다른 요청의 접속이 끝날 때 까지 대기하거나 
또는 특정시간이 지난 후 접속이 이루어질 수 없다는 메시지를 보여주게 된답니다 .

[error] server reached MaxClients setting, consider raising the MaxClients setting.


만약, 동시접속자 수를 기본 동시접속자 최대 수인 256명 미만으로 조정하고자 한다면,
재컴파일이 필요없이 아래 파일만 수정합니다.

../conf/httpd.conf 
MaxClients 150
 
그리고, 아파치를 리스타트 하면 됩니다. 
# apachectl restart


 

[출처] 내가사는이유 (http://kikook.tistory.com/492)

반응형

댓글()

웹서버 접속자 수 확인

리눅스/APACHE|2015. 1. 16. 16:30
반응형

# netstat -anlp |grep :80 |grep ES |wc -l


* 한 IP에 대하여 많은 세션이 보일 수 있으니 여러번 명령을 내려보아 판단해야 합니다.


* | uniq 로 중복되는 IP 추려 낼 수 있습니다.


반응형

댓글()

보안서버 (mod_ssl) 설치

리눅스/APACHE|2015. 1. 16. 16:29
반응형

apache 1.x 환경에서는 mod_ssl 를 설치해야하며
httpd 2.x 환경에서는 mod_ssl 설치를 생략합니다.
(httpd 2.x 에는 기본적으로 mod_ssl 모듈이 포함되어 있음)
 
 
1. 설치
openssl: http://www.openssl.org/source/
mod_ssl: http://www.modssl.org/source/ 
 
openssl 을 다운로드 받고 압축을 풉니다.
./config
make
make install
 
mod_ssl 을 다운로드 받고 압축을 풉니다.
./configure --with-apache=../apache_1.3.39 --with-ssl=/usr/local/ssl
 
[참고]
여기서 --with-apache=../apache_1.3.39 은 소스 디렉토리를 하며 (설치 디렉토리 아님)
mod_ssl 에 대하여 make, make install 은 할 필요가 없습니다. 
 
 
2-1. apache 1.3.x 설치
 
아파치 소스 디렉토리에서
./configure --prefix=/usr/local/apache --enable-module=so --enable-shared=max ?enable-module=rewrite --enable-shared=rewrite --enable-module=ssl --enable-shared=ssl
make
make install
 
[참고]
64bit 시스템에서 make 시 -fPIC 관련 에러 메세지가 나타날 경우
/usr/local/ssl 디렉토리를 삭제하고 yum install openssh* 로 패키지 설치 후
mod_ssl 의 설치 옵션중 --with-ssl=/usr/local/ssl 대신 --with-ssl 으로 ./configure 를 다시 하면 됩니다.
 
 
2-2. httpd 2.x 설치
 
아파치 소스 디렉토리에서
./configure --prefix=/usr/local/apache2 --enable-modules=so --enable-mods-shared=all --enable-modules=shared --enable-rewrite --with-mpm=worker --enable-ssl
make
make install
 
환경 설정 및 CSR, KEY 파일 생성, CRT파일 적용은 별도 매뉴얼을 참고하시기 바랍니다.
 

반응형

댓글()

Awstats 6.6 로그분석기 설치

리눅스/APACHE|2015. 1. 16. 16:29
반응형

1. 최신버전 다운
http://awstats.sourceforge.net에서 최신버전을 다운로드 받을 수 있다.
Awstats
는 보안이슈가 많으므로 반드시 최신버전을 다운로드 받을 수 있도록 한다.


2. 압축풀기
[root@localhost src]# tar zxvf awstats-6.6.tar.gz


3. 이동
[root@localhost src]# mv awstats-6.6 /usr/local/awstats

 

4. 권한설정
[root@localhost src]# chmod -R 705 /usr/local/awstats


5. awstats 설정파일 생성하기
[root@localhost tools]# cd /usr/local/awstats/tools

[root@localhost tools]# perl awstats_configure.pl

----- AWStats awstats_configure 1.0 (build 1.6) (c) Laurent Destailleur -----
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to 'understand' all possible ways to use AWStats...
Read the AWStats documentation (docs/index.html).
-----> Running OS detected: Linux, BSD or Unix
-----> Check for web server install
Found Web server Apache config file '/usr/local/apache/conf/httpd.conf'
-----> Check and complete web server config file '/usr/local/apache/conf/httpd.conf'
Warning: You Apache config file contains directives to write 'common' log files
This means that some features can't work (os, browsers and keywords detection).
Do you want me to setup Apache to write 'combined' log files [y/N] ? y <-- apache 로그형식을 combined로 했는지를 확인하고 있다아직combined로 안했더라도 나중에 설정하면 되므로 “y”

Add 'Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"'
Add 'Alias /awstatscss "/usr/local/awstats/wwwroot/css/"'
Add 'Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"'
Add 'ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"'
Add '' directive
AWStats directives added to Apache config file.
-----> Update model config file '/usr/local/awstats/wwwroot/cgi- bin/awstats.model.conf'
File awstats.model.conf updated.
-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y <-- 시스템에 awstats 를 처음 설정 하는 것인지 확인하고 있다처음이면 “y를 아니면 “n”

----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
www.domain.com <-- 설정 파일 이름을 정한다.

-----> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
(엔터) <-- 설정 디렉토리를 정한다보통 디폴트(/etc/awstats)로 설정한다.

-----> Create config file '/etc/awstats/awstats.www.domain.com.conf'
Config file /etc/awstats/awstats.www.domain.com.conf created.
-----> Restart Web server with '/sbin/service httpd restart'
-----> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.domain.com
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue...

A SIMPLE config file has been created: /etc/awstats/awstats.www.domain.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.domain.com' with command:
> perl awstats.pl -update -config=www.domain.com
You can also read your statistics for 'www.domain.com' with URL:
> http://localhost/awstats/awstats.pl?config=www.domain.com
Press ENTER to finish...

httpd.conf 끝부분에 다음과 같은 내용이 추가 되었는지를 확인한다만약 추 가되지 않았다면 수동으로 만들어 준다.

[root@localhost tools]# vi /usr/local/apache/conf/httpd.conf

#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#

Options None
AllowOverride None
Order allow,deny
Allow from all

awstats의 설정파일을 적절히 수정해 주어야 한다.
위에서 설정파일을 www.domain.com로 만들어 주었으므로 /etc/awstats/awstats.www.domain.com.conf 파일을 찾아 수정해 주면 된다.

51 Line <-- www.domain.com 로그파일 위치

51 #LogFile="/var/log/httpd/mylog.log"
52 LogFile="/usr/local/apache/logs/domain_access_log" <-- 실제 사용되는 아파치 로그 파일

204 Line <-- awstats의 설치 위치

204 #DirData="/var/lib/awstats"
205 DirData="/usr/local/awstats"


894 Line <-- 
언어선택

894 #Lang="auto"
895 Lang="ko"

로그파일 형식 combined 지정

★ 아직까지 apache access로그 형식을 combined 로 지정하지 않았다면 combined로 지정한다기존의 로그는 삭제한다

1) httpd.conf 파일 내용중
    # CustomLog logs/access_log common
    CustomLog logs/access_log combined
 
2) vitual host 부분중
    # CustomLog /usr/local/apache/logs/domain_access_log common
    CustomLog /usr/local/apache/logs/domain_access_log combined


6. 
로그 분석파일 만들기

[root@localhost tools]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.domain.com

Create/Update database for config "/etc/awstats/awstats.www.domain.com.conf" by AWStats version 6.6 (build 1.876)
From data in log file "/home/domain/public_html/logs/www.domain.com- access_log"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 33732
Found 2 dropped records,
Found 855 corrupted records,
Found 0 old records,
Found 32875 new qualified records.

7. 웹상에서 awstats 확인하기

http://domain.com/awstats/awstats.pl?config=www.domain.com


8. 클론으로 로그 분석 파일 갱신하기

매시간 10분마다 로그 분석 파일을 갱신(시간은 적절히 설정)

# crontab -e
    10 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.domain.com

이와 같은 방법으로 시스템내의 여러 웹사이트를 로그 분석 파일을 여러개 설정할 수 있다.


▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

9. awstats 
디렉토리 아파치 인증 설정하기

awstats는 보안 이슈가 발생할 가능성이 많으므로 아피치 인증을 설정한다.

[root@domain wwwroot]# vi /usr/local/apache/conf/httpd.conf

Options None
AllowOverride All <-- 수정
Order allow,deny
Allow from all

[root@domain wwwroot]# vi .htaccess

AuthName "아이디와 암호를 입력하세요."
AuthType Basic

#AuthUserFile /usr/local/apache/conf/.htpasswd
AuthUsrFile /usr/local/awstats/wwwroot/.htpasswd
AuthGroupFile /dev/null
require valid-user

[root@domain wwwroot]# htpasswd -c .htpasswd admin

New password:
Re-type new password:
Updating password for user admin

웹상에서 apache 인증이 되는지 확인한다.

반응형

댓글()