我需要使用特定版本的 PHP (7.1) 设置本地 LAMP。在全新安装的 18.04 中,我首先安装了 Apache 和 MySQL。然后我按照本指南从 ppa:ondrej/php 安装 PHP 并完成安装 phpMyAdmin,它工作正常。
我的 php 安装是
sudo apt install php7.1 libapache2-mod-php7.1 php7.1-mysql php7.1-mbstring
对于我的站点测试,我运行了一个在 16.04 上对我有用的虚拟主机脚本。一切看起来都有效,除了手动必须 chown public_html 目录。我的问题是,尝试在 info.dev 访问我的测试文件会返回页面错误info.dev refused to connect.
和ERR_CONNECTION_REFUSED
.
PHP 似乎正在工作,因为我成功地infophp()
从 apache 测试页面调用。
有人可以提出一些建议吗?
这里有更多信息...
站点可用的 v-hosts 文件
<VirtualHost *:80>
ServerName info.dev
ServerAlias www.info.dev
ServerAdmin webmaster@localhost
DocumentRoot /var/www/info.dev/public_html
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
#CustomLog ${APACHE_LOG_DIR}/access.log combined
#Include conf-available/serve-cgi-bin.conf
<Directory /var/www/info.dev/public_html >
Options Indexes FollowSymLinks MultiViews
# AllowOverride All allows using .htaccess
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
/etc/hosts 文件
127.0.0.1 localhost
127.0.1.1 leon
# 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
127.0.0.1 magento.dev
127.0.0.1 info.dev
我的一些access.log:
127.0.0.1 - - [21/Oct/2018:09:24:05 +0300] "GET / HTTP/1.1" 200 315 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0"
127.0.0.1 - - [21/Oct/2018:09:24:05 +0300] "GET /favicon.ico HTTP/1.1" 404 500 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0"
::1 - - [21/Oct/2018:09:41:18 +0300] "GET / HTTP/1.1" 200 23933 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36"
我的一些error.log
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
[Sun Oct 21 08:40:11.623382 2018] [mpm_prefork:notice] [pid 32239] AH00163: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Sun Oct 21 08:40:11.623406 2018] [core:notice] [pid 32239] AH00094: Command line: '/usr/sbin/apache2'
[Sun Oct 21 09:27:39.337465 2018] [mpm_prefork:notice] [pid 32239] AH00169: caught SIGTERM, shutting down
[Sun Oct 21 09:41:16.361551 2018] [mpm_prefork:notice] [pid 3368] AH00163: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Sun Oct 21 09:41:16.361651 2018] [core:notice] [pid 3368] AH00094: Command line: '/usr/sbin/apache2'
权限
leon@leon:/var/www/info.dev$ ls -l
total 4
drwxr-xr-x 2 leon www-data 4096 loka 21 09:42 public_html
leon@leon:/var/www/info.dev$ cd public_html/
leon@leon:/var/www/info.dev/public_html$ ls -l
total 4
-rw-r--r-- 1 leon leon 22 loka 21 09:42 index.php
leon@leon:/var/www/info.dev/public_html$
嗯……不管这是什么
leon@leon:/var/www/info.dev/public_html$ apachectl -S
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:
*:80 is a NameVirtualHost
default server 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost info.dev (/etc/apache2/sites-enabled/info.dev.conf:1)
alias www.info.dev
port 80 namevhost magento.dev (/etc/apache2/sites-enabled/magento.dev.conf:1)
alias www.magento.dev
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default
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
好的!经过长时间的敲击键盘后,我意识到这与命名您的域有关
.dev
我尝试了相同的步骤,
.lan
并且效果很好。