nginx php-fpm與rails並存 - Linux
By Jack
at 2015-03-22T22:46
at 2015-03-22T22:46
Table of Contents
請問一下各位
我想讓php與rails並存於同一個網站上
並且使用path去區分網站
目前我有三個目錄分別是
/var/work/rails 存放rails的
/var/work/php 存放php程式
/var/work/nginx_root 存放404等錯誤的靜態網頁
目前我的設定檔為
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.53;
passenger_ruby /usr/local/rvm/gems/ruby-2.1.2/wrappers/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
rewrite_log on;
error_log /opt/nginx/logs/error.log debug;
listen 80;
server_name localhost;
root /var/work/nginx_root;
error_page 403 404 405 406 500 501 502 503 504 /index.html;
# for rails
location /rails/assets {
passenger_base_uri /rails/assets;
passenger_enabled off;
alias /var/work/rails/public/assets;
}
location /rails {
alias /var/work/rails/public;
passenger_base_uri /rails;
passenger_app_root /var/work/rails;
passenger_document_root /var/work/rails/public;
passenger_enabled on;
}
}
}
這個設定檔運作是正常的
rails與錯誤網頁的導向都可以正常運作
但我現在要加入php-fpm的設定
讓連入的網址如果是 http://192.168.1.1/php/test.php
會採用php執行請問該如何做
我加入了以以下的設定
location /php {
alias /var/work/php;
passenger_enabled off;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index test.php;
fastcgi_param DOCUMENT_ROOT /var/work/php;
fastcgi_param SCRIPT_FILENAME /var/work/php/$fastcgi_script_name;
include fastcgi_params;
}
但會得到錯誤
/var/work/nginx_root/test.php failed (2: No such file or directory)
也就是說他還是跑到 nginx_root 下面去了
請問我該如何做調整
以下是我使用的版本
nginx version: nginx/1.6.2
built by gcc 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx --with-http_ssl_module
--with-http_gzip_static_module --with-http_stub_status_module
--with-cc-opt=-Wno-error
--add-module=/usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.55/ext/nginx
--
我想讓php與rails並存於同一個網站上
並且使用path去區分網站
目前我有三個目錄分別是
/var/work/rails 存放rails的
/var/work/php 存放php程式
/var/work/nginx_root 存放404等錯誤的靜態網頁
目前我的設定檔為
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.53;
passenger_ruby /usr/local/rvm/gems/ruby-2.1.2/wrappers/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
rewrite_log on;
error_log /opt/nginx/logs/error.log debug;
listen 80;
server_name localhost;
root /var/work/nginx_root;
error_page 403 404 405 406 500 501 502 503 504 /index.html;
# for rails
location /rails/assets {
passenger_base_uri /rails/assets;
passenger_enabled off;
alias /var/work/rails/public/assets;
}
location /rails {
alias /var/work/rails/public;
passenger_base_uri /rails;
passenger_app_root /var/work/rails;
passenger_document_root /var/work/rails/public;
passenger_enabled on;
}
}
}
這個設定檔運作是正常的
rails與錯誤網頁的導向都可以正常運作
但我現在要加入php-fpm的設定
讓連入的網址如果是 http://192.168.1.1/php/test.php
會採用php執行請問該如何做
我加入了以以下的設定
location /php {
alias /var/work/php;
passenger_enabled off;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index test.php;
fastcgi_param DOCUMENT_ROOT /var/work/php;
fastcgi_param SCRIPT_FILENAME /var/work/php/$fastcgi_script_name;
include fastcgi_params;
}
但會得到錯誤
/var/work/nginx_root/test.php failed (2: No such file or directory)
也就是說他還是跑到 nginx_root 下面去了
請問我該如何做調整
以下是我使用的版本
nginx version: nginx/1.6.2
built by gcc 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx --with-http_ssl_module
--with-http_gzip_static_module --with-http_stub_status_module
--with-cc-opt=-Wno-error
--add-module=/usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.55/ext/nginx
--
Tags:
Linux
All Comments
By Suhail Hany
at 2015-03-25T11:09
at 2015-03-25T11:09
By Quintina
at 2015-03-29T23:18
at 2015-03-29T23:18
By Margaret
at 2015-04-02T18:59
at 2015-04-02T18:59
By Leila
at 2015-04-04T21:15
at 2015-04-04T21:15
By Lily
at 2015-04-06T06:04
at 2015-04-06T06:04
By Caroline
at 2015-04-10T10:21
at 2015-04-10T10:21
By Steve
at 2015-04-14T10:18
at 2015-04-14T10:18
By Olive
at 2015-04-18T12:01
at 2015-04-18T12:01
By Elvira
at 2015-04-23T09:43
at 2015-04-23T09:43
By Jake
at 2015-04-23T17:15
at 2015-04-23T17:15
Related Posts
雙系統硬碟對拷後,無法開機
By Suhail Hany
at 2015-03-21T04:49
at 2015-03-21T04:49
OS從WIN7換成Fedora的硬碟問題
By Daniel
at 2015-03-21T02:27
at 2015-03-21T02:27
安裝llvm/clang的問題
By Donna
at 2015-03-21T01:55
at 2015-03-21T01:55
CentOS 硬體選擇
By Sierra Rose
at 2015-03-21T01:11
at 2015-03-21T01:11
ImageMagick支援圖片類型問題
By Hedda
at 2015-03-20T17:14
at 2015-03-20T17:14