[Question] Biên dịch web server nginx + PHP + FCGI |
14/09/2011 10:02:07 (+0700) | #1 | 247087 |
|
vitcon01
Member
|
0 |
|
|
Joined: 29/04/2009 11:28:21
Messages: 306
Offline
|
|
Em đã tiến hành biên dịch nginx tuy nhiên hiện tại nó chỉ có thể chạy được html, còn php thì bị lỗi 403.
Code:
# ./configure --without-http_autoindex_module --without-http_ssi_module --without-http_userid_module --without-http_auth_basic_module --without-http_geo_module --without-http_empty_gif_modul
Sau đó em biên dịch php-5.3.8
Code:
./configure --with-zlib --with-bz2 --with-curl --with-curlwrappers --enable-exif --enable-ftp --with-gd --with-ldap --enable-mbstring --with-mcrypt --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --enable-soap --enable-sqlite-utf8 --enable-zip --with-openssl
Sau đó em biên dịch spawn-fcgi 1.6.3
Code:
Tiến hành bật dịch vụ nginx và spawn-fcgi
Code:
[root@localhost init.d]# service fastcgi start
Starting php-cgi: spawn-fcgi: child spawned successfully: PID: 9146
Starting fastcgi: ok
[root@proxy spawn-fcgi-1.6.3]# /usr/local/nginx1/sbin/nginx
Kiêm tra:
Code:
[root@proxy spawn-fcgi-1.6.3]# netstat -an | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
[root@proxy spawn-fcgi-1.6.3]# netstat -an | grep :9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
[root@proxy spawn-fcgi-1.6.3]#
File cấu hình của nginx.conf
Code:
#user nobody;
worker_processes 1;
user nginx nginx;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name nixcraft.in www.nixcraft.in;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location ~ ^/index.php
{
fastcgi_pass 127.0.0.1:9000;
#CHANGE THIS TO THE PATH TO YOUR WEB ROOT DIRECTORY
fastcgi_param SCRIPT_FILENAME /var/www/marketdark$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
#error_page 404 /404.html;
# wwwect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
}
File cấu hình của fastcgi_params
Code:
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-wwwect
#fastcgi_param REDIRECT_STATUS 200;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
Em cảm ơn! |
|
JK - JH
()()()
LTKT - LTT |
|
|
|
[Question] Biên dịch web server nginx + PHP + FCGI |
14/09/2011 10:09:13 (+0700) | #2 | 247089 |
centos
Member
|
0 |
|
|
Joined: 28/03/2008 17:13:12
Messages: 219
Offline
|
|
Cho mình xem log báo lỗi của nginx đi bạn, xem nó bảo thế nào?
Theo mình nghĩ là thằng spawn-fcgi của bạn chưa làm việc được với php nên nó trả về lỗi 403. Khi cài đặt spawn xong bạn start lên phải chỉ ra cho spawn biết đường dẫn đến file php-cgi để nó kết nồi về php
spawn-fcgi -a 127.0.0.1 -p 9000 -f /php-path-php-cgi/php5-cgi
|
|
|
|
|
[Question] Biên dịch web server nginx + PHP + FCGI |
14/09/2011 11:05:41 (+0700) | #3 | 247098 |
|
conmale
Administrator
|
Joined: 07/05/2004 23:43:15
Messages: 9353
Location: down under
Offline
|
|
Đã dùng php 5.3.8 thì nên dùng php-fpm đi cho xong. Nên enable "--enable-fpm" trong lúc biên dịch php.
Còn nếu muốn khắc phục lỗi thì luôn luôn kèm logs chớ nói suông lỗi 403 thì có thánh mới giải quyết nổi. |
|
What bringing us together is stronger than what pulling us apart. |
|
|
|
[Question] Biên dịch web server nginx + PHP + FCGI |
14/09/2011 12:59:36 (+0700) | #4 | 247113 |
|
vitcon01
Member
|
0 |
|
|
Joined: 29/04/2009 11:28:21
Messages: 306
Offline
|
|
Đây là log nginx
Code:
[root@proxy php-5.3.8]# tail /usr/local/nginx1/logs/error.log
2011/09/13 23:32:36 [error] 25174#0: *5095 directory index of "/usr/local/nginx1//html/" is forbidden, client: 192.168.137.1, server: nixcraft.in, request: "GET / HTTP/1.1", host: "192.168.137.253"
2011/09/13 23:32:37 [error] 25174#0: *5095 directory index of "/usr/local/nginx1//html/" is forbidden, client: 192.168.137.1, server: nixcraft.in, request: "GET / HTTP/1.1", host: "192.168.137.253"
2011/09/13 23:32:37 [error] 25174#0: *5095 directory index of "/usr/local/nginx1//html/" is forbidden, client: 192.168.137.1, server: nixcraft.in, request: "GET / HTTP/1.1", host: "192.168.137.253"
2011/09/13 23:32:37 [error] 25174#0: *5095 directory index of "/usr/local/nginx1//html/" is forbidden, client: 192.168.137.1, server: nixcraft.in, request: "GET / HTTP/1.1", host: "192.168.137.253"
2011/09/13 23:32:37 [error] 25174#0: *5095 directory index of "/usr/local/nginx1//html/" is forbidden, client: 192.168.137.1, server: nixcraft.in, request: "GET / HTTP/1.1", host: "192.168.137.253"
2011/09/13 23:32:37 [error] 25174#0: *5095 directory index of "/usr/local/nginx1//html/" is forbidden, client: 192.168.137.1, server: nixcraft.in, request: "GET / HTTP/1.1", host: "192.168.137.253"
2011/09/14 00:50:57 [error] 25174#0: *5097 directory index of "/usr/local/nginx1//html/" is forbidden, client: 127.0.0.1, server: nixcraft.in, request: "POST / HTTP/1.1", host: "localhost"
2011/09/14 01:02:04 [error] 25174#0: *5098 directory index of "/usr/local/nginx1//html/" is forbidden, client: 192.168.137.1, server: nixcraft.in, request: "GET / HTTP/1.1", host: "192.168.137.253"
2011/09/14 01:02:06 [error] 25174#0: *5098 directory index of "/usr/local/nginx1//html/" is forbidden, client: 192.168.137.1, server: nixcraft.in, request: "GET / HTTP/1.1", host: "192.168.137.253"
2011/09/14 01:02:43 [error] 25174#0: *5098 directory index of "/usr/local/nginx1//html/" is forbidden, client: 192.168.137.1, server: nixcraft.in, request: "GET / HTTP/1.1", host: "192.168.137.253"
|
|
JK - JH
()()()
LTKT - LTT |
|
|
|
[Question] Biên dịch web server nginx + PHP + FCGI |
14/09/2011 14:00:17 (+0700) | #5 | 247118 |
Dpm
Member
|
0 |
|
|
Joined: 06/04/2009 01:43:30
Messages: 85
Offline
|
|
# ./configure --without-http_autoindex_module --without-http_ssi_module --without-http_userid_module --without-http_auth_basic_module --without-http_geo_module --without-http_empty_gif_modul
2011/09/14 01:02:43 [error] 25174#0: *5098 directory index of "/usr/local/nginx1//html/" is forbidden, client: 192.168.137.1, server: nixcraft.in, request: "GET / HTTP/1.1", host: "192.168.137.253"
|
|
|
|
|
[Question] Biên dịch web server nginx + PHP + FCGI |
14/09/2011 14:19:28 (+0700) | #6 | 247122 |
centos
Member
|
0 |
|
|
Joined: 28/03/2008 17:13:12
Messages: 219
Offline
|
|
mà cài nginx without chi vậy bồ, cứ để ./configure mà phang |
|
|
|
|
[Question] Biên dịch web server nginx + PHP + FCGI |
15/09/2011 12:54:24 (+0700) | #7 | 247170 |
|
vitcon01
Member
|
0 |
|
|
Joined: 29/04/2009 11:28:21
Messages: 306
Offline
|
|
centos wrote:
mà cài nginx without chi vậy bồ, cứ để ./configure mà phang
--->sao bồ không yum hay apt-get hay pacman cho nó sương hơn biên dịch làm gì hã bồ.
Code:
# ./configure --without-http_autoindex_module --without-http_ssi_module --without-http_userid_module --without-http_auth_basic_module --without-http_geo_module --without-http_empty_gif_modul
2011/09/14 01:02:43 [error] 25174#0: *5098 directory index of "/usr/local/nginx1//html/" is forbidden, client: 192.168.137.1, server: nixcraft.in, request: "GET / HTTP/1.1", host: "192.168.137.253"
--->cảm ơn bạn, tôi đã thêm module đó, tuy nhiên lỗi vẫn vậy.
Mấu chốt lỗi là chỗ này:
Code:
location / {
root html;
index index.html index.htm;
}
tôi tiến hành change như sau
Code:
location / {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
index index.html index.htm index.php;
}
--->thì lỗi không còn hiện ra như trên, tuy nhiên ko hiển thị trang, mà là 1 trang trắng xoá. |
|
JK - JH
()()()
LTKT - LTT |
|
|
|
[Question] Biên dịch web server nginx + PHP + FCGI |
19/09/2011 14:17:49 (+0700) | #8 | 247367 |
centos
Member
|
0 |
|
|
Joined: 28/03/2008 17:13:12
Messages: 219
Offline
|
|
vitcon01 wrote:
centos wrote:
mà cài nginx without chi vậy bồ, cứ để ./configure mà phang
--->sao bồ không yum hay apt-get hay pacman cho nó sương hơn biên dịch làm gì hã bồ.
Tùy thằng manager nó quyết định việc cài đặt từ source hay tử binarry mà bồ. |
|
|
|