|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
以下のモジュールを読み込んだが必要なのかなぁ?
|
|
|
|
|
|
tce-load -wi fcgi
|
|
|
|
|
|
|
|
|
tce-load -wi fcgi-dev
|
|
|
|
|
|
|
|
|
どうも必要ないみたい。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
そもそも以下のように対応版が入っているし
|
|
|
|
|
|
|
tc@tc4364:/tmp/tcloop/fcgi/usr/local/bin$
php-cgi -v
|
|
|
|
|
PHP 5.3.8 (
cgi-fcgi
) (built: Nov 28 2011 01:55:54)
|
|
|
|
|
Copyright (c) 1997-2011 The PHP Group
|
|
|
|
|
|
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
|
|
|
|
tc@tc4364:/tmp/tcloop/fcgi/usr/local/bin$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
起動してみるが・・・・・
|
|
|
|
|
|
|
|
|
cgi-fcgi -start -connect localhost:9000 /usr/local/bin/php-cgi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
一晩考えてもダメダメだった。。。。。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
気を取り直し翌日
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fastfgiの起動は以下のようにする
|
|
|
|
|
|
|
|
php-cgi -b 127.0.0.1:9000 &
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
どっか違うディレクトリ見ているから動かないかな?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
全部のディレクトリにスクリプトを置いてやる!!
|
|
|
|
|
|
こんなシェル作ってやる
|
|
|
|
|
|
|
|
sudo
|
|
|
|
|
|
|
|
|
|
vi b.sh
|
|
|
|
|
|
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\rm /root/a.sh 2>/dev/null
|
|
|
|
|
|
|
|
find / -type d|egrep -v "^/proc|^/dev|^/mnt|^/sys">a.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while read a
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
|
|
echo "echo $a > $a/index.php" >>a.sh
|
|
|
|
|
|
done <a.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
実行
|
|
|
|
|
|
|
|
|
|
sh b.sh
|
|
|
|
|
|
|
|
|
|
sh a.sh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
これでもなんかうまくいかない
|
|
|
|
|
|
|
|
消す
|
|
|
|
|
|
|
|
|
|
vi b.sh
|
|
|
|
|
|
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\rm /root/a.sh 2>/dev/null
|
|
|
|
|
|
|
|
find / -type d|egrep -v "^/proc|^/dev|^/mnt|^/sys">a.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while read a
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
|
|
echo "\\rm $a/index.php" >>a.sh
|
|
|
|
|
|
|
done <a.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
実行
|
|
|
|
|
|
|
|
|
|
sh b.sh
|
|
|
|
|
|
|
|
|
|
sh a.sh
|
|
|
|
|
|
|
|
|
|
エラー出るがOKOK
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nginx.confかな??
|
|
|
|
|
|
|
|
|
うまくいったものが以下
|
|
|
|
|
|
|
|
vi /opt/env/srv/nginx/nginx.conf
|
|
|
|
|
|
|
#user
nobody;
|
|
|
|
|
|
|
|
|
worker_processes
1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#error_log
/home/log/nginx/error.log;
|
|
|
|
|
|
#error_log
/home/log/nginx/error.log
notice;
|
|
|
|
|
error_log
/home/log/nginx/error.log
info;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pid
/home/log/nginx/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
/home/log/nginx/access.log
main;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sendfile
on;
|
|
|
|
|
|
|
|
#tcp_nopush
on;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
keepalive_timeout
0;
|
|
|
|
|
|
|
|
#keepalive_timeout
65;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gzip
on;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server {
|
|
|
|
|
|
|
|
|
listen
80;
|
|
|
|
|
|
|
|
server_name
localhost;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#charset koi8-r;
|
|
|
|
|
|
|
|
charset utf-8;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#access_log
/home/log/nginx/host.access.log
main;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
location / {
|
|
|
|
|
|
|
|
root
html;
|
|
|
|
|
|
|
|
index.php index
index.html index.htm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#error_page
404
/404.html;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# redirect 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;
|
|
fastcgi_param
SCRIPT_FILENAME
/home/html$fastcgi_script_name;
|
|
include
/usr/local/fastcgi_params;
|
|
|
|
|
#include
fastcgi_params;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# deny access to .htaccess files, if Apache's document root
|
|
|
# concurs with nginx's one
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
#location ~ /\.ht {
|
|
|
|
|
|
|
#
deny
all;
|
|
|
|
|
|
|
|
#}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# another virtual host using mix of IP-, name-, and port-based configuration
|
|
#
|
|
|
|
|
|
|
|
|
|
#server {
|
|
|
|
|
|
|
|
|
#
listen
8000;
|
|
|
|
|
|
|
#
listen
somename:8080;
|
|
|
|
|
|
#
server_name
somename
alias
another.alias;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
location / {
|
|
|
|
|
|
|
|
#
root
html;
|
|
|
|
|
|
|
|
#
index
index.html index.htm;
|
|
|
|
|
|
#
}
|
|
|
|
|
|
|
|
|
#}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# HTTPS server
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
#server {
|
|
|
|
|
|
|
|
|
#
listen
443;
|
|
|
|
|
|
|
|
#
server_name
localhost;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
ssl
on;
|
|
|
|
|
|
|
#
ssl_certificate
cert.pem;
|
|
|
|
|
|
#
ssl_certificate_key
cert.key;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
ssl_session_timeout
5m;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
ssl_protocols
SSLv2 SSLv3 TLSv1;
|
|
|
|
|
|
#
ssl_ciphers
HIGH:!aNULL:!MD5;
|
|
|
|
|
|
#
ssl_prefer_server_ciphers
on;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
location / {
|
|
|
|
|
|
|
|
#
root
html;
|
|
|
|
|
|
|
|
#
index
index.html index.htm;
|
|
|
|
|
|
#
}
|
|
|
|
|
|
|
|
|
#}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
なんかディレクトリ情報がヘンなんじゃねーかと思い
|
|
|
|
|
|
nginxが何を送るのか気になってしまい以下のサンプルを作ってみた。
|
|
|
|
(ローカルで動かすことにした)
|
|
|
|
|
|
|
|
nginx.confを改造
|
|
|
|
|
|
|
|
|
fastcgi_pass
192.168.0.8:9000;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
サンプルPHP(socket.php)
|
|
|
|
|
|
|
|
ローカル(Windows環境)で動かしたソース
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
// php.ini
を変更
|
|
|
|
|
|
|
|
|
// ;extension=php_sockets.dll
コメントを外して有効にする
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$port = 9000;
|
|
|
|
|
|
|
|
|
$address ='192.168.0.8';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sock= socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
|
|
|
|
#$sock = socket_create_listen($port);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
socket_bind($sock, $address, $port);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
socket_listen($sock, 5);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
|
|
|
|
|
$clientsock = socket_accept($sock);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
|
|
|
|
|
$buf = socket_read($clientsock, 1024);
|
|
|
|
|
|
if ($buf == "") { break; }
|
|
|
|
|
|
|
echo $buf;
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
socket_close($clientsock);
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
socket_close($sock);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
サーバ側nginx再起動
|
|
|
|
|
|
|
|
|
sudo killall nginx
|
|
|
|
|
|
|
|
sudo /usr/local/sbin/nginx -c /usr/local/nginx.conf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
実行してみる
|
|
|
|
|
|
|
|
|
D:\dev\php>
php-cgi socket.php
|
|
|
|
|
|
|
ブラウザでhttp://192.168.0.X/index.php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
X-Powered-By: PHP/5.2.13
|
|
|
|
|
|
|
|
Content-type: text/html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
~~~~SCRIPT_FILENAME/home/html/index.php ~~~~~~~~
|
|
|
|
~
|
|
|
|
|
|
|
|
|
|
SCRIPT_NAME/index.php
|
|
|
|
|
|
|
|
REQUEST_URI/index.php
|
|
|
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
|
|
|
|
D:\dev\php>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
まぁ、/home/html/index.phpと出ているので、index.phpを置いてみる
|
|
|
|
|
d:\home\html\index.php
|
|
|
|
|
|
|
|
|
<? phpinfo(); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
実行
|
|
|
|
|
|
|
|
|
|
d:\dev\php\php-cgi -b 192.168.0.8:9000
|
|
|
|
|
|
ブラウザでhttp://192.168.0.4/index.php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ををを、phpinfoが出た!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
じゃあ
|
|
|
|
|
|
|
|
|
|
nginx.confを戻す
|
|
|
|
|
|
|
|
|
fastcgi_pass
127.0.0.1:9000;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cat /home/html/index.php
|
|
|
|
|
|
|
|
<? phpinfo(); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nginx再起動
|
|
|
|
|
|
|
|
|
sudo killall nginx
|
|
|
|
|
|
|
|
sudo /usr/local/sbin/nginx -c /usr/local/nginx.conf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fastcgi再起動
|
|
|
|
|
|
|
|
|
sudo killall php-cgi
|
|
|
|
|
|
|
|
sudo php-cgi -b 127.0.0.1:9000 &
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ブラウザでhttp://192.168.0.X/index.php
|
|
|
|
|
|
|
やっぱり何にも出ない
|
|
|
|
|
|
|
|
|
ソース表示すると・・・・・
|
|
|
|
|
|
|
|
<? phpinfo(); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
あれ?そのまんまじゃん
|
|
|
|
|
|
|
|
おかしいなぁ、正式に書いてみる・・・・・
|
|
|
|
|
|
|
cat /home/html/index.php
|
|
|
|
|
|
|
|
<?php phpinfo(); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ブラウザでhttp://192.168.0.4/index.php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
![IF>
![ENDIF]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
で、出たよ。
|
|
|
|
|
|
|
|
|
やっとでた!!!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
しかし、wordpressとかメジャーなPHPアプリは”<?php”しか受けつけなくて大丈夫かな?
|
|
|
調べてみるとshort_open_tagというのが関連するらしい
|
|
|
|
|
|
root@tc4364:/usr/local#
php-cgi -i | grep short
|
|
|
|
|
|
<tr><td class="e">short_open_tag</td><td class="v">Off</td><td class="v">Off</td></tr>
|
|
|
|
|
|
|
|
|
|
|
D:\dev\php>
php-cgi -i | findstr short
|
|
|
|
|
|
|
<tr><td class="e">short_open_tag</td><td class="v">On</td><td class="v">On</td></tr>
|
|
|
|
|
|
|
|
|
|
|
ローカルは5.2.13で、サーバが5.3.8なので違ったのでした。
|
|
|
|
|
理由はXMLを絡めるとまずいからだって
|
|
|
|
|
|
|
例:
|
|
|
|
|
|
|
|
|
|
<?php echo '<?xml version="1.0"?>'; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
さてさて、とりあえずphp-cgiも上がるように起動スクリプトに追加
|
|
|
|
|
sudo echo PHP_FCGI_CHILDREN=5>>/opt/env/srv/nginx.sh
|
|
|
|
|
sudo echo PHP_FCGI_MAX_REQUESTS=1000>>/opt/env/srv/nginx.sh
|
|
|
|
sudo echo php-cgi -b 127.0.0.1:9000 \&>>/opt/env/srv/nginx.sh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
自作アプリが動くようにphp.iniも直しておく
|
|
|
|
|
|
|
vi /opt/env/srv/php/php.ini
|
|
|
|
|
|
|
short_open_tag
On
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reboot
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
高速化
|
|
|
|
|
|
|
|
|
|
APCっつーのがいいのか?hippopはまだか・・・tinycoreのレジストリにはまだないのでこれでおしまい
|
|
http://www26.atwiki.jp/nginx/pages/21.html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
http://www.linuxask.com/questions/how-to-compile-apc-module-for-php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1. Download the latest APC from PECL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wget http://pecl.php.net/get/APC
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2. Extract the APC source package and compile/install it
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tar -xvf APC
|
|
|
|
|
|
|
|
|
cd APC-X.X.X (replace with your downloaded version)
|
|
|
|
|
|
phpize
|
|
|
|
|
|
|
|
|
|
./configure
|
|
|
|
|
|
|
|
|
make && make install
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3. Enable APC in PHP configuration
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "extension=apc.so" > /etc/php.d/apc.ini
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4. Restart the httpd and use phpinfo() to verify if APC is running
|
|
|
|
|
![IF>
|
|
|
|
|
|
|
|
|
|
![ENDIF]>