apache - Ubuntu本地主机问题

标签 apache ubuntu

现在我知道有很多关于在 Ubuntu 中使用 apache2 和 PHP 设置 localhost 的帖子。

但是,我已经绞尽脑汁了大约 2 个小时,现在我已经受够了。

这基本上是一个测试站点;我想看看它是否适用于网址
personalisedchampagnestore.localhost
我已经安装了 apache2 和 php5。我已经测试了 localhost,它适用于默认的 html 页面。

附言这些类似于默认值,所以我已经去掉了很多

然后我配置了以下文件:

apache2.conf

<Directory /var/www/vhosts/personalisedchampagnestore/PersonalisedChampagneStore/web/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

网站可用/个性化champagnestore.conf
<VirtualHost *:80>
    ServerName personalisedchampagnestore

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/vhosts/personalisedchampagnestore/PersonalisedChampagneStore/web/


    ErrorLog ${APACHE_LOG_DIR}/personalisedchampagnestore/error.log
    CustomLog ${APACHE_LOG_DIR}/personalisedchampagnestore/access.log combined

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

最后

/etc/hosts
127.0.0.1   localhost
127.0.0.1   personalisedchampagnestore
127.0.1.1   liam-VirtualBox

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

保存后,我重新启动了 apache2,使用 sudo a2ensite personalisedchampagnestore 启用了站点,并使用 sudo a2enmod rewrite 启用 mod_rewrite .我还删除了 .htaccess 并添加了一个空白 index.html 页面,但我仍然收到以下错误:
Server not found

Firefox can't find the server at www.personalisedchampagnestore.localhost.

我也看过/var/log/apache2/error.log文件,那里什么都没有。另外,我查看了我设置的错误日志 /var/log/apache2/personalisedchampagnestore/error.log , 这个文件是完全空的。

有没有人有任何建议?我认为这是我错过的非常微小的事情,我最终会踢自己。

编辑:
Server version: Apache/2.4.7 (Ubuntu)

PHP 5.5.9-1ubuntu4 (cli) (built: Apr  9 2014 17:08:27) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

Ubuntu 14.04 LTS

最佳答案

当然,你需要确保www不包含在 url 中(由于 .htaccess 文件)。

1.在sites-available/personalisedchampagnestore.conf文件,ServerName提到的是personalisedchampagnestore

  • /etc/hosts文件,注册主机为personalisedchampagnestore
  • 所以你只需要在浏览器地址栏中写下 -http://personalisedchampagnestore

  • 它应该可以正常工作。

    如果您希望网址为 http://personalisedchampagnestore.localhost ,那么请进行以下更改 -
  • sites-available/personalisedchampagnestore.conf文件,更改以下行 -ServerName personalisedchampagnestorewithServerName personalisedchampagnestore.localhost
  • /etc/hosts文件,更改以下行 -127.0.0.1 personalisedchampagnestorewith127.0.0.1 personalisedchampagnestore.localhost

  • 我希望它有所帮助。

    关于apache - Ubuntu本地主机问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23345152/

    相关文章:

    php - php 中的字符串/段落/文档比较

    ubuntu - 如何安装 SOOT?

    ruby-on-rails - 在 ubuntu 中取消 bash 的源码

    无法在ubuntu上运行C编译的程序

    python - 在ubuntu中使用livestreamer录制

    ubuntu 创建一个 tensorflow 工作节点

    apache - 配置Apache Web服务器以使用代理服务器

    java - 使用 Apache POI 设置 Excel 单元格的 RGB 背景颜色

    javascript - 我该如何修复 "app.use() requires a middleware function"

    svn - 不同路径的 Apache