Ubuntu localhost issue



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

然而,我已经绞尽脑汁了大约两个小时,现在我已经受够了。

这基本上是一个试验场;我想看看它是否与url 一起工作

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

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


1.在sites-available/personalisedchampagnestore.conf文件中,提到的ServerNamepersonalisedchampagnestore

  1. /etc/hosts文件中,注册的主机为personalisedchampagnestore

  2. 所以你只需要在浏览器地址栏中写下-http://personalisedchampagnestore

它应该可以正常工作。


如果您希望url为http://personalisedchampagnestore.localhost,请进行以下更改-

  1. sites-available/personalisedchampagnestore.conf文件中,更改以下行-ServerName personalisedchampagnestore
    with
    ServerName personalisedchampagnestore.localhost

  2. /etc/hosts文件中,更改以下行-
    127.0.0.1 personalisedchampagnestore
    with
    127.0.0.1 personalisedchampagnestore.localhost

我希望它能有所帮助。

最新更新