Phusion Passenger Forbidden Permissions Denied - passenger

I'm trying to run Phusion Passenger with Apache and when I start passenger I get the following error:
=============== Phusion Passenger Standalone web server started ===============
PID file: /root/passenger.3000.pid
Log file: /root/passenger.3000.log
Environment: development
Accessible via: http://0.0.0.0:3000/
You can stop Phusion Passenger Standalone by pressing Ctrl-C.
===============================================================================
2012/12/11 18:01:36 [error] 3188#0: *4 "/root/public/index.html" is forbidden (1
3: Permission denied), client: 127.0.0.1, server: _, request: "HEAD / HTTP/1.1", host: "0.0.0.0"
I've had a look around at other peoples comments on this but their answers are focused around Nginx rather than Apache. Any advice would be appreciated.

Phusion Passenger Standalone will refuse to run as root for security reasons. When you ran passenger start, it asked you to provide --user, didn't it? Well, Phusion Passenger Standalone is running as that user, and that user probably does not have permission to access anything under /root.
You can either relax permissions on /root, or you can move your application directory to a place where it's accessible for that user.

Related

Valet 502 Bad Gateway

valet is not working after I updated php from 7.3 to 7.4. I already tried to reinstall valet, php, nginx and dnsmasq but it's still not working.
Now the ngix server is running but I can't acces to my projects. I get the error 502 Bad Gateway for every project url.
The services are running but brew services dont show the correct status.
dnsmasq unknown root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
gitlab-runner started user /Users/user/Library/LaunchAgents/homebrew.mxcl.gitlab-runner.plist
mysql#5.7 started user /Users/user/Library/LaunchAgents/homebrew.mxcl.mysql#5.7.plist
nginx unknown root /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php error root /Library/LaunchDaemons/homebrew.mxcl.php.plist
php#7.4 unknown root /Library/LaunchDaemons/homebrew.mxcl.php#7.4.plist
redis started user /Users/user/Library/LaunchAgents/homebrew.mxcl.redis.plist
Nginx error log
2021/01/27 16:35:21 [crit] 35081#0: *1 connect() to unix:/Users/user/.config/valet/valet.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://unix:/Users/user/.config/valet/valet.sock:", host: "devtest.test", referrer: "http://devtest.test/"
I've managed to get mine working again.
I started by doing a full wipe down following the instructions that valet gives when you run valet uninstall which involved removing valet and all associated config, uninstalling php, nginx and dnsmasq via brew and cleaning up all remaining config. I then reinstalled everything, reconfigured my sites in valet and tried to load one up. Still I got the 502 Bad Gateway error.
I eventually tried running valet use php to make sure it was correctly bound to the right php version. Valet claimed that is was but I ran it again with the force flag just in case valet use php --force.
After that I was up and running again. Hopefully this might help you too.
What's strange is that my brew services list output lists dnsmasq, nginx and php as status unknown but they do all seem to be running correctly. I can't work out what's happening there but at least everything seems to be working again now.

Not found error on setting up local server using LAMPP

When I enter localhost/hello.php in my browser, I get below error.
Not Found
The requested URL /hello.php was not found on this server.
Apache/2.4.18 (Ubuntu) Server at localhost Port 80
I think there is some compatibility issue in the LAMPP and Ubuntu.
To start apache2 normally you need to first hard stop it through following command:
Sudo service apache2 stop.
And then restart the apache2 or LAMPP . This worked for me.

Can't access Ruby server on VM from host machine

I have a VM set up running Ubuntu server 14.04. In my VM I have created the following Ruby/Sinatra app:
require 'sinatra'
set :environment, :production
set :bind, '0.0.0.0'
get '/' do
"Hello World!"
end
When I execute this using ruby hello.rb I get the following output:
[2015-03-09 16:58:34] INFO WEBrick 1.3.1
[2015-03-09 16:58:34] INFO ruby 2.1.5 (2014-11-13) [x86_64-linux]
== Sinatra/1.4.5 has taken the stage on 4567 for production with backup from WEBrick
[2015-03-09 16:58:34] INFO WEBrick::HTTPServer#start: pid=2258 port=4567
Everything seems to work fine, but when I try to access localhost:4567 from my host machine (Windows 8.1) I get a GET http://localhost:4567/ net::ERR_CONNECTION_REFUSED error (in Chrome).
If I try to access the server from within my VM (ex, by using wget http://localhost:4567) it works fine.
I also have Apache2.4 running in my VM, which works fine, but I disabled it when trying to access my Ruby server by running sudo service apache2 stop.
What could the problem be? I have no problem running regular Ruby files, and I can access my Ruby/Sinatra app if I use Apache2 with Phusion Passenger. But when I simply run ruby hello.rb I can't access it from my host machine.
localhost refers to your local host, which in the case of Windows is not the same as your Ubuntu instance.
You'll need to connect to your Ubuntu instance IP directly, whatever that is. Usually you can find out with ip addr or ifconfig.
If you need a friendly DNS name you can put in your browser, xip.io provides one.
If you're using Vagrant then you can configure port forwarding so you can still use localhost if you want. Without port forwarding you will not be able to connect indirectly.
I have the network adapter for my VM attached to NAT. I was forwarding ports 443, 22 and 80 to my VM, and accessing my server on those ports works fine. Since I was running the Ruby WEBrick server on the default port 4567, I just had to forward port 4567 from my host machine to my VM as well.
After that change, typing http://localhost:4567 into my web browser served up the content from my Ruby file.

Running a Sinatra server when non-root user

I am part of a shared linux server, which is hosted on DigitalOcean.
I want to run a Sinatra web server from it, but I am not a root user.
I set the port for 4040, with set :port, 4040 and the server starts successfully with ruby server.rb.
== Sinatra/1.4.5 has taken the stage on 4040 for development with backup from WEBrick
[] INFO WEBrick::HTTPServer#start: pid=18955 port=4040
When I visit the IP address like http://IP_ADDRESS:4040, nothing shows up.
What am I doing wrong?

Rails app behaving differently in development vs production

Can someone please shed some light on why the app is behaving differently in production vs development mode. I have checked and re-checked config/database.yml and ensured that the username and password are correct. In fact as of writing this I have set both, development and production database to be same. Yet, when I run the server in production environment, Mysql2 complains about access denied, but works fine in development environment.
Same thing happens when running rails c production vs rails c development , no error in development but Mysql2 access denied in production.
Production mode
$ rails s -e production
=> Booting WEBrick
=> Rails 4.0.2 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-03-19 18:20:22] INFO WEBrick 1.3.1
[2014-03-19 18:20:22] INFO ruby 2.1.0 (2013-12-25) [x86_64-freebsd10.0]
[2014-03-19 18:20:22] INFO WEBrick::HTTPServer#start: pid=10800 port=3000
I, [2014-03-19T18:20:30.569167 #10800] INFO -- : Started GET "/" for 192.168.1.102 at 2014-03-19 18:20:30 +0200
F, [2014-03-19T18:20:30.709229 #10800] FATAL -- :
Mysql2::Error (Access denied for user 'root'#'localhost' (using password: YES)):
Development Mode
$ rails s -e development
=> Booting WEBrick
=> Rails 4.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-03-19 18:22:53] INFO WEBrick 1.3.1
[2014-03-19 18:22:53] INFO ruby 2.1.0 (2013-12-25) [x86_64-freebsd10.0]
[2014-03-19 18:22:53] INFO WEBrick::HTTPServer#start: pid=10898 port=3000
Started GET "/" for 192.168.1.102 at 2014-03-19 18:23:03 +0200
Processing by Rails::WelcomeController#index as HTML
Rendered /home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/templates/rails/welcome/index.html.erb (2.3ms)
Completed 200 OK in 24ms (Views: 11.6ms | ActiveRecord: 0.0ms)
And here is my config/database.yml.
development:
adapter: mysql2
encoding: utf8
database: amo
pool: 5
username: root
password: mypass
host: localhost
production:
adapter: mysql2
encoding: utf8
database: amo
pool: 5
username: root
password: mypass
host: localhost
O/S : FreeBSD 10.0 64bit
Ruby : 2.1.0 (installed using Rbenv)
Rails : 4.0.2
A common problem is that the DB user permissions are setup with % to refer to local access permissions....
...but in the prod environment, where the DB and web servers are on different machines, you need to set the user permission to come from the IP, DNS, etc of the web server machine.
For instance, you may have perms like this:
grant all privileges on mydb.* to myuser#'%' identified by 'mypasswd';
grant all privileges on mydb.* to myuser#localhost identified by 'mypasswd';
But this will only work for your local dev environment. You may have this kind of permission setup scripted, in which case you'd need different setup perms for your prod DB.
In the prod environment, you may have your web service on 168.0.1.2 and your DB on 168.0.1.100. So your prod DB would need:
grant all privileges on mydb.* to myuser#168.0.1.2 identified by 'mypasswd';
If you add another web server, remember to add permissions for users coming from that machine.
If none of this is ringing a bell, post your GRANTS (change the private details). I'll dig out the commands to do this, if you aren't familiar.

Resources