当我运行 vhost 时,网站无法访问

当我运行 vhost 时,网站无法访问

我已经尝试了两天来运行我的虚拟主机,到目前为止,它运行良好。我搜索了但找不到解决方案。该站点已启用。这是我收到的错误:此站点无法访问 project.local 不允许连接。对本地项目进行 Google 搜索。ERR_CONNECTION_REFUSED

这是我的配置文件:

projet.conf 

ServerName projet.local
ServerAdmin webmaster@localhost
DocumentRoot "/home/malik/WCS"
<Directory "/home/malik/WCS" >
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
</Directory>    

在 ect/hosts 中:

127.0.0.1   projet.local

/var/log/apache2/access.log.1:

127.0.0.1 - - [30/Oct/2018:15:16:16 +0100] "GET / HTTP/1.1" 200 771 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36"
127.0.0.1 - - [30/Oct/2018:17:28:13 +0100] "GET / HTTP/1.1" 200 771 

错误日志1:

[Wed Dec 19 09:58:34.636654 2018] [mpm_prefork:notice] [pid 1436] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Wed Dec 19 09:58:34.636691 2018] [core:notice] [pid 1436] AH00094: Command line: '/usr/sbin/apache2'
[Thu Dec 20 02:22:52.333222 2018] [core:warn] [pid 1436] AH00045: child process 4808 still did not exit, sending a SIGTERM
[Thu Dec 20 02:22:52.448879 2018] [core:warn] [pid 1436] AH00045: child process 4809 still did not exit, sending a SIGTERM
[Thu Dec 20 02:22:52.448895 2018] [core:warn] [pid 1436] AH00045: child process 4810 still did not exit, sending a SIGTERM
[Thu Dec 20 02:22:52.448900 2018] [core:warn] [pid 1436] AH00045: child process 4811 still did not exit, sending a SIGTERM
[Thu Dec 20 02:22:52.448904 2018] [core:warn] [pid 1436] AH00045: child process 4812 still did not exit, sending a SIGTERM
Cannot load Xdebug - it was already loaded
Cannot load Xdebug - it was already loaded
Cannot load Xdebug - it was already loaded
Cannot load Xdebug - it was already loaded
Cannot load Xdebug - it was already loaded
Cannot load Xdebug - it was already loaded
Cannot load Xdebug - it was already loaded
Cannot load Xdebug - it was already loaded
Cannot load Xdebug - it was already loaded
Cannot load Xdebug - it was already loaded
[Thu Dec 20 02:22:53.465018 2018] [mpm_prefork:notice] [pid 1436] AH00169: caught SIGTERM, shutting down
Cannot load Xdebug - it was already loaded
Cannot load Xdebug - it was already loaded

$ sudo netstat -plnt
Proto Recv-Q Send-Q Adresse locale          Adresse distante        Etat       PID/Program name
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      1169/mysqld     
tcp        0      0 127.0.0.1:63342         0.0.0.0:*               LISTEN      4608/java       
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN      2182/dnsmasq    
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      4456/cupsd      
tcp        0      0 127.0.0.1:6942          0.0.0.0:*               LISTEN      4608/java       
tcp6       0      0 ::1:631                 :::*                    LISTEN      4456/cupsd   

$ apachectl -S
[Thu Jan 03 17:49:33.928029 2019] [so:warn] [pid 5785] AH01574: module php7_module is already loaded, skipping
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:

127.0.0.1:80           is a NameVirtualHost
         default server localhost (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost blog.local (/etc/apache2/sites-enabled/blog.conf:1)
         port 80 namevhost hph.local (/etc/apache2/sites-enabled/hph.conf:1)
         port 80 namevhost librairie.dev (/etc/apache2/sites-enabled/librairie.conf:1)
         port 80 namevhost projet.local (/etc/apache2/sites-enabled/projet.conf:1)
         port 80 namevhost symfony.local (/etc/apache2/sites-enabled/symfony.conf:1)
127.0.1.1:80           cornac.local (/etc/apache2/sites-enabled/cornac.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex rewrite-map: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl 
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used

sudo systemctl 启动 apache2.service

systemctl 状态 apache2.service

apache2.service - LSB:Apache2 网络服务器 已加载:已加载(/etc/init.d/apache2;错误;供应商预设:已启用) 插入:/lib/systemd/system/apache2.service.d └─apache2-systemd.conf 活动:自 2019-01-03 21:30:34 CET 以来处于非活动状态(已死亡);2 分 9 秒前 文档:man:systemd-sysv-generator(8) 进程:13298 ExecStop=/etc/init.d/apache2 stop(code=exited,status=0/SUCCESS) 进程:13274 ExecStart=/etc/init.d/apache2 start(code=exited,status=0/SUCCESS)

janv. 03 21:30:20 malik-X751LJ apache2[13274]: * 启动 Apache httpd web 服务器 apache2 janv. 03 21:30:27 malik-X751LJ apache2[13274]: [2019 年 1 月 3 日星期四 21:30:27.211423] [so:warn] [pid 13291] AH01574: 模块 php7_module 已加载,跳过 janv。 03 21:30:32 malik-X751LJ apache2[13274]: [2019 年 1 月 3 日星期四 21:30:32.218467] [core:error] [pid 13291] (EAI 2) 名称或服务未知: AH00547: 无法解析 ho janv。03 21:30:32 malik-X751LJ apache2[13274]: AH00558: apache2: 无法可靠地确定服务器的完全限定域名,使用 127.0.1.1。设置“ServerN janv”。03 21:30:34 malik-X751LJ apache2[13274]: 分段错误(核心转储)janv。 janv. 03 21:30:34 malik-X751LJ apache2[13274]: 操作“启动”失败。 janv. 03 21:30:34 malik-X751LJ apache2[13274]: Apache 错误日志可能有更多信息。 janv. 03 21:30:34 malik-X751LJ apache2[13298]: * 停止 Apache httpd Web 服务器 apache2 janv. 03 21:30:34 malik-X751LJ apache2[13298]: * janv. 03 21:30:34 malik-X751LJ systemd[1]: 已启动 LSB: Apache2 Web 服务器。

任何帮助都将不胜感激,谢谢

答案1

您的ServerName参数设置为projet.local您真正想要的值时project.local

更改它,保存,重新加载 apache2 ( sudo systemctl reload apache2) 并重试。

您还需要更新您的/etc/hosts(注意:etc而不是ect同时)文件,因为其中的拼写也有错误。

相关内容