热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何禁用所有apache虚拟主机?-Howtodisableallapachevirtualhosts?

Imwritingashellscripttodosomewebserverconfiguration.Ineedtodisableallcurrentlyacti

I'm writing a shell script to do some web server configuration. I need to disable all currently active virtual hosts. a2dissite doesn't accept multiple arguments, so I can't do

我正在编写一个shell脚本来进行一些Web服务器配置。我需要禁用所有当前活动的虚拟主机。 a2dissite不接受多个参数,所以我不能这样做

a2dissite `ls /etc/apache2/sites-enabled`

Should I use find? Is it safe to manually delete the symlinks in /etc/apache2/sites-enabled?

我应该使用find吗?手动删除/ etc / apache2 / sites-enabled中的符号链接是否安全?

9 个解决方案

#1


10  

Is your script Debian only? If so, you can safely delete all the symlinks in sites-enabled, that will work as long as all sites have been written correctly, in the sites-available directory.

你的脚本只是Debian吗?如果是这样,您可以安全地删除已启用站点中的所有符号链接,只要所有站点都已正确写入,这些符号链接将在sites-available目录中删除。

For example:

 find /etc/apache2/sites-enabled/ -type l -exec rm -i "{}" \;

will protect you against someone who has actually written a file instead of a symlink in that directory.

将保护您免受实际在该目录中编写文件而不是符号链接的人的攻击。

(remove the -i from rm for an automatic script, of course)

(当然,从rm中删除-i作为自动脚本)

#2


11  

After a little more research, I found out that a2dissite is just a shell script, and it basically just calls rm. So, like other responses, I agree that it is safe to do

经过一番研究,我发现a2dissite只是一个shell脚本,它基本上只是调用rm。因此,与其他回复一样,我同意这样做是安全的

rm /etc/apache2/sites-enabled/*

#3


8  

ubuntu 12.04lts / ubuntu 16.04lts

ubuntu 12.04lts / ubuntu 16.04lts

You can just do the following [NB: you will may need root permission sudo a2dissite]

您可以执行以下操作[注意:您可能需要root权限sudo a2dissite]

a2dissite *

Or

a2dissite

And it will prompt you for the ones you want to do

它会提示你做你想做的事

when you have completely disabled sites restart apache2 server

当你完全禁用站点重启apache2服务器

sudo systemctl restart apache2

or just reload apache configuration without a full restart:

或者只是在没有完全重启的情况下重新加载apache配置:

sudo service apache2 reload

#4


2  

You can just delete the symlinks, or move the entire directory away. There is no special database or other metadata besides those links.

您可以删除符号链接,也可以移动整个目录。除这些链接外没有特殊的数据库或其他元数据。

#5


2  

To remove the host file just delete it. If you just want to dissable the site, use

要删除主机文件,只需将其删除即可。如果您只想放弃网站,请使用

sudo a2dissite sitename

Restart apache2

sudo /etc/init.d/apache2 reload

Again to remove (delete)it completely from the system,

再次从系统中删除(删除)它,

sudo rm /etc/apache2/sites-available/sitename

I would also disable it first before deleting the file

我还会在删除文件之前先禁用它

#6


1  

I never use 'a2dissite ' and always delete and create the links in /etc/apache2/sites-enabled manually so yes, I'd say it's pretty safe.

我从不使用'a2dissite'并且总是手动删除并创建/ etc / apache2 / sites-enabled中的链接所以是的,我会说它非常安全。

#7


0  

Here is my workaround, first type:

这是我的解决方法,第一种类型:

# a2dissite (type this command without any argument, it would prompt to ask you choose the next line)

#a2dissite(键入此命令不带任何参数,它会提示您选择下一行)

Your choices are: siteA siteB siteC siteD

您的选择是:siteA siteB siteC siteD

Which site(s) do you want to disable (wildcards ok)?

您要禁用哪个站点(通配符确定)?

Now you just copy all of above list of sites (siteA siteB siteC siteD) and paste into as your answer, then Enter.

现在,您只需复制以上所有站点列表(siteA siteB siteC siteD)并粘贴到您的答案中,然后按Enter键。

The output result would be:

输出结果将是:

removing dangling symlink /etc/apache2/sites-enabled/siteA.conf
removing dangling symlink /etc/apache2/sites-enabled/siteB.conf
removing dangling symlink /etc/apache2/sites-enabled/siteC.conf
removing dangling symlink /etc/apache2/sites-enabled/siteD.conf

This approach will help us to optional to choose to a long list of names of site should be removed or intact.

这种方法将帮助我们选择要删除或完整的网站名称的长列表。

#8


-1  

you can edit the httpd.conf and delete the include line for the virtual hosts (at the bottom of the file)

您可以编辑httpd.conf并删除虚拟主机的包含行(位于文件底部)

#9


-3  

Apparently, you can just install the latest Ubuntu ;)

显然,你可以安装最新的Ubuntu;)


推荐阅读
  • 31.项目部署
    目录1一些概念1.1项目部署1.2WSGI1.3uWSGI1.4Nginx2安装环境与迁移项目2.1项目内容2.2项目配置2.2.1DEBUG2.2.2STAT ... [详细]
  • 在Docker中,将主机目录挂载到容器中作为volume使用时,常常会遇到文件权限问题。这是因为容器内外的UID不同所导致的。本文介绍了解决这个问题的方法,包括使用gosu和suexec工具以及在Dockerfile中配置volume的权限。通过这些方法,可以避免在使用Docker时出现无写权限的情况。 ... [详细]
  • 如何在服务器主机上实现文件共享的方法和工具
    本文介绍了在服务器主机上实现文件共享的方法和工具,包括Linux主机和Windows主机的文件传输方式,Web运维和FTP/SFTP客户端运维两种方式,以及使用WinSCP工具将文件上传至Linux云服务器的操作方法。此外,还介绍了在迁移过程中需要安装迁移Agent并输入目的端服务器所在华为云的AK/SK,以及主机迁移服务会收集的源端服务器信息。 ... [详细]
  • imx6ull开发板驱动MT7601U无线网卡的方法和步骤详解
    本文详细介绍了在imx6ull开发板上驱动MT7601U无线网卡的方法和步骤。首先介绍了开发环境和硬件平台,然后说明了MT7601U驱动已经集成在linux内核的linux-4.x.x/drivers/net/wireless/mediatek/mt7601u文件中。接着介绍了移植mt7601u驱动的过程,包括编译内核和配置设备驱动。最后,列举了关键词和相关信息供读者参考。 ... [详细]
  • Ubuntu安装常用软件详细步骤
    目录1.GoogleChrome浏览器2.搜狗拼音输入法3.Pycharm4.Clion5.其他软件1.GoogleChrome浏览器通过直接下载安装GoogleChro ... [详细]
  • 本文介绍了在Web应用系统中,数据库性能是导致系统性能瓶颈最主要的原因之一,尤其是在大规模系统中,数据库集群已经成为必备的配置之一。文章详细介绍了主从数据库架构的好处和实验环境的搭建方法,包括主数据库的配置文件修改和设置需要同步的数据库等内容。MySQL的主从复制功能在国内外大型网站架构体系中被广泛采用,本文总结了作者在实际的Web项目中的实践经验。 ... [详细]
  • systemd-nspawn可以创建最轻量级的容器(ns的意思就是namespace),本文的实验平台是Ubuntu16.04,x86_64机器。本文的目的是:在Ubuntu中用syst ... [详细]
  • python3.7 安装pip3_python3的pip3安装
    ---恢复内容开始---pip3的安装需要对应一整套python的编译工具库,所以安装好的pip3是这个样子:inearAi:~$pip3-Vpi ... [详细]
  • 系统安装Debian系统的安装方式和Ubuntu系统的安装方式几乎是一样的,毕竟Ubuntu系统是基于Debian的,就如同CentOS基于Redhat ... [详细]
  • 搭建Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境的详细步骤
    本文详细介绍了搭建Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境的步骤,包括环境说明、相关软件下载的地址以及所需的插件下载地址。 ... [详细]
  • Ubuntu 9.04中安装谷歌Chromium浏览器及使用体验[图文]
    nsitionalENhttp:www.w3.orgTRxhtml1DTDxhtml1-transitional.dtd ... [详细]
  • 本文讨论了在Linux系统中,使用chown命令将django项目目录下的static目录的拥有者从root改为eureka的问题。作者尝试了多种命令,包括chown和sudo chown等,但都没有成功修改拥有者。文章提供了相关目录的权限信息,并补充了项目所在磁盘和操作系统的信息。 ... [详细]
  • 在ubuntu服务器上安装vscode,但是目前使用的方法都无法成功。第一次安装经历:安装完anaconda后有自动安装vscode的选项,输入yes后,没有出现错误,但是在终端输 ... [详细]
  • 分享css中提升优先级属性!important的用法总结
    web前端|css教程css!importantweb前端-css教程本文分享css中提升优先级属性!important的用法总结微信门店展示源码,vscode如何管理站点,ubu ... [详细]
  • 阿里云服务器iis设置方法与上千种Linux桌面版本相比,Linux服务器只有可怜的十几种。但想要选对适合你的企业需要的仍然不是件容易的事情,选Linux服务器首先要 ... [详细]
author-avatar
ayipyipyip
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有