我login到Linux服务器。 我认为这是一个红帽发行版。
a2ensite和a2dissite命令不可用。 在/etc/httpd目录中,我没有看到任何提及的sites-enabled或sites-available 。
我很确定该网站正在执行/etc/httpd/conf.d/ssl.conf的指令。 我想做一个a2dissite ssl ,然后重新加载Web服务器。 如何做到这一点?
a2ensite等是在基于Debian的系统中可用的命令,在基于RH的发行版中不可用。
他们所做的是pipe理/etc/apache2/sites-availableconfiguration文件部分的符号链接,以及/etc/apache2/sites-enabled /etc/apache2/sites-available mods-available 。 例如,如果您在configuration文件/etc/apache2/sites-avaible/example.com定义了vhost,则a2ensite example.com将在/etc/apache2/sites-enabled为此文件创build符号链接,并重新加载apacheconfiguration。 主要的Apacheconfiguration文件包含的行包含/etc/apache2/sites-enabled每个文件,因此它们被合并到运行时configuration中。
在RHEL中模仿这个结构是很容易的。 在/etc/httpd/ named sites-enabled和sites-available添加两个目录,并将您的虚拟主机添加到sites-available文件。 之后,添加一行
include ../sites-enabled
到/etc/httpd/conf/httpd.conf 。 您现在可以创build符号链接到sites-enabled ,然后使用service httpd reload或apachectl重新加载configuration。
作为Sven出色的答案的补充,两个脚本模仿a2ensite和a2dissite的行为。 原来的ensite.sh可以在Github上find
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