I recently migrated to Mac OSX Yosemite 10.10 and I followed this tutorial.
To set up my machine, After a lots of hiccups I finally managed to reach a point where I find just a single issue happening due to nginx port issues.
If I do
sudo nginx
I get this
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] still could not bind()
which means 443 and 306 ports are being used somewhere else
and when I do
sudo lsof -i:443
I get this
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 548 root 13u IPv4 0xce9cf564560ec22b 0t0 TCP *:https (LISTEN)
nginx 549 nobody 13u IPv4 0xce9cf564560ec22b 0t0 TCP *:https (LISTEN)
similarly for sudo lsof -i:306
I get
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 548 root 14u IPv4 0xce9cf564560ed3cb 0t0 TCP *:306 (LISTEN)
nginx 549 nobody 14u IPv4 0xce9cf564560ed3cb 0t0 TCP *:306 (LISTEN)
Now if nginx is already using these ports, how come it is claiming that Address is already in use
and when I run my app in browser say abc.dev.com
I get no response from server, after sometime browser simply tells me
The connection has timed out
The server at abc.dev.com is taking too long to respond.
If i do curl http://abc.dev.com I get
curl: (7) Failed to connect to abc.dev.com port 80: Operation timed out
Also If I do
nginx.start
I get this:
/Library/LaunchDaemons/homebrew.mxcl.nginx.plist: Operation already in progress
if I do::
nginx.stop //it works, I think it stops
if I do:
nginx.restart
I get this:
/Library/LaunchDaemons/homebrew.mxcl.nginx.plist: Could not find specified service
I have ran out of ideas and can't think of anything that could be causing this. Any Ideas are highly appreciated...
Thanks for the help.
Author of the guide you've linked above here. It seems like you managed to get Nginx running without the proper LaunchDaemon.
Can you make sure, when you enter "nginx.stop", the process is really stopped? (ps aux).
Regarding the last error while "nginx.restart": thats normal, because you already stopped the service before with "nginx.stop". So a restart (actually: stop && start) will come up with the error since it's trying to stop an already stopped service.
Anyway, since your issue is pretty much guide-dependent / relevant, I'm not sure if StackOverflow is the right place for this discussion. Let's better continue in the comment section of the guide.
Related
I am having issues with setting up Laravel Valet on my machine (MacOS Mojave 10.14). I followed the official documentation on Laravel documentation site. I have installed Valet, added Composer to path, I can run valet and laravel commands from anywhere in the system so that works. I have mapped my project folder with valet park. I can also do a ping on any *.test domain and it returns 127.0.0.1 responses.
I have created a new project laravel new blog within that directory and when accessing http://blog.test I am getting nginx 403 forbidden response.
I suspect something may conflict maybe so I tried these steps, none of which worked:
Added explicitly both blog and blog/public to valet link blog and valet link blog2. Accessing blog.test and blog2.test both return forbidden
Killing Apache with sudo apachectl stop returns:
/System/Library/LaunchDaemons/org.apache.httpd.plist: Could not find specified service
sudo killall httpd returns:
No matching processes were found
Uninstalling nginx and running valet install again didn't help.
Running sudo nginx returns:
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] still could not bind()
NOTE: I do have a Docker running on my machine
I have found Docker to be the issue. I already had an app running on port 80 so it was preventing nginx from starting. I shut down the container and run sudo nginx and it solved the issue.
Having a terribly frustrating time not having valet working on a fresh install. Going to any *.test site in my browser just hangs and eventually gets the error message This site can’t be reached, "ping app.test" hangs as well, and eventually errors with "ping: cannot resolve app.test: Unknown host". However pinging a different domain (such as ping.xyz errors immediately, as opposed to after ~20 seconds like with *.test).
On Os Sierra, my composer.json looks like the following
{
"require": {
"laravel/installer": "^1.5",
"laravel/valet": "dev-master"
}
}
Since I've seen that dev-master resolved this for some people. All my processes seem to be running:
However some clues are that http://localhost/ in my browser returns a page 404 - not found, and running sudo nginx returns a bunch of already in user errors:
❯ pwd
/Users/schorr/.valet
schorr#Andrew-Schorr ~/.valet
❯ sudo Nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
and valet fetch-share-url returns
❯ valet fetch-share-url [17:04:53]
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
...
Any help is greatly appreciated. thanks!
Finally figured this out, for anyone else in my very specific situation:
I had changed my user name on the same machine, and for whatever reason installing dnsmasq wasn't overwriting the old /Users/user/.valet/dnsmasq.conf file. So at the very bottom I had:
conf-file=/Users/OLD_USER_NAME/.valet/dnsmasq.conf
conf-file=/Users/NEW_USER_NAME/.valet/dnsmasq.conf
So all I had to do was comment out the OLD_USER_NAME line and was good to go :|
Append http:// to the url the first time you hit it. For example use http://websitedir.test
I hope it's this simple, let me know.
Try the command 'valet paths' and let me know what that spits out.
I've searched a lot about this but none of the solutions I encountered helped.
First time using Wampserver with Apache and PHP and my localhost displays:
403 Forbidden.
Forbidden
You don't have permission to access / on this server.
Apache/2.4.33 (Win64) PHP/5.6.35 Server at localhost Port 80
Also when I run httpd via cmd it shows:
C:\apache\bin>httpd
(OS 10048)Only one usage of each socket address (protocol/network
address/port) is normally permitted. : AH00072: make_sock: could not bind
to address [::]:80
(OS 10048)Only one usage of each socket address (protocol/network
address/port) is normally permitted. : AH00072: make_sock: could not bind
to address 0.0.0.0:80
AH00451: no listening sockets available, shutting down
AH00015: Unable to open logs
I uninstalled Skype because I saw it might have problems with port 80.
I've tried to Allow access all granted in httpd docs but didn't work.
Any ideas?
You need to go into Apache and change all port from 80 to 8080.
I'm trying to connect my port 7979 to nginx and it doesn't work.
I was on localhost:7979/myproject/app/index.php but when I restarted my mac and I updated it, I now see the error message:
ERR_CONNECTION_REFUSED
When I try sudo nginx I see the following messages.
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] still could not bind()
Port 80 is functioning. If I go to localhost:80 I see this message in the html page:
Default website Congratulations, your Nginx seems to work just fine.
:)
Why am I unable to use port 7979?
I changed the root and the port and it worked on site-available/default.
The root by default wasn't good i don't know why it changed when i restarted my mac.
THan
It's difficult to troubleshoot with this little info available. So first:
An error message like nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use) indicates that something is already listening on port 80 and hence nginx can't do that as well when you start it.
Assuming your configuration files are perfectly ok, you'll have to figure out what is already listening on ports 80, 443 and 306. It might be an instance of nginx that's running with an older configuration but without much more details thats' just a guess.
See what processes are running:
$ ps -ax
See if there's an nginx instance running:
$ ps -ax | grep nginx
Netstat can give you what ports are being listened to:
$ nestat -an | grep LISTEN
To find out which process is listening to a given port:
$ sudo lsof -i :631
(631 is just an example)
What I suspect: you're starting nginx while it's already running. If it's already running, you should restart it instead of starting a new copy.
This might be of help: https://serverfault.com/questions/225948/how-to-restart-nginx-on-mac-os-x
In essence:
$ sudo nginx -s reload
Just a warning I don't run nginx on macOS, but it should work if nginx on macOS reacts like it does on FreeBSD (which macOS uses as a long distant base)
I have a Heroku PHP project in my local directory in Xubuntu 14.04 machine.
I want to run it locally in order to develop/test it before deploying on Heroku.
First of all, I've tried to cd into project directory and ran foreman start web.
There were errors related to some missing packages and PHP version so I did the following:
1). Installed latest PHP version from custom PPA (ppa:ondrej/php5):
php --version
PHP 5.5.18-1+deb.sury.org~trusty+1 (cli) (built: Oct 17 2014 15:20:47).
2). Created a symlink for php5-fpm binary:
sudo ln -s /usr/sbin/php5-fpm /usr/local/bin/php-fpm
3). Installed nginx.
4). Changed the Procfile:
web: vendor/bin/heroku-php-nginx /web
Next, I'm trying to start the server using: foreman start web command and I'm getting the following output:
02:38:23 web.1 | started with pid 15815
02:38:23 web.1 | Booting on port 5000...
02:38:23 web.1 | DOCUMENT_ROOT changed to '/web/'
02:38:24 web.1 | Starting php-fpm...
02:38:24 web.1 | Starting nginx...
02:38:24 web.1 | [06-Nov-2014 02:38:24] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
02:38:24 web.1 | [06-Nov-2014 02:38:24] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
02:38:26 web.1 | nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
02:38:26 web.1 | 2014/11/06 02:38:26 [warn] 15897#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
02:38:26 web.1 | 2014/11/06 02:38:26 [emerg] 15897#0: open() "/var/log/nginx/access.log" failed (13: Permission denied)
02:38:26 web.1 | Process exited unexpectedly: nginx
02:38:26 web.1 | Going down, terminating child processes...
02:38:26 web.1 | vendor/bin/heroku-php-nginx: line 282: 15891 Terminated tail -qF -n 0 "${logs[#]}"
02:38:26 web.1 | 15892 | strip_fpm_child_said 1>&2
02:38:26 web.1 | exited with code 1
02:38:26 system | sending SIGTERM to all processes
Apparently, it can't start because it can't access log files that is owned by root user.
Next, I'm trying to start it using sudo: sudo foreman start web and getting the following output:
02:43:29 web.1 | started with pid 16153
02:43:30 web.1 | Booting on port 5000...
02:43:30 web.1 | DOCUMENT_ROOT changed to '/web/'
02:43:30 web.1 | Starting php-fpm...
02:43:30 web.1 | Starting nginx...
02:43:32 web.1 | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
02:43:32 web.1 | nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
02:43:32 web.1 | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
02:43:32 web.1 | nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
02:43:33 web.1 | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
02:43:33 web.1 | nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
02:43:33 web.1 | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
02:43:33 web.1 | nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
02:43:34 web.1 | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
02:43:34 web.1 | nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
02:43:34 web.1 | nginx: [emerg] still could not bind()
02:43:34 web.1 | Process exited unexpectedly: nginx
02:43:34 web.1 | Going down, terminating child processes...
02:43:34 web.1 | vendor/bin/heroku-php-nginx: line 282: 16229 Terminated tail -qF -n 0 "${logs[#]}"
02:43:34 web.1 | 16230 | strip_fpm_child_said 1>&2
02:43:34 web.1 | exited with code 1
02:43:34 system | sending SIGTERM to all processes
Looks like it doesn't like that nginx service is running. Why is that?
I'm turning the webserver off using: sudo service nginx stop and trying again.
This time there are no error messages and it looks like server is running.
However, when I'm loading the webpage in my browser I'm getting the HTTP's 502 Bad Gateway error.
From the nginx error log I can see that nginx can't access FastCGI socket file:
2014/11/06 02:45:44 [crit] 16342#0: *1 connect() to unix:/tmp/heroku.fcgi.5000.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/heroku.fcgi.5000.sock:", host: "localhost:5000".
The socket file is owned by root and nginx is running as www-data.
What is the reason for this, how do I fix this problem? Is it possible to run Heroku locally from my user (not the root)?
I've had the same issue (on Mac OS, fresh install of nginx with homebrew).
I did not edit vendor/heroku/heroku-buildpack-php/conf/nginx/heroku.conf.php (it'd be overridden anytime the buildback gets updated, and it's slightly different nowadays anyway).
I've just fixed the permission for the error log file (chmoded it) and then run heroku local as normal
If you run heroku local as root, that will work around your error log permission error, but then nginx runs as root and php-fpm runs as nobody (in my case), hence the permission mismatch stated above.
If you fix the permission and then run heroku local (no sudo), then both runs as nobody, and it worked for me.
Your circumstance exactly like me.
The problem is the difference permission between process about nginx and php5-fpm.
Quick fix:
First:
Edit file: vendor/heroku/heroku-buildpack-php/conf/nginx/heroku.conf.php
comment: #server unix:/tmp/heroku.fcgi..sock max_fails=3 fail_timeout=3s;
open comment and change port: server 127.0.0.1:9000 max_fails=3 fail_timeout=3s;
Second:
Edit file: vendor/heroku/heroku-buildpack-php/conf/php/php-fpm.conf
comment: listen = /tmp/heroku.fcgi.${PORT}.sock
open comment and change port: listen = 127.0.0.1:9000