如何查看linux下apache配置文件-创新互联

这篇文章主要介绍如何查看linux下apache配置文件,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

成都创新互联公司专注于营山企业网站建设,自适应网站建设,商城网站建设。营山网站建设公司,为营山等地区提供建站服务。全流程按需求定制设计,专业设计,全程项目跟踪,成都创新互联公司专业和态度为您提供的服务

Linux下Apache的配置文件是 /etc/apache2/apache2.conf,Apache在启动时会自动读取这个文件的配置信息。而其他的一些配置文件,如 httpd.conf等,则是通过Include指令包含进来。

在apache2.conf里有sites-enabled目录,而在 /etc/apache2下还有一个sites-available目录,其实,这里面才是真正的配置文件,而sites- enabled目录存放的只是一些指向这里的文件的符号链接,你可以用ls /etc/apache2/sites-enabled/来证实一下。

所以,如果apache上配置了多个虚拟主机,每个虚拟主机的配置文件都放在 sites-available下,那么对于虚拟主机的停用、启用就非常方便了:当在sites-enabled下建立一个指向某个虚拟主机配置文件的链 接时,就启用了它;如果要关闭某个虚拟主机的话,只需删除相应的链接即可,根本不用去改配置文件。

sudo cp /etc/apache2/sites-avaliable/000-default.conf , 命名为 test.conf

2.修改配置文件:test.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.test.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/test/
ErrorLog /var/www/html/test/error.log
CustomLog /var/www/html/test/access.log combined
<Directory "/var/www/html/test">
    Options FollowSymLinks
    DirectoryIndex index.php index.html index.htm
    AllowOverride All #注意这个地方的配置,会影响本地目录下的.htaccess的启用
    Order deny,allow
    Allow from All
</Directory>
# 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
# 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>

建立链接文件:

sudo ln -s /etc/apache2/sites-available/test.conf /etc/apache2/sites-enabled/test.conf

或者: sudo a2ensite test.conf

4.重启apache 服务器

sudo /etc/init.d/apache2 restart

修改hosts(/etc/hosts)

// 增加一行
127.0.0.1 www.test.com

到这里基本就可正常访问了!

附:如果这里还需要对目录级的URL重写支持,继续往下:

终端运行

sudo a2enmod

程序提示可供激活的模块名称,输入:rewrite

成功会提示

rewrite already load

修改/etc/apache2/sites-enabled/test.conf (该链接指向的是站点配置文件)

把下的AllowOverride 属性改为All,保存。(上面我们已经配置为 All)

重新加载apache

sudo /etc/init.d/apache2 restart

以上是如何查看linux下apache配置文件的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联成都网站设计公司行业资讯频道!

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

当前文章:如何查看linux下apache配置文件-创新互联
URL链接:https://www.cdcxhl.com/article16/jsigg.html

成都网站建设公司_创新互联,为您提供网站收录App开发搜索引擎优化ChatGPT网站策划定制网站

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

h5响应式网站建设