설치
설치 위치
버전 확인
Apache(CentOS) 명령어
Note:
CentOS7(RHEL7)
부터 기존에 사용하던service
명령이 실행되지 않을 수 있습니다.systemctl
명령어를 사용해주세요.
- systemctl:
/usr/bin/systemctl
- service:
/sbin/service
명령어 종류 | systemctl (CentOS7) | service (CentOS6) |
---|---|---|
아파치 상태 확인 | systemctl status httpd | service httpd status |
아파치 시작 | systemctl start httpd | service httpd start |
아파치 정지 | systemctl stop httpd | service httpd stop |
아파치 재시작 | systemctl restart httpd | service httpd restart |
아파치 리로드 | systemctl reload httpd | service httpd reload |
아파치 자동시작 설정(On) | systemctl enable httpd | chkconfig httpd on |
아파치 자동시작 해제(Off) | systemctl disable httpd | chkconfig httpd off |
아파치 자동시작 확인 | systemctl is-enabled httpd | chkconfig httpd |
자동 실행 서비스 목록 | systemctl list-unit-files –type=service | chkconfig –list httpd |
아파치 마스크 | systemctl mask http | |
아파치 언마스크 | systemctl unmask http | |
방화벽 시작 | systemctl start firewalld | service iptables start |
방화벽 중지 | systemctl stop firewalld | service iptables stop |
방화벽 자동시작 적용 | systemctl enable firewalld | chkconfig iptables off |
방화벽 자동시작 해제 | systemctl disable firewalld | chkconfig iptables on |
Apache 실행 예제
Apahce 주요 디렉토리
/etc/httpd
- Apahce 디렉토리
/etc/httpd/conf
httpd.conf
: Apache 설정 파일magic
: MIME 형식을 지정하기 위한 파일
/etc/httpd/conf.d
- Apache 설정을 분리해서 저장하는 디렉토리
httpd.conf
설정 내용을 이 디렉토리에 저장하면httpd.conf
파일이 현 디렉토리를 내용을 불러와서 사용httpd.conf
파일 마지막에IncludeOptional conf.d/*.conf
구문이 존재
/etc/httpd/log
- 로그 파일이 저장되는 디렉토리
/etc/httpd/modules
- Apache 모듈 설치 디렉토리
1. 방화벽 설정
CentOS를 기본 설치할 경우 외부에서의
80 port
접근이 차단되어있습니다.
ports: 80/tcp
가 명시되어있는지 확인해주세요.
공란으로 되어있을 경우
80 port
로 접근 가능하도록 정책을 추가하고 reload하세요.
2. 아파치 자동시작 설정
3. 아파치 실행
4. 웹 브라우저에 자신의 IP 입력후 접속
http://[웹서버가 실행된 아이피 주소]
웹 브라우저에서 Testing 123..
이 나오면 Apache 설치 및 구동이 완료된 것 입니다.
5. 배포 디렉토리
/etc/httpd/conf/httpd.conf
파일을 열면 Apache
설정 내용이있습니다.
DocumentRoot "/var/www/html"
구문에 의해 /var/www/html
디렉토리의 파일을 웹 서버가 출력합니다.
<IfModule dir_module/>
구문에 index.html
이 기본 문서로 지정되어 있음을 확인 할수 있습니다.
하지만, 현재 /var/www/html
디렉토리에는 파일이 존재하지 않습니다.
/var/www/html
위치에 index.html
파일을 생성하고 다시 접속하면 index.html
의 내용이 출력됩니다.