linux如何修改根名字,在ubuntu 16.04中修改apache首页根目录及文件名称步骤

一、修改根目录

(一)、如果有默认设置则:(enabled 启用)

打开/etc/apache2/sites-enabled/000-default.conf 找到 DocumentRoot 修改成相应的目录即可 ,比如 /var/www/html/你的目录;当然这里面也可以设置http跳转至https

(二)、如果无默认设置则:(available可用)

打开/etc/apache2/sites-available/000-default.conf 找到 DocumentRoot 修改成相应的目录即可 ,比如 /var/www/html/你的目录;

二、修改首页文件名称

打开 /etc/apache2/mods-available/dir.conf 其中 DirectoryIndex

是则是设置首页文件名称的,比如 index.html index.cgi index.pl index.php index.xhtml index.htm 等 。其优先顺序按排序先后来。

三、修改完后记得重启:sudo service apache2 restart 或systemctl restart apache2

四、其他常见操作

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

1、查看日志 tail -f /var/log/apache2/error.log

2、出现 If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule 错误,使用 sudo a2enmod proxy_http 可解决

3、

Invalid command 'ProxyRequests', perhaps misspelled or defined by a module not included in the server configuration 运行一下

a2enmod proxy再重启即可

4、node.js 服务增加域名配置

在 /etc/apache2/sites-enabled 新建xxx.conf 文件,在文件里写入如下文件:

ServerName xxx.com(即你的域名)

ServerAlias xxx.com (即你的域名)

ProxyRequests Off

Order deny,allow

Allow from all

ProxyPass http://127.0.0.1:xxxx/ (即你的端口)

ProxyPassReverse http://127.0.0.1:xxxx/ (即你的端口)

5、查看apache版本

apachectl -v

Server version: Apache/2.4.37 (Ubuntu)

Server built: 2018-10-28T15:00:00

6、Apache 2.4统一增加响应头

/etc/apache2/apache2.conf (httpd.conf跟这个是一样的) 增加如下

Header always set Referrer-Policy "no-referrer"

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值