我已经安装了Laravel,并且由于某些原因,我的路由不工作(404错误),只是默认的"/“。
这些是我创建的其他路线:
Route::get('test', function(){ // it doesn't work like so either: "/test"
return "Test";
});
Route::get('user', function(){
return "User";
});他们中的任何一个都没有到达。
如果我列出我所有的路线,这就是我得到的:
D:\web\laravel>php artisan route:list
+--------+----------+----------+------+---------+--------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+----------+------+---------+--------------+
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | api/user | | Closure | api,auth:api |
| | GET|HEAD | test | | Closure | web |
| | GET|HEAD | user | | Closure | web |
+--------+----------+----------+------+---------+--------------+知道为什么这些不管用吗?据我所知,Homestead中的web服务器和php不需要任何额外的手动配置来允许这样的基本代码工作。
编辑
如果我列出VM内的路线,我的路线就不在那里!:
vagrant@homestead:~/code$ php artisan route:list
+--------+----------+----------+------+---------+--------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+----------+------+---------+--------------+
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | api/user | | Closure | api,auth:api |
+--------+----------+----------+------+---------+--------------+这是我在Homestead.yaml中的共享文件夹配置:
folders:
- map: D:/web/laravel
to: /home/vagrant/code这些地点设立了:
sites:
- map: homestead.test
to: /home/vagrant/code/public如果我这样做,ls来自/home/流浪者/代码:
vagrant@homestead:~/code$ ls
app bootstrap composer.lock database phpunit.xml readme.md routes storage vendor
artisan composer.json config package.json public resources server.php tests webpack.mix.js这是我做“流浪”时的输出-规定:
PS C:\Homestead> vagrant up --provision
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Checking if box 'laravel/homestead' is up to date...
==> homestead-7: Clearing any previously set forwarded ports...
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
homestead-7: Adapter 1: nat
homestead-7: Adapter 2: hostonly
==> homestead-7: Forwarding ports...
homestead-7: 80 (guest) => 8000 (host) (adapter 1)
homestead-7: 443 (guest) => 44300 (host) (adapter 1)
homestead-7: 3306 (guest) => 33060 (host) (adapter 1)
homestead-7: 4040 (guest) => 4040 (host) (adapter 1)
homestead-7: 5432 (guest) => 54320 (host) (adapter 1)
homestead-7: 8025 (guest) => 8025 (host) (adapter 1)
homestead-7: 27017 (guest) => 27017 (host) (adapter 1)
homestead-7: 22 (guest) => 2222 (host) (adapter 1)
==> homestead-7: Running 'pre-boot' VM customizations...
==> homestead-7: Booting VM...
==> homestead-7: Waiting for machine to boot. This may take a few minutes...
homestead-7: SSH address: 127.0.0.1:2222
homestead-7: SSH username: vagrant
homestead-7: SSH auth method: private key
homestead-7: Warning: Connection aborted. Retrying...
homestead-7: Warning: Connection reset. Retrying...
homestead-7: Warning: Connection aborted. Retrying...
homestead-7: Warning: Connection reset. Retrying...
homestead-7: Warning: Connection aborted. Retrying...
homestead-7: Warning: Connection reset. Retrying...
homestead-7: Warning: Connection aborted. Retrying...
homestead-7: Warning: Connection reset. Retrying...
homestead-7: Warning: Connection aborted. Retrying...
homestead-7: Warning: Remote connection disconnect. Retrying...
homestead-7: Warning: Connection aborted. Retrying...
homestead-7: Warning: Remote connection disconnect. Retrying...
homestead-7: Warning: Connection aborted. Retrying...
homestead-7: Warning: Connection reset. Retrying...
homestead-7: Warning: Connection aborted. Retrying...
homestead-7: Warning: Remote connection disconnect. Retrying...
homestead-7: Warning: Connection aborted. Retrying...
==> homestead-7: Machine booted and ready!
==> homestead-7: Checking for guest additions in VM...
homestead-7: The guest additions on this VM do not match the installed version of
homestead-7: VirtualBox! In most cases this is fine, but in rare cases it can
homestead-7: prevent things such as shared folders from working properly. If you see
homestead-7: shared folder errors, please make sure the guest additions within the
homestead-7: virtual machine match the version of VirtualBox you have installed on
homestead-7: your host and reload your VM.
homestead-7:
homestead-7: Guest Additions Version: 5.0.18_Ubuntu r106667
homestead-7: VirtualBox Version: 5.2
==> homestead-7: Setting hostname...
==> homestead-7: Configuring and enabling network interfaces...
==> homestead-7: Mounting shared folders...
homestead-7: /vagrant => C:/Homestead
==> homestead-7: Running provisioner: file...
==> homestead-7: Running provisioner: shell...
homestead-7: Running: inline script
==> homestead-7: Running provisioner: shell...
homestead-7: Running: inline script
==> homestead-7: Running provisioner: shell...
homestead-7: Running: inline script
==> homestead-7: Running provisioner: shell...
homestead-7: Running: inline script
homestead-7: Unable to mount one of your folders. Please check your folders in Homestead.yaml
==> homestead-7: Running provisioner: shell...
homestead-7: Running: C:/Users/[user]/AppData/Local/Temp/vagrant-shell20180424-1628-11jxfyp.sh
==> homestead-7: Running provisioner: shell...
homestead-7: Running: inline script
==> homestead-7: Running provisioner: shell...
homestead-7: Running: inline script
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Creating Certificate: homestead.test
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Creating Site: homestead.test
==> homestead-7: Running provisioner: shell...
homestead-7: Running: inline script
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Checking for old Schedule
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Clear Variables
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Restarting Cron
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Restarting Nginx
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Creating MySQL Database: homestead
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Creating Postgres Database: homestead
==> homestead-7: Running provisioner: shell...
homestead-7: Running: script: Update Composer
homestead-7: You are running composer as "root", while "/home/vagrant/.composer" is owned by "vagrant"
homestead-7: You are already using composer version 1.6.4 (stable channel).
==> homestead-7: Running provisioner: shell...
homestead-7: Running: C:/Users/[user]/AppData/Local/Temp/vagrant-shell20180424-1628-1j2nixt.sh
==> homestead-7: Running provisioner: shell...
homestead-7: Running: C:/Users/[user]/AppData/Local/Temp/vagrant-shell20180424-1628-ltovu3.sh我见过这句话:
homestead-7: Unable to mount one of your folders. Please check your folders in Homestead.yaml它没有提供详细的信息。
D:/web/laravel和/home/vagrant/code都有相同的内容,但是我注意到,如果我创建一个随机文件,称之为D:/web/laravel/deleteme.txt,即使我重新加载了迷航器,它也不会显示在/home/迷航/代码中。
发布于 2018-04-27 17:28:21
您检查过是否启用了mod_rewrite吗?
另外,请查看您的公共目录。
<Directory "/path/to/your/directory">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>发布于 2018-04-25 21:52:09
我认为您需要对您的配置执行以下操作:
发自:
folders:
- map: D:/web/laravel
to: /home/vagrant/code至:
folders:
- map: D:/web/laravel/code
to: /home/vagrant/code发布于 2018-04-27 06:45:40
你在窗户上,对吧?
变化
folders:
- map: D:/web/laravel
to: /home/vagrant/code至
folders:
- map: D:\web\laravel
to: /home/vagrant/code如果您只有一个项目,则不使用--provision运行。
https://stackoverflow.com/questions/49908997
复制相似问题