Homestead访问站点报错“No Input File Specified”技术求助
Hey there, fellow Homestead newbie! Let's work through that frustrating "No Input File Specified" error—this is one of the most common hiccups when you're setting up your first box, so you're definitely not alone.
From what you've shared, the core issue is almost always a mismatch between your folder mappings, site root configuration, or a missing provision step. Let's break down the fixes step by step:
1. Fix Your Homestead.yaml Configuration
Your current config cuts off at the folders section, which is probably where the problem starts. You need to make sure both folders and sites are properly mapped to your project.
Correct Folder & Site Mapping
Map your local project root (not just the public folder) to a path inside the Vagrant box, then point your site directly to the public directory:
ip: "192.168.10.10" memory: 2048 cpus: 1 provider: virtualbox authorize: ~/.ssh/id_rsa.pub keys: - ~/.ssh/id_rsa folders: - map: C:\Code\php_projects\TestFolder\TestProject to: /home/vagrant/code/TestProject # Where your project lives inside the VM sites: - map: testproject.test # Local domain to access your site to: /home/vagrant/code/TestProject/public # Explicitly point to the public folder
2. Update Your Local Hosts File
You need to link the domain from your sites config to Homestead's IP address. On Windows, edit C:\Windows\System32\drivers\etc\hosts (run your editor as administrator) and add this line:
192.168.10.10 testproject.test
3. Reload Vagrant with Provisioning
After changing Homestead.yaml or the hosts file, you must reload the box and apply the new config—this is a step lots of new users miss! Run this command in your terminal (from the folder where your Homestead files are stored):
vagrant reload --provision
4. Verify File Permissions (Just to Be Safe)
Sometimes the VM can't read your files due to permission issues. First, SSH into the box:
vagrant ssh
Then run these commands to set the right permissions for your public folder:
sudo chown -R www-data:www-data /home/vagrant/code/TestProject/public sudo chmod -R 755 /home/vagrant/code/TestProject/public
5. Double-Check Your index.php
Make sure the file actually exists in the right place inside the VM. From the SSH session, run:
ls /home/vagrant/code/TestProject/public
You should see index.php listed. If not, double-check your folder mapping in Homestead.yaml—it might be pointing to the wrong local path.
Once you've gone through these steps, try accessing http://testproject.test in your browser again. That should resolve the "No Input File Specified" error!
内容的提问来源于stack exchange,提问作者Fred

