更改 Amazon EC2 Linux 实例中网站的默认目录 [英] Change default directory for website in Amazon EC2 Linux instance

查看:21
本文介绍了更改 Amazon EC2 Linux 实例中网站的默认目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在 Amazon EC2 Linux 实例上安装基于 Zend 的站点.为了能够做到这一点,我需要将主目录名称设为public"而不是html",这是 EC2 的默认名称.

如何将站点默认目录的路径从/var/www/html/更改为/var/www/public/?

预先感谢您的帮助!

解决方案

Oliver 走在正确的轨道上.你需要做两件事:

  1. httpd.conf 文件中的 DocumentRoot 语句更新到您的新主目录.
  2. 重新启动您的网络服务以使更改生效.

例如,执行以下命令:

sudo vi/etc/httpd/conf/httpd.conf

然后在 vi 编辑器中输入 /DocumentRoot + ENTER 查找以下行:

DocumentRoot "/var/www/"

现在只需将文档根目录更改为您想要的任何内容.(在vi编辑器中,将光标移动到您想要的位置,按i切换到插入模式,修改代码,然后按ESC 退出插入模式.)您还可以(并且可能应该)更改紧随其后的任何 <Directory 语句,因为这些语句放宽了一些访问标准并且不应该t 应用在您的网络根目录之上的级别.例如,您可能会看到:

<预><代码>## 放宽对/var/www 中内容的访问.#<目录/var/www">

我建议将其更改为:

<预><代码>## 放宽对/var/www/html/drupal 中内容的访问.#<目录/var/www/html/drupal">

更改注释纯粹是为了保持一致性,以防其他人稍后查看您的代码.文件中可能至少有 2 条语句符合此模式,因此请查找并更改它们.

输入 :x 并按 ENTER 完成后保存更改.

最后,关键的一步:重启你的网络服务!这是一个经常被忽视的步骤.该命令将根据您的服务器设置而有所不同,但可能非常接近:

sudo service mysqld restart

完成后检查您的网站,以确保当您只使用域名而不使用其他文件夹时,它会转到正确的默认文件夹.祝你好运!

I want to be able to install a Zend - based site on Amazon EC2 Linux instance. To be able to do that, I need to have the main directory name as "public" rather than "html" as is default for EC2.

How can I change the path to the site's default directory from /var/www/html/ to /var/www/public/ ?

Thank you in advance for your help!

解决方案

Oliver is on the right track. You need to do 2 things:

  1. Update the DocumentRoot statement within the httpd.conf file to your new home directory.
  2. Restart your web service for the change to take effect.

So for example, do the following command:

sudo vi /etc/httpd/conf/httpd.conf

Then look for the following line by typing /DocumentRoot + ENTER in the vi editor:

DocumentRoot "/var/www/"

Now just change the document root directory to whatever you want.(In the vi editor, move the cursor where you want it, press i to switch to insert mode, modify the code, then press ESC to get out of insert mode.) You can (and probably should) also change any <Directory statements that immediately follow, as these relax some access standards and shouldn't apply at a level above your web root. For example, you may see this:

#
# Relax access to content within /var/www.
#
<Directory "/var/www">

I recommend changing this to:

#
# Relax access to content within /var/www/html/drupal.
#
<Directory "/var/www/html/drupal">

Changing the comment is purely for consistency should anyone else review your code later. There are probably at least 2 statements that fit this pattern in the file, so look for and change them.

Save your changes when finished by typing :x and pressing ENTER.

Finally, a crucial step: restart your web service! This is a commonly overlooked step. The command will vary based on your server setup, but will probably be very close to:

sudo service mysqld restart

Check your website when finished to make sure it's going to the right default folder when you just use the domain name with no additional folders. Good luck!

这篇关于更改 Amazon EC2 Linux 实例中网站的默认目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆