Laravel homestead: "No input file specified" - laravel

This is the output I get when entering my local site.
I'm using Windows and running Homestead with Vagrant on it. This is my homestead.yaml file:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: D:/web/laravel
to: /home/vagrant/code
sites:
- map: laravel.test
to: /home/vagrant/code/public
databases:
- laravel
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
As you see, I opted for a global homestead installation, in my user folder, mapping Laravel to a path in a secondary drive.
None of these solutions I found worked for me:
vagrant up --provision
vagrant provision
Any help appreciated!

My global Homestead installation did not work, but my per project installations are OK.
Per project set up is preferred; we are able to tweak each project independently if and when we need to.
I lost two weeks due to 'no iput file specified' (at global installation). Yet the per project process is easy.
The following video more than helped me: https://www.youtube.com/watch?v=rs2Hzx4qBm8
Further let me use terms "host" (the machine) and "guest" (Homestead virtual machine, VM).
This sure works as described with versions:
Ubuntu 18.04, Virtualbox 5.2.18, Vagrant 2.1.5, Composer 1.7.2 - host.
Laravel Homestead 7.17.0, Laravel Installer 2.0.1 (Laravel 5.7) - guest.
Have Vagrant, Virtual Box (you can install the two per https://laravel.com/docs/5.7/homestead), as well as Composer installed on the host,
cd where you wish to keep Laravel sites, then mkdir LaravelSites, cd LaravelSites and then
composer create-project --prefer-dist laravel/laravel petrTest (it takes time), to create the project (and add plenty packages), and then cd petrTest and ls to review it; I guess in this step I remember adding mbstring and perhaps one or two more packages per requests on terminal by hand (sudo apt install thePackage) for my first homestead project into my host,
composer require laravel/homestead --dev, to add homestead and yaml packages to the project,
vendor/bin/homestead, to run Homestead, so to install it into your project run vendor/bin/homestead make, and view your project (note you have just added Vagrantfile and mainly Homestead.yaml),
nano Homestead.yaml, review, and exit keeping it intact for your first project,
ssh-keygen -t rsa -C "madeUp#email.com", Enter, file (keep_suggested_file): Enter, Overwrite the current file?: y, passphrase: Enter, passphrase again: Enter,
vagrant up (it takes time and computing resources), then vagrant ssh to switch to your guest (VM), cd code, then ls; and in /home/vagrant/code of your guest you can see those same files that are in /home/petr/LaravelSites/petrTest of your host (the two directories are synced),
logout to leave the guest for the host, sudo nano /etc/hosts, then append 192.168.10.10 homestead.test to the bottom and make sure to Write Out the changes. Then in the browser: homestead.test, Enter. You should see the Laravel web.
Alternatively you can follow the nice and easy video, too.

Related

Laravel homestead 502 bad gateway

Everytime i go to my project I get a 502 bad gateway. When I refresh, the page works.. If I click a link to another page I get 502 bad gateway again. After the refresh the page loads. What could be the problem here.
Homestead.yaml
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: c:/Users/MyNameHere/.ssh/id_rsa.pub
keys:
- c:/Users/MyNameHere/.ssh/id_rsa
folders:
- map: c:/Users/MyNameHere/Desktop/sites
to: /home/vagrant/code
sites:
- map: spa.test
to: /home/vagrant/code/spa/public
databases:
- homestead
Got the latest version for virtualbox and vagrant.
My spa folder contains the newest version laravel.
Login to Laravel Homestead Server with PuTTY and Private Key File.
then...
cd /etc/php/7.4/mods-available
sudo nano xdebug.ini
Comment out the first line
;zend_extension=xdebug.so
xdebug.remote_enable = 0
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.max_nesting_level = 512
Then restart PHP-FPM
sudo service php7.4-fpm restart
Had the same issue with the latest version of homestead.
After digging in log files and then github issues for homestead, I found this this.
There's an issue with xdebug that they're waiting for a fix for. The solution is to disable xdebug or use php 7.2. I opted for the latter. In that case, make the following change in your homestead.yaml and then running vagrant reload --provision will fix this.
sites:
- map: spa.test
to: /home/vagrant/code/spa/public
php: "7.2"
I was having the same problem and I couldn't change the PHP version or disable xdebug, but I could and did change for the Apache server.
sites:
- map: spa.test
to: /home/vagrant/code/spa/public
type: "apache"
I had a similar issue, got the 502 error. Refreshing the browser or reloading the virtual machine had no effect.
I solved disabling the Xdebug. Found the solution here: https://christattum.com/disabling-xdebug-in-laravel-homestead/
On prompt:
cd /etc/php/7.4/mods-available
sudo vi xdebug.ini
Commented all the lines of the file with ;
Run the vagrant reload --provision command to the Homestead file in the virtual machine, and then after vagrant up, enter with vagrant ssh. Your problem will be solved :)
You can change your ip post adress and write 127.0.0.1 in your host file.
You can enter it by adding 8000 next to the project name in the search engine.
For example spa.test:8000 and then running vagrant reload --provision will fix this.
I lost 3 days trying to solve the same issue.
My mistake was to have defined in my host file something like:
127.0.0.1 spa.test
The solution is to add instead, the same IP you specified in Homestead.yaml.
192.168.10.10 spa.test
to /etc/host (In case of Mac)
to C:\Windows\System32\drivers\etc\hosts (in case of Windows)
Even if you have multiple hosts defined in your global Homestead.yaml file.
For instance
folders:
- map: /Users/davidecasiraghi/Projects/my_laravel_project
to: /home/vagrant/code/my_laravel_project
- map: /Users/davidecasiraghi/Projects/spa
to: /home/vagrant/code/spa
sites:
- map: my_laravel_project.test
to: /home/vagrant/code/my_laravel_project/public
- map: spa.test
to: /home/vagrant/code/spa/public
Then in the host file:
192.168.10.10 spa.test
192.168.10.10 my_laravel_project.test
Then when you will do vagrant up you will be able to access to both of them.
For me this was related to Xdebug, which doesn't seem to yet be compatible with PHP 7.3.
To continue using 7.3, you can turn Xdebug off with
sudo phpdismod xdebug
restart php service
sudo service php7.3-fpm reload
For Chinese,
if you are using Clash for Windows,
then edit "Bypass Domain".
It's not relevant to this question,
but Google lead me here,
Do this inside your Homestead VM vagrant ssh
Check your php version
$ php -v
Edit your website config file
$ sudo nano /etc/nginx/sites-available/<laravel.app>
line
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
change according to your php version
mine was php8.2-fpm.sock; then I change it to php8.1-fpm.sock; press ctrl+x to save, then
$ sudo service nginx restart
$ sudo service php<ver>-fpm restart
reload the page

Configure Laravel environment just once and use it for further app developments

I am pretty new to Laravel and just started with development of my first application in the framework. I had started learning it a while ago and faced n number of issues while configuring the test application. It had been a long time and I can't find all the notes I had made while I faced issues.
So my problem is this time I want to configure my environment and create a package or a container so that I get it up and running next time when I want to develop more apps in future. Is there any way to achieve it?
If you want a clean and complete development environment for laravel and spare yourself of configuring everything on your local OS and Be able to have the same configuration somewhere else on another machine, I'd recommend using homestead which you can find it's documentation Here.
Steps are easy you basically install vagrant and VirtualBox or VMWare. (I recommend VirtualBox). Then install homestead by following the Per Project Installation section of the docs and you're gonna have a Homestead.yaml file in your laravel installation. Which is going to look something like this :
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
hostname: myhost
name: myhost
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: "/Path/To/Project/myapp"
to: "/home/vagrant/myapp"
sites:
- map: my.app
to: "/home/vagrant/myapp/public"
databases:
- mydatabase
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 50000
# to: 5000
# - send: 7777
# to: 777
# protocol: udp
Edit this file to your settings and save it for future use. Then just add my.app *Your.Ip.Add.ress* to your OS hosts file which you're gonna find the guide on how to do that in the docs as well.
Finally run vagrant up in your project root and have everything setup!
Just type my.app or whatever you set it up to be and your laravel website comes up.
You can ssh to this virtual server installation with vagrant ssh command.
Database username is homestead and password is secret by default. you can change all of this yourself in the virtual server.

Laravel Homestead (Windows)

Today I have been trying to install the Laravel library together with Laravel Homestead.. But I can't seem to get it working.
The first thing, Laravel documentation tells you to do: composer global require "laravel/homestead=~2.0", but it didn't work.
So I searched the internet some and found: composer global require "laravel/homestead=~3.0", which actually worked.
But now when I try to run the homestead command in my command line, it gives me this: http://prntscr.com/9perhj, that's the only thing it's giving me.
I have added the directory to my path variable.
I hope someone can help me.
Thanks in advance!
Homestead itself command will return this expected screen. You would need to pass the command you want to run.
At first, run homestead init so that it will create the Homestead.yaml configuration file
This is an old question but I thought I'd put up my answer since it took me multiple tries to get it right and I documented the process while I was doing it so I wouldn't have such a hard time in the future.
Note: You should NOT have NginX, PHP, MySQL, etc. installed on your machine. The Vagrant Homestead virtual box provides all of this functionality. I had some issues where I had NginX and MySQL on my machine and it was connecting to my local machine's MySQL when it should be connecting to the virtual box's MySQL.
Without further ado, this is how I set it up for my Windows 7 machine:
Prerequisites:
VirtualBox:
https://www.virtualbox.org/wiki/Downloads
Vagrant:
https://www.vagrantup.com/downloads.html
Git Bash: A terminal that feels like a Linux terminal. You can do everything you do on an Ubuntu server in Windows.
https://git-scm.com/downloads
Putty: Telnet client that I used for connecting to my VirtualBox Homestead server
http://www.putty.org/
create project folder
open terminal in project folder (something like E:\Projects\Vagrant)
type 'vagrant box add laravel/homestead'
type 'git clone https://github.com/laravel/homestead.git Homestead'
This installs Homestead in the designated project folder.
type 'cd Homestead'
type 'bash init.sh' OR 'init.bat'
This creates a folder in:
C:\Users\USERNAME\.homestead
which has the file:
Homestead.yaml
If you open the Homestead.yaml file it should look something like this:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Code
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
databases:
- homestead
The '~/' folder is the equivalent of:
C:\Users\USERNAME\
Change:
folders:
- map: ~/Code
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
To:
folders:
- map: E:/Projects/Vagrant/Homestead
to: /home/vagrant/Homestead
sites:
- map: WEBSITE.dev
to: /home/vagrant/Homestead/Laravel/public
goto C:\Windows\System32\drivers\etc
open the file 'hosts' in a text editor
add '192.168.10.10 WEBSITE.dev' (the IP address should match the IP address in the Homestead.yaml file)
open a terminal in E:/Projects/Vagrant/Homestead folder
type 'ssh-keygen -t rsa -C "USERNAME#gmail.com"'
This creates the folder C:\Users\USERNAME.ssh and sets up your SSH Key
type 'vagrant init laravel/homestead'
type 'vagrant up'
You should see Homestead running in VirtualBox
You can use 'vagrant destroy' to kill it when done
Use putty.exe to log in to Homestead
IP Address: 127.0.0.1
Port: 2222
login as: vagrant
password: vagrant
Everything is now ready

How to setup Laravel Homestead server to run locally without being on a network/internet?

Previously, I manually setup my own VM on VirtualBox and configured it so it would also work when I'm coding offline (no internet/not connected to a router). I did this using settings in the VirtualBox GUI and also in Apache on the VM.
Now I'm interested in learning nginx and I've decided to try and use Laravel's Homestead. The tutorials I'm looking at seem to have the assumption I will be accessing the Homestead VM across the network (even though of course it's on the same PC). What do I need to do to ensure the VM will be accessible when I'm offline (like when I'm coding on a plane or train)? I'd like to still be able to have access to the internet from the VM whenever I do get back on WiFi (ie. for apt-get, etc.).
(note: My host machine is running Windows 7 64-bit)
Download and install fresh copies of Vagrant and Virtualbox.
https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2.msi
http://dlc-cdn.sun.com/virtualbox/4.3.22/VirtualBox-4.3.22-98236-Win.exe
Also download laravel/homestead manually
https://vagrantcloud.com/laravel/boxes/homestead/versions/0.2.2/providers/virtualbox.box
to my downloads folder C:\Downloads\homestead-0-2-2.box
After Installing Virtualbox and Vagrant. Installed laravel/homestead by running the following command in git bash (you can download git bash here: http://git-scm.com/downloads).
vagrant box add laravel/homestead /c/downloads/homestead-0-2-2.box
Run this command inside C:\users\yourusername
git clone https://github.com/laravel/homestead.git Homestead
NB: This will create this folder: C:\Users\yourusername\Homestead
With some files.
Still in Git bash, cd into C:\Users\yourusername\Homestead and run this command:
bash init.sh
NB: this will create a folder C:\Users\yourusername\.homestead that contains Homestead.yaml and some other files
Then Generate an SSH key which you will need when you want to login to your VM by running this command:
ssh-keygen -t rsa -C "youremailaddress#youremail.com"
NB: This will ask some question simply hit enter or type yes and hit enter.
This will create your ssh key inside C:\Users\yourusername\.ssh
Then you need to configure homestead by editing for Nginx
C:\Users\digitlimit\Homestead\Homestead.yaml
You can right-click Homestead.yaml file then click open then choose to open with wordpad.
My Homestead.yaml looks this after editing:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: /wamp/www
to: /home/vagrant/Code
sites:
- map: laravel.dev
to: /home/vagrant/Code/laravel/public
databases:
- homestead
variables:
- key: APP_ENV
value: local
# blackfire:
# - id: foo
# token: bar
NB: To understand the mapping which is a process of sharing a folder between the host and the VM:
My laravel project is located at C:\wamp\www\laravel
This directory /home/vagrant/Code will be inside the VM after installation.
So what am telling VM is, whenever you see /home/vagrant/Code reference this folder C:\wamp\www\laravel
Also in this:
sites:
- map: laravel.dev
to: /home/vagrant/Code/laravel/public
What we are saying here is when i go to my browser and type http://laravel.dev display the content of /home/vagrant/Code/laravel/public which is actually pointing to C:\www\wamp\laravel\public
After editing Homestead.yaml file save your chnages
NB: Before we can use http://laravel.dev in the host web browser to view our laravel project, we need to add this the following to the hosts file located in
C:\Windows\System32\drivers\etc\hosts
Add this ip address under the list of other ip address listed if any:
192.168.10.10 laravel.dev
Finally, go back to your Git bash, ensure you are in
/c/Users/yourusername/homestead and type:
vagrant up
Wait for vagrant to complete its processes. Click yes when you see any dialog box asking for permission to create network adapter on your system
Any VM running on your development machine will be accessible when you're offline. Just make sure you setup your development machine's host file to have the VM's location set.
If you're following the Laravel Homestead Setup:
In scripts/homestead.rb, you'll have a line that has the IP Address of the VM.
# in scripts/homestead.rb
# Configure A Private Network IP
config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.10"
Add this IP address into to your hosts file. This is located usually in C:\Windows\System32\drivers\etc\hosts
#in hosts file
192.168.10.10 yourwebsite.dev

Laravel Homestead 2.0 Adding New Sites

Homestead 2 is awesome, but I can't seem to get new sites to work without going through the following process.
I do homestead edit to setup the new site paths and domains etc
I edit hosts to set up the domain
I do homestead halt then homestead up to restart
This is when I think things should be working... but they don't. I have to run the additional step of
Running vagrant global-status getting the id and running vagrant provision <id>.
Everything works except running provision again wipes out all the databases! How do I add new sites without having to provision again?
Instead of step 3 use vagrant provision in your homestead directory (~/.composer/vendor/laravel/homestead/).
As I know Taylor is already planning a "provision" flag, until that you can feel free to use vagrant commands.
this works for me
homestead halt && homestead up --provision
Here is my ~/homestead/.Homestead.yaml file, it contains a configuration for two apps, one with HHVM enabled and one with HHVM disabled(default in homestead).
Homestead will create the database for you in MySQL and PostgreSQL server, when running homestead up.
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Projects
to: /home/vagrant/Projects
sites:
- map: jobs.app
to: /home/vagrant/Projects/jobs/public
- map: messages.app
to: /home/vagrant/Projects/messages/web
hhvm: true
databases:
- jobs
- messages
variables:
- key: APP_ENV
value: local
You can now run:
$ homestead up
and then:
$ homestead ssh
and then run byobu(for tmux):
$ byobu
and cd into the project:
$ cd Projects/jobs
and run composer:
$ composer update

Resources