在本文中,我们将学习如何将Apache默认的Web根文件夹更改为新位置。默认情况下,Apache Web根目录或Document根目录文件夹位于/ var / www / html。
出于安全原因或由于数据大小而引起空间问题,这些类型的更改将非常有用,我们想将文档根文件夹更改为其他位置或装入点。如果我们有多个实例,并且希望将每个网站的数据保存在各自的卷或文件夹中,这将很有帮助。
具有计算机上Sudo权限的用户的Ubuntu 16.04服务器。
机器上安装的Apache2 Web服务器
用于移动站点信息或文件的新安装位置或新文件夹位置。
众所周知,Apache Web服务器的默认位置是/ var / www / html,或者您是否具有不同的设置,其中包含多个站点,并且具有针对不同站点的多个文档根。
如果我们在Apache的虚拟主机中配置并启用了多个站点,则可以在/ etc / apache2 / sites-enabled文件夹中搜索文档根目录。
下面是用于查找服务器中发布的所有多个站点的文件夹名称的命令。
$ grep –R “DocumentRoot” /etc/apache2/sites-enabled
由于我只有一个站点,因此启用输出将如下所示–
sites-enabled/000-default.conf DocumentRoot /var/www/html
使用rsync命令,我们会将所有文件复制到一个新文件夹位置,在该位置我们要移动Apache Web服务器的默认文档根文件夹。
例如,在我们的环境中,新的Web根文档文件夹将为'/ mnt / newdatavol'
$ sudo rysnc –av /var/www/html /mnt/newdatavol
Apache使用两种类型的配置文件,一种是全局的,另一种是特定于站点的配置,因为我们正在使用现有安装。我们将修改使用grep命令找到的虚拟主机文件。
默认情况下,我们必须更改Apache 000-default.conf和default-ssl.conf随附的两个虚拟主机配置文件。
$ sudo vi /etc/apache2/sites-enabled/000-default.conf <VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost DocumentRoot /mnt/newdatavol # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost>
我们保存了文件,现在我们将在下面将SSL端口的Apache Web服务器更改为默认文件夹位置,以查看用于编辑default-ssl.conf的命令
$ sudo vi /etc/apache2/sites-available/default-ssl.conf <IfModule mod_ssl.c> <VirtualHost _default_:443> ServerAdmin webmaster@localhost DocumentRoot /mnt/newdatavol # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf # SSL Engine Switch: # Enable/Disable SSL for this …. .. .. </VirtualHost>
将配置更改更改为默认文档根目录后,我们需要重新启动Apache服务器以使更改生效。在此之前,我们将检查语法错误
$ sudo apachectl configtest Syntax OK
正如我们看到的消息语法正确,现在我们可以继续并重新启动服务器以使更改生效。
$ sudo systemctl restart apache2
在以上文章中,我们学习了如何在Ubuntu 16.04上更改Apache服务器的默认文档位置。这很容易备份我们发布的网站,而无需任何系统默认文件,当我们在不同位置拥有多个网站或客户网站数据时,它们将非常有用。我们还可以使用其他网络存储设备(例如NAS和SAN)安全地存储日期。
例如:如果jar文件位于“D:\apps\jar.jar”中,则日志路径为“D:\log”;如果jar文件位于“C:\apps\jar.jar”中,则日志路径为“C:\log” 我尝试将log4j2.xml中的行(如下)更改为: 并在初始化记录器之前调用此函数:
问题内容: 如何在Jenkins作为Windows服务运行的Windows上更改Jenkins默认文件夹。由于分区上空间不足,我想将文件夹更改为(每个版本占用〜10MB的可用空间)。我不想重新安装为Windows服务。我只想更改现有实例的文件夹。在缺乏全局解决方案的情况下,我只能专注于重定位文件夹。 在此先感谢您的帮助。 问题答案: 停止詹金斯服务 将文件夹移到 使用regedit,更改为 启动服
如何更改Jenkins作为Windows服务运行的Windows上的Jenkins默认文件夹。由于分区上的空间不足(每个构建占用10MB左右的可用空间),我想将文件夹更改为。我不想将重新安装为Windows服务。我只想更改现有实例的文件夹。在缺乏全局解决方案的情况下,我只能专注于重新定位文件夹。 事先谢谢你的帮助。
问题内容: 我正在制作一个使用Twitter凉亭的新项目。我创建了一个来维护我的所有依赖,如jquery。然后运行,将所有内容安装在名为的文件夹中。但是我需要将组件安装在其他文件夹中,例如。 我尝试将我的components.json编辑为: 要么: 如https://github.com/twitter/bower/pull/94所示,但它不起作用。 问题答案: 在项目根目录(与您的主目录相对)
问题内容: 我需要更改默认的Eclipse WTP“ Web资源”动态文件夹。当前它指向WebContent,我需要指向src \ main \ webapp。 问题答案: 我找到了解决办法:在.settings在项目的文件夹,文件夹,有一个名为“org.eclipse.wst.common.component”,里面更改行的文件有。 就这样!
我正在做一个新项目,使用twitter上的bower。我创建了一个来维护我的所有依赖项,比如jquery。然后我运行,它将所有内容安装在名为的文件夹中。但是我需要将组件安装在不同的文件夹中,例如。 我尝试将我的components.json编辑成: 或: 如中所示https://github.com/twitter/bower/pull/94但它不起作用。