简体   繁体   中英

Error when deploying Rails with Passenger and Apache: Unexpected error in mod_passenger: Cannot connect to Unix socket Permission denied (errno=13)

I have been trying to deploy my Rails app by using Phusion Passenger and Apache on CentOS 7. I am following the tutorial available on the Phusion Passenger website, but I am stuck.

When I start Apache, and I access the application by using a browser I get: 500 Internal Server Error. The following error was found in the error log file in /etc/httpd/logs/error_log:

[ 2017-03-15 22:57:15.5385 18290/7f4c6eb61880 apa/Hooks.cpp:690 ]: Unexpected error in mod_passenger: Cannot connect to Unix socket '/tmp/passenger.8zZ83f3/agents.s/core': Permission denied (errno=13)
  Backtrace:
     in 'int Passenger::connectToServer(const Passenger::StaticString&, const char*, unsigned int)' (IOUtils.cpp:459)
     in 'Passenger::FileDescriptor Hooks::connectToCore()' (Hooks.cpp:273)
     in 'int Hooks::handleRequest(request_rec*)' (Hooks.cpp:561)

So far I tried:

  1. Disabling SELinux: setting SELINUX=disabled (in /etc/sysconfig/selinux)
  2. Adding 'umask 0022' (or even 'umask u=rwx,g=rx,o=rx') to /etc/sysconfig/httpd
  3. Assigning 755 priviliges to /tmp folder
  4. Changing PassengerInstanceRegistryDir to a different folder under my user's home directory (and also assigning 755 privileges)

But none of these seem to work. I am using Phusion Passenger 5.1.2 and Apache 2.4.6.

Also, this is what I get by running

$ sudo /usr/bin/passenger-config validate-install
  • Checking whether this Passenger install is in PATH... ✓
  • Checking whether there are no other Passenger installations... ✓
  • Checking whether Apache is installed... ✓
  • Checking whether the Passenger module is correctly configured in Apache... ✓

This is the output when I run

$ sudo /user/sbin/passenger-memory-status

Version: 5.1.2
Date   : 2017-03-16 07:42:59 -0500

---------- Apache processes ----------
PID    PPID   VMSize    Private  Name
--------------------------------------
18237  1      227.0 MB  0.2 MB   /usr/sbin/httpd -DFOREGROUND
18286  18237  229.0 MB  0.2 MB   /usr/sbin/httpd -DFOREGROUND
18287  18237  229.0 MB  0.2 MB   /usr/sbin/httpd -DFOREGROUND
18288  18237  229.0 MB  0.2 MB   /usr/sbin/httpd -DFOREGROUND
18289  18237  229.0 MB  0.3 MB   /usr/sbin/httpd -DFOREGROUND
18290  18237  229.0 MB  0.3 MB   /usr/sbin/httpd -DFOREGROUND
18300  18237  229.0 MB  0.2 MB   /usr/sbin/httpd -DFOREGROUND
### Processes: 7
### Total private dirty RSS: 1.73 MB


-------- Nginx processes --------

### Processes: 0
### Total private dirty RSS: 0.00 MB


----- Passenger processes -----
PID    VMSize    Private  Name
-------------------------------
18264  417.0 MB  1.0 MB   Passenger watchdog
18267  649.9 MB  3.2 MB   Passenger core
18275  427.3 MB  3.0 MB   Passenger ust-router
### Processes: 3
### Total private dirty RSS: 7.11 MB

I solved the problem by running the following command:

$ sudo chcon -R -v -t httpd_sys_rw_content_t /tmp

I don't know if other things can be impacted by changing the permissions over the whole folder. Do you guys think this might be a problem?

As an alternative, I can also set PassengerInstanceRegistryDir to a different location, and run the above mentioned command once again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM