我在 Ubuntu 16.04LTS 上有 apache2 服务器,我现在在 /var/www/html 中有名为 book_donation 的 Laravel 5.6 项目,当我访问 localhost 时,Laravel 欢迎屏幕出现没有问题,但是每当我单击任何 url 时,它都会给出:
未找到
在此服务器上找不到请求的 URL /book_donation/public/login。Apache/2.4.18 (Ubuntu) 服务器在 127.0.0.1 端口 80
这是.htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
这是我的/etc/apache2/site-available/000-default.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.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory "/var/www/html">
AllowOverride all
Require all granted
</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
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# 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>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
我的php版本是7.1,apache版本是2.4.18,怎么解决?
如文档中所述,您应该将 Web 服务器的文档 / Web 根目录配置为公共目录。
创建一个新文件/etc/apache2/site-available/book_donation.test.conf
:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName book_donation.test
ServerAlias www.book_donation.test
DocumentRoot /var/www/html/book_donation/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
编辑您的/etc/hosts
文件并添加以下内容:
127.0.1.1 book_donation.test
然后运行:
sudo a2ensite book_donation.test.conf
sudo service apache2 restart
然后您应该能够访问book_donation.test
并查看您的网站。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句