Laradock - Localhost refused to connect on Windows 10 using Nginx - laravel

I have setup a laradock app on my local machine. I have followed the instructions as provided:
http://laradock.io/
In addition to that as I am on Windows 10, and using Docker toolbox, I have shared my folder with the laradock's workspace. That's working fine as I can see my app's folders inside the workspace when I run the following command
docker-compose exec workspace bash
I have also added a host entry inside my hosts file on windows.
127.0.0.1 localhost
But nothing works. I get a response 'localhost refused to connect'. Even css files inside public folder are not accessible

You should checkout the nginx/sites folder inside your laradock folder. Check the root path inside default.conf - root /var/www/public; should correspond to where your project /public folder actually is inside workspace.
I personally use laradock for many projects and create multiple .conf files that correspond to my sites name like myproject1.test - myproject1.conf and my file structure is like that:
/laradock
/myproject1
/myproject2
hosts file:
127.0.0.1 myproject1.test
127.0.0.1 myproject2.test
myproject1.conf inside nginx/sites:
...
server_name myproject1.test;
root /var/www/myproject1/public;
...
Hope that helps

Related

How to set up /etc/hosts to access a subfolder like it's a root folder (on a Mac)

I am setting up a new machine. I have it configured to use a Sites folder and localhost to access it. Using Apache, everything installed via Homebrew.
Sites folder
site1
site2
In the browser
localhost/site1/index.html
localhost/site2/index.html
That part works fine.
The problem is that site1 and site2 think localhost is the root folder (which it is) but I want them to think localhost/site1 and localhost/site2 are the root folders for those sites.
Is this something I can do with /etc/hosts or some other trickery?
It turns out this is a combination of /etc/hosts and Apache VirtualHosts. Here are the steps I took:
Establish the directories where you want to serve them from (this will become your DocumentRoot). In my case /Users/myusername/Sites/site1
Edit your /etc/hosts file to include your new "domain name" (this will become your ServerName). In my case site1.com
127.0.0.1 site1.com
::site1.com
Create an Apache Virtual Host ... there are different ways to go about this, but I used Homebrew to install Apache, so for me, there is a file here: /opt/homebrew/etc/httpd/extra/httpd-vhosts.conf. I copied the examples provided using DocumentRoot and ServerName as noted above.
Update this file /opt/homebrew/etc/httpd/httpd.conf to uncomment this line
Include /opt/homebrew/etc/httpd/extra/httpd-vhosts.conf
Restart Apache

laragon project: DNS address could not be found

I just installed laragon, on port 8080, because my port 80 is already used, and I can't access my project in "learnlaravel.test" but I can open my localhost localhost:8080.
Error:
This site can’t be reached. learnlaravel.test’s DNS address could not
be found. Diagnosing the problem
laragon
learnlaravel.test
Go in your project Directory via CMD
then Run command
php artisan serve
Menu -> Apache -> sites-enabled -> delete all (auto)
C:\Windows\System32\drivers\etc\hosts right click -> properties on hosts file and uncheck the "Read-only".
make sure auto virtual host is checked on laragon
restart laragon and try your project folder name inside in www with .test (or as specified in laragon setting) in the browser

laravel-8 storage accessing using docker

can't access images inside /public/storage
i have done php artisan storage:link
the files are visible when using my local environment but when switching to Docker environment with the same code, i can't access them (not found)
my files owner is the same as in my docker config
i test it by visiting http://127.0.0.1:8000/storage/test.png
where test.png is inside public/storage
I have 3 services inside my docker-compose file
Nginx
PHP
MYSQL
I think the problem from permissions but i can't figure out the solution
As far as I know, each docker has an IP address. So, you have to start the server with the IP address of docker container. However, to avoid errors from docker's dynamic IP address, you use 0.0.0.0 instead of the IP address of docker because 0.0.0.0 means all IPv4 addresses on the local machine. To resolve your issue, you use the following command in docker.
php artisan serve --host 0.0.0.0
Note:
Maybe you will get another error, let me know if you meet them.
if anyone faced the same issue.
i managed to solve this by removing the symlink created by laravel and make my own one from my nginx container based on the real path inside my container

How to deploy Laravel Project using Laradock

I have setup the local environment of the project using Laradock and pushed the images to a Amazon ECR.
Now I'm trying to deploy that in to a EC2 instance
My Issues are :
Once I pull the images to the EC2 from ECR, should I include docker-composer.yml file in side of laradock folder to the EC2 or can I run the images using "docker run" command ?
Should I add laradock folder to remote server ?
Once I pull the images to the EC2 from ECR, should I include docker-composer.yml file in side of laradock folder to the EC2 or can I run the images using "docker run" command ?
Yes you should add docker-compose.yml, because that is the file docker-compose uses to know what services exist. You should run docker-compose up <service1> <service2> <service3> ... -d and figure out if the configurations are working for you out of the box.
Should I add laradock folder to remote server ?
Yes this is where the specific images and configs are defined.

Hosts file redirect to local computer directory

I have a local Apache server running on my desktop which allows me to run a local site which I want to access from my laptop.
I'm able to access the computer in my hosts file using '192.168.0.5 liam.pc' but I can't figure out how to enter a directory. I've tried '192.168.0.5/Hudex/public hudex.dev' but it doesn't seem to work.
How can I accomplish the effect I want?
HOSTS file:
127.0.0.1 localhost
127.0.0.1 zheil.dev
192.168.0.5 liam.pc

Resources