a2ensite와 a2dissite는 어떻게?


10

Linux 서버에 로그인했습니다. 나는 그것이 Red Hat 배포판이라고 생각합니다.

명령 a2ensite을 a2dissite사용할 수 없습니다. 에서 /etc/httpd디렉토리, 나는 어떤 언급이 표시되지 않는 sites-enabled나 sites-available.

사이트에서 현재의 지시문을 실행하고 있다고 확신합니다 /etc/httpd/conf.d/ssl.conf. 을 수행 한 a2dissite ssl다음 웹 서버를 다시로드하고 싶습니다 . 이것을 달성하는 방법?

답변:


24

a2ensite 등은 데비안 기반 시스템에서 사용할 수 있고 RH 기반 배포에서는 사용할 수없는 명령입니다.

그들이하는 일은 구성 파일 부분에서 기호 링크에서 관리하는 것입니다 /etc/apache2/sites-available및 mods-available에 /etc/apache2/sites-enabled등을. 당신은 설정 파일에 정의 된 가상 호스트가있는 경우 예를 들면 /etc/apache2/sites-avaible/example.com, a2ensite example.com이 파일에 대한 심볼릭 링크를 만들 것입니다 /etc/apache2/sites-enabled및 아파치 설정을 다시로드합니다. 기본 Apache 구성 파일에는 모든 파일을 포함하는 행이 포함 /etc/apache2/sites-enabled되어 있으므로 런타임 구성에 통합됩니다.

RHEL에서이 구조를 모방하는 것은 매우 쉽습니다. 두 디렉토리를 추가 /etc/httpd/이름 sites-enabled과 sites-available와의 파일로 가상 호스트를 추가합니다 sites-available. 그런 다음 줄을 추가하십시오

include ../sites-enabled 

에 /etc/httpd/conf/httpd.conf. 이제 심볼릭 링크를 sites-enabled만든 다음 service httpd reload또는을 사용 하여 구성을 다시로드 할 수 있습니다 apachectl.


1
아 알 겠어. 따라서 기본적으로 /etc/httpd/conf.d는 사이트 활성화와 동등한 기능을합니다. 따라서 해당 디렉토리에서 ssl.conf를 제거하고 httpd를 다시 시작 / 다시로드하면 변경 사항이 적용됩니다. 멋지다
— John

2

Sven의 탁월한 답변에 대한 추가 기능으로 a2ensite 및 a2dissite의 동작을 모방하는 두 개의 스크립트가 있습니다. ensite.sh 원본은 Github 에서 찾을 수 있습니다

a2ensite.sh

#!bin/bash
# Enable a site, just like the a2ensite command.

SITES_AVAILABLE_CONFIG_DIR="/etc/httpd/sites-available";
SITES_ENABLED_CONFIG_DIR="/etc/httpd/sites-enabled";

if [ $1 ]; then
  if [ -f "${SITES_ENABLED_CONFIG_DIR}/${1}" ]; then
    echo "Site ${1} was already enabled!";
  elif [ ! -w $SITES_ENABLED_CONFIG_DIR ]; then
    echo "You don't have permission to do this. Try to run the command as root."
  elif [ -f "${SITES_AVAILABLE_CONFIG_DIR}/${1}" ]; then
    echo "Enabling site ${1}...";
    ln -s $SITES_AVAILABLE_CONFIG_DIR/$1 $SITES_ENABLED_CONFIG_DIR/$1
    echo "done!"
 else
   echo "Site not found!"
fi
else
  echo "Please, inform the name of the site to be enabled."
fi


a2dissite.sh

#!bin/bash
# Disable a site, just like a2dissite command, from Apache2.

SITES_AVAILABLE_CONFIG_DIR="/etc/httpd/sites-available";
SITES_ENABLED_CONFIG_DIR="/etc/httpd/sites-enabled";

if [ $1 ]; then
  if [ ! -f "${SITES_ENABLED_CONFIG_DIR}/${1}" ]; then
    echo "Site ${1} was already disabled!";
  elif [ ! -w $SITES_ENABLED_CONFIG_DIR ]; then
    echo "You don't have permission to do this. Try to run the command as root."
  elif [ -f "${SITES_AVAILABLE_CONFIG_DIR}/${1}" ]; then
    echo "Disabling site ${1}...";
    unlink $SITES_ENABLED_CONFIG_DIR/$1
    echo "done!"
  else
    echo "Site not found!"
  fi
else
  echo "Please, inform the name of the site to be enabled."
fi

"사이트 이름"은 무엇이어야합니까?
— ewizard
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.