I am running into a problem with Homestead. I have a piece of code that works well on an online dev server, but fails in the vagrant Homestead one.
The piece of code is an ajax executed one, where I upload an image, save it in a temp directory and send it back to the user, who then crops it. For this, I have two functions, tempUpload and tempCrop. It is failing in tempCrop, and most the line that triggers it is the following:
$img = getimagesize($imgUrl);
$imgUrl is an input with the url to an image in a temp folder. Checking in vagrant, I saw that these images have attributes -rwxrwxrwx 1 vagrant vagrant. The error appearing in the console is "SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data".
Again, this works perfect in an online version, so I guess it is either a permission problem or some environment setting. The permissions for the temp folder in vagrant are as following: drwxrwxrwx 1 vagrant vagrant
I have checked in /app/storage/logs, and the error I'm getting is:
'getimagesize(http://nominate.app:8000/temp/2078ec37e959dd733930ad758854ce4cb5f175de.jpg): failed to open stream: Connection refused'
I really don't know what else to look into, specially since it is working fine in another dev environment I have, running centOS.
Any ideas?
Thanks a lot.
The answer would be to put the path rather than the url into getimagesize.
Basically, as far as your virtual machine knows, it's serving on port 80. Vagrant seamlessly forwards this port to the host machine's port 8000. When you call getimagesize, it first tries to resolve the hostname (nominate.app), and, if successful, it tries to initiate a connection to it on port 8000. I'm guessing that nominate.app is configured to resolve to 127.0.0.1 (the VM), which isn't actually listening on port 8000.
It's a bad idea to perform those sorts of operations over HTTP, since it'll slow things down and potentially generate multiple temporary copies of the same image. You can use Laravel's path helpers to help you determine the local path of the image (i.e. getimagesize(public_path() . "/temp/" . $filename)).
Changing my host file to point homestead.app to the Homestead VM's IP of 192.168.10.10 rather than 127.0.0.1 resolved this very same issue. Additionally, I can now navigate to http://homestead.app rather than http://homestead.app:8000.
Thanks to ClarkF for pointing me in the right direction to get this resolved!
As much as we don't enjoy "it works in develop but not in production", it's even more curious when it works in production but not in develop!
Related
Actual state of art:
I need to expose my laravel app on internal lan, and sometime I need,or I close visual studio by mistake, so I moved the project on laragon, and everything is ok.
Need
During the test we have implemented some error_log() to debug some problems.
Problem
Actually I cannot read the printed error_log() or the http request, cause opening laragon terminal is like to be on the folder with the normal terminal, I cannot read the server running terminal.
What I want?
I would like to use laragon, and get access to the server instance console to read the logged data printed with error_log()
If you are running on Laragon just set your config to point to the public folder of your laravel. Give it the name of sitename.test or whatever. This will write a new line to your hosts file with the 127.0.0.1 IP. Then if you want others to view they will have to change their host file to
your computers ip addy sitename.test
Then open your firewall and let Laragon through on port 80 and port 3306 on your private network.
When starting XAMPP i suddenly got a new IP address. Instead of 192.168.64.2 I got 192.168.64.3. I have been looking for answers everywhere without a good advice what to do.
The biggest issue is that I can't go to my files that are on the 192.168.64.2. So what am I doing wrong or what solution is there to make XAMPP start next time on a specific IP address. I have also tried to make it start as localhost when changing in httpd.conf to Listen 127.0.0.1:80 without success!
I have also seen that some are saying that I might have xampp-vm. But as far as I know that should not be the issue.
I've been trying to get my head around this all day. I understand how to create and manage single level subdomains in laravel, such as subdomain.domain.com
However, I'm trying to add a second level subdomain, for example: subsubdomain.subdomain.domain.com
I can get Homestead working fine with single level subdomains, but whenever I add the extra subdomain, I get a connection refused - unable to connect error in chrome.
There's nothing in the nginx error log either.
This is what I've done:
Open `~/.homestead/Homestead.yaml
Add the domain subsubdomain.subdomain.domain.com in addition to subdomain.domain.com
Save and exit, then run vagrant reload --provision
I can see the new sub-subdomain added to the hosts file, as well as a conf file created in the vagrant box
When I try to access subdomain.domain.com it works fine, when I try to access subsubdomain.subdomain.domain.com it fails with refused to connect.
I have no idea what to try next, there's nothing in the nginx error log, Homestead is up and running because I can access the single level subdomain completely fine. The only one that isn't working is the second level subdomain.
Any info on what I might be doing wrong, or anything else that might be helpful to debug would be greatly appreciated.
Update
I've managed to connect to the server if I add the port :8000 to the address: subsubdomain.subdomain.domain.com doesn't work, but subsubdomain.subdomain.domain.com:8000 works
I'm using XAMPP, on Mavericks, to simulate a localhost. I set jobeet.local, for example, as my vhosts. I tried to access it on my computer, it worked as well.
Now, I want to test my website on an IPad. So, I did the following steps:
Run XAMPP server on port 80, as usual
Connect the IPad to my wifi network.
Setup Http Proxy on Ipad, as picture showed below but change the port to 80
Now, I tested to access 127.0.0.1 via IPad. It worked! However, jobeet.local doesn't work.
I have searched and tried many ways to achieve this issue but they don't work.
Could you help me figure it out?
Thanks in advance.
You might have to update the hosts file.
The hosts file is a text file that maps hostnames to IP addresses.
Upon typing a url address on the browser, the system is checking if there is a relevant entry on the hosts file and gets the corresponding IP address, else it resolves the IP via the active connection’s DNS servers.
The hosts file can be edited to block certain hostnames (like ad-serving/malicious hosts), or used for web development purposes, i.e. to redirect domains to local addresses.
Editing the hosts file
Editing the hosts file in Mac OS X – Leopard, is a pretty easy task, especially if you are familiar with the terminal.
Step 1 – Open the Terminal.app
Either by start typing Terminal on the Spotlight, or by going into Applications -> Utilities -> Terminal.
Step 2 – Open the hosts file
Open the hosts by typing on the Terminal that you have just opened:
$ sudo nano /private/etc/hosts
Type your user password when prompted.
Step 3 – Edit the hosts file
The hosts file contains some comments (lines starting with the # symbol), as well as some default hostname mappings (e.g. 127.0.0.1 – localhost).
Simply append your new mappings underneath the default ones. Or edit one of the default values if you know what you are doing!
You can navigate the file using the arrow keys.
Step 4 – Save the hosts file
When done editing the hosts file, press control-o to save the file.
Press enter on the filename prompt, and control-x to exit the editor.
Step 5 – Flush the DNS cache
On Leopard you can issue a simple Terminal command to flush the DNS cache, and have your host file changes to take immediate effect:
$ dscacheutil -flushcache
You can now test your new mapping on the browser!
Hope this works for you!
I had to reinstall my setup today and made a step by step at that occasion:
I use a combination of Squidman and Mamp Pro (I assume it's similar to XAMPP)—hope this help anyone in their quest; happy to read feedback or get advice to make this better...
Squidman http://squidman.net/squidman/index.html
Mamp Pro http://www.mamp.info/en/mamp-pro/
on Squidman
- Preferences > General > Http port:
something different from the one MAMP is using (if map uses 80, then put 8080)
Preferences > Clients > Provide proxy service for:
insert the IP address or the subnet we will be catering for
Start Squidman
on MAMP:
setup the hostname, as well as the the website attached
insert the (local) IP address of the local machine
insert the port of Apache on the local machine
start Mamp; check that website is running correctly on local machine
on iPad/iPhone/mobile device
select the same wireless network as the laptop
in Wifi network > Preferences/Information: set a Manual HTTP Proxy
server IP is the (local) IP address of the Apache server, also running Squidman; port is the port used for Squidman
(Extra)
stuff to test: move dev server onto virtual machine (VirtualBox), to use with Node, custom PHP build, etc.
automate the setting: write pref for Squidman, Mamp/hostname, restart the Apache server, send configuration of proxy to mobile via iMessage or email.
I recommend using http://xip.io/. For example (taken from the website):
10.0.0.1.xip.io resolves to 10.0.0.1
www.10.0.0.1.xip.io resolves to 10.0.0.1
mysite.10.0.0.1.xip.io resolves to 10.0.0.1
foo.bar.10.0.0.1.xip.io resolves to 10.0.0.1
It does the job and you don't have to set anything up. I'm only pushing it because I am overly excited that I have wasted time trying over-engineered solutions.
On a mac you can use Squid on Windows that's Fiddler, however I'm having troubles with Fiddler and iPhone at the moment...
Its been so long since i've needed to ftp something I seem to have forgotten how to do it.
(server address)I have got my ftp address
(password)I have got my password
(port)I have assumed the port is 20 or 21
I am using Filezilla and the above are the only information it requests.
I had connected it to localhost without any problems apart from it not showing the files that are stored in my htdocs folder (I had a look to see if i needed to direct to the folder but couldn't find anything to say that it was necessary) the port number for that was 14147. When I try to connect to a remote host I keep receiving errors saying maybe the port is incorrect or "Connected, waiting for authentication", I cannot leave the port option blank, I have tried 20, 21, 25, 80, 8080, 14147 and a couple of random ones after getting frustrated.
I have gone onto my provider and tried to find the port but cant seem to find the port they use for anything other than the emails, that was 25 and that is when i get the Connected, waiting for authentication message.
In short can someone please direct me to an idiots guide to FTP'ing, I know it should be quite straight-forward, but i'm really struggling. I have looked at a few tutorials but as it is such a straight forward job none seem to address my issue.
Please help (I assume what im trying to ftp doesnt make a difference?)
Little confusing to understand but if you need help setting up an ftp servers, heres how:
download and install Filezilla server(assuming this is done)
when it asks for what server leave it at default(host is 127.0.0.1
and port 14147)
set up a group. for this go to edit->groups and
hit add and name it.
now go to shared folders and select the
folder(s) you want this group to access along with what permissions
they need. Hit ok.
now set up a user in your group. Go to
edit->users
Click add, name the account(this will be your
username) and set the group
ensure the box labeled enable account
is selected and that you have a password set up.
hit ok to save
changes. Now try to connect through localhost using an FTP client.
if it works then continue on. If it does not work ensure that a
firewall is not blocking the server
set up port forwarding for
port 21(every router is different so try googling how to do this).
test by using your external ip address. Don't know it? try
whatismyip.com
That should be all you need to do for your new FTP server