Database migrating only working with 127.0.0.1 but access from website is localhost with homestead - laravel

I have a Homestead setup in Users/[username]/Homestead and setup a vagrant to run several websites and this is working fine.
ip: 192.168.10.10
memory: 2048
cpus: 2
provider: virtualbox
mariadb: true
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
-
map: '~/Sites/domain1'
to: /home/vagrant/domain1
-
map: '~/Sites/domain2'
to: /home/vagrant/domain2
sites:
-
map: domain1.app
to: /home/vagrant/domain1/public
-
map: domain2.app
to: /home/vagrant/domain2/public
databases:
- homestead
- domain1database
- domain2database
I am running the vagrant up and vagrant ssh from the Users/[username]/Homestead directory.
The problem relates to the migrations and then accessing the database from the frontend such as https://domain1.app and https://domain2.app.
For example the .env with the following settings allows migrations from /User/[username]/Sites/domain1.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=33060
DB_DATABASE=domain1database
DB_USERNAME=homestead
DB_PASSWORD=secret
But I can only access these databases frontend with the following.
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=33060
DB_DATABASE=domain1database
DB_USERNAME=homestead
DB_PASSWORD=secret
So at the moment I have to keep changing 127.0.0.1 and localhost.
Do the sites need to reside in the Homestead folder?

UPDATE/SOLUTION:
I have managed to sort the issue with these settings in the .env.
DB_CONNECTION=mysql
DB_HOST=192.168.10.10
DB_PORT=3306
DB_DATABASE=domain1database
DB_USERNAME=homestead
DB_PASSWORD=secret
The same above settings also works in Sequel Pro.

Related

Homestead gives error: No input file specified. on Windows 10

I'm running Homestead under Windows 10 using VirtualBox. For some reason, no matter what I try, I get this error:
I only found a single other question similar to my issues, and the resolution there resulted in an error when running vagrant up.
No input file specified.
My homestead.yaml file looked like this:
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox
folders:
- map: D:/code
to: /home/code
sites:
- map: homestead.test
to: /home/code/test/public
sites:
- map: info.test
to: /home/code/info/public
sites:
- map: food.test
to: /home/code/food/public
databases:
- homestead
- food
- info
features:
- mysql: true
- mariadb: false
- postgresql: false
- ohmyzsh: false
- webdriver: f
My hosts file is:
192.168.10.10 homestead.test
192.168.10.10 info.test
192.168.10.10 food.test
The folder mappings appear to be working. If I browse D:/code from the host I can see the Laravel
install under D:/code/test. I if put a file there on the host, it's visible from vagrant ssh.
What am I missing?
Try updating your Homestead.yaml file to this:
sites:
- map: homestead.test
to: /home/code/test/public
- map: info.test
to: /home/code/info/public
- map: food.test
to: /home/code/food/public
Maybe specifying "sites" multiple times is what's breaking it.
Have you tried logging in to your box with vagrant ssh and then doing flip to toggle between nginx and Apache?
See https://laravel.com/docs/8.x/homestead#web-servers

Problem to make a cluster with laravel and docker swarm using laradock

I recently started with docker and I have been following this steps to make a cluster with laradock
https://github.com/jarnovanleeuwen/laravel-dock
first I create with docker-machine 2 nodes, one manager and the other a worker
then with this comand I set the manager node as the leader
docker swarm init --advertise-addr 192.168.99.100
I add the other node as a worker with
docker swarm join
After I access the manager node with docker-machine ssh manager and create a service
docker service create --name registry --publish published=5000,target=5000 registry:2
I leave the virtual machine with exit and cd into the folder laravel-dock, then I up the containers to create the images with
./dock up
then I set it down
./dock down
I build the image with
./dock build
Then i push it into the service I created with
./dock push
The push refers to repository [192.168.99.100:5000/registry]
Get https://192.168.99.100:5000/v2/: http: server gave HTTP response to HTTPS client
With this I try to deploy the stack with
./dock deploy
Are you sure you want to deploy [192.168.99.100:5000/registry:web] to [docker#192.168.99.100]? (y/N) y
Uploading deployment configuration...The authenticity of host '192.168.99.100 (192.168.99.100)' can't be established.
ECDSA key fingerprint is SHA256:r1F+7kuet+grlysNruBECAmYpRVVlvORYhAR4ipNFco.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.99.100' (ECDSA) to the list of known hosts.
docker#192.168.99.100's password:
docker#192.168.99.100's password:
OK
docker#192.168.99.100's password:
./dock-swarm: line 4: .env: No such file or directory
it request the password for the machine that is "tcuser" and come with this error ".env: No such file or directory", so I manually copy the .env to this folder created in the manager node with
docker-machine scp -r .env manager:/home/docker/laraveldock
I try to deploy again and have this error
sudo ./dock deploy
Are you sure you want to deploy [192.168.99.100:5000/registry:web] to [docker#192.168.99.100]? (y/N) y
Uploading deployment configuration...docker#192.168.99.100's password:
docker#192.168.99.100's password:
OK
docker#192.168.99.100's password:
Top-level object must be a mapping
And at this point I have stuck with this error, am I doing something wrong in this steps? also here is the configurations
.env
APP_ID=laraveldock
DEPLOY_SERVER=docker#192.168.99.100
DOCKER_REPOSITORY=192.168.99.100:5000/registry:web
REGISTRY=localhost:5000
REGISTRY_USER=docker
REGISTRY_PASSWORD=tcuser
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:25q1JJ78zFzeGYOBIyIndCmuSJBOCaezyW2utE7hE3Y=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_DATABASE=laraveldock
DB_USERNAME=root
DB_PASSWORD=secret
REDIS_PASSWORD=rediz
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
DB_DATABASE=laraveldock
DB_USERNAME=root
DB_PASSWORD=secret
REDIS_PASSWORD=rediz
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
docker-compose.yml
version: '3.7'
# Volumes
volumes:
mysql:
driver: local
redis:
driver: local
services:
# Apache + PHP
app:
environment:
- CONTAINER_ROLE=app
- DB_HOST=db
- DB_PORT=3306
- REDIS_HOST=redis
- REDIS_PORT=6379
env_file: ../.env
ports:
- "80:80"
# Scheduler
scheduler:
user: webdev
environment:
- CONTAINER_ROLE=scheduler
- DB_HOST=db
- DB_PORT=3306
- REDIS_HOST=redis
- REDIS_PORT=6379
env_file: ../.env
# Queue worker
queue:
user: webdev
environment:
- CONTAINER_ROLE=queue
- DB_HOST=db
- DB_PORT=3306
- REDIS_HOST=redis
- REDIS_PORT=6379
env_file: ../.env
# MySQL
db:
image: mysql:5.7
command: ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]
environment:
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
- MYSQL_DATABASE=${DB_DATABASE}
ports:
- "3306:3306"
volumes:
- mysql:/var/lib/mysql/
# Redis
redis:
image: redis:5.0
command: ["redis-server", "--appendonly", "yes", "--requirepass", "${REDIS_PASSWORD}"]
I spent an hour on this bug. In my case problem was caused by missing docker-compose on remote server.

Create new native php project in homestead box

I want to create new project (not a laravel project) in homestead box. I have edited homestead.yaml but when i access on the web browser, it is always routed to the laravel project instead of the map i 've added to homestead.yaml. Here is the conf :
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
mariadb: true
authorize: c:/Users/Fauzan/.ssh/id_rsa.pub
keys:
- c:/Users/Fauzan/.ssh/id_rsa
folders:
- map: d:/Projects/Homestead
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
- map: belajarphp.lol
to: /home/vagrant/Code/Belajarphp/
databases:
- homestead
- belajarphp
I go to 192.168.10.10/belajarphp still directed to the laravel project.
I have added "192.168.10.10 belajarphp.lol" and opened in web browser still directed to laravel project.
I don't have any idea
solved this by destroy vagrant and rebuilt from stractch

Cannot get Homestead and Laravel working

I am getting 403 Forbidden when going to homestead.app but it works with homestead.app/public
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Desktop
to: /home/vagrant/Desktop
type: "nfs"
sites:
- map: valiant.dev
to: /home/vagrant/Desktop/Laravel
databases:
- homestead
Any help with this would be greatly appreciated, I am about to give up and go back to codeigniter.
Update your homestead.yaml file on .homestead folder to this
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Desktop/Code
to: /home/vagrant/Code
sites:
- map: valiant.app
to: /home/vagrant/Code/public
databases:
- homestead
Mapping folders syncing
folders:
- map: ~/Desktop/Code
to: /home/vagrant/Code
This means that we are going to sync the Desktop/Code folder and /home/vagrant/Code folder so that files are updated on both folders.
Mapping website
sites:
- map: valiant.app
to: /home/vagrant/Code/public
This means whenever you are going to hit valiant.app folder it will check /home/vagrant/Code/public path
Updating Hosts
When you have successfully configured the above one, do vim /etc/hosts and add the following line to the file
192.168.10.10 valiant.dev
Reloading Vagrant
Once you have done all the above mentioned tasks, cd into the Homestead directory on home folder and do the following
vagrant reload --provision
above command will create(if doesn't exist already) on vagrant machine and map them according. Now do
vagrant up
That should get you working.

403 Forbidden nginx/1.6.2 on Laravel Homestead installation

I'm out of ideas about what I can do to finish my Laravel Homestead install.
Some infos :
laravel/homestead (virtualbox, 0.2.4)
vagrant base is lucid32. I can't use the serve command with SSH.
Here is my homestead.yaml :
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: /Users/bolos/base
to: /home/vagrant/base
sites:
- map: homestead.app
to: /home/vagrant/base/homestead/public
databases:
- homestead
variables:
- key: APP_ENV
value: local
provider: virtualbox
# blackfire:
# - id: foo
# token: bar
I don't know what else I can provide to help, but feel free to ask.
Thank you in advance.
According to your configuration you must replace:
to: /home/vagrant/base/homestead/public
with:
to: /home/vagrant/base/public
And this should work if you have Laravel on /Users/bolos/base.

Resources