linux服務器WEB環境一鍵安裝包lanmp教程之五

在我們安裝了linux服務器WEB環境一鍵安裝包lanmp後,可能會有不少疑問還有就是使用過程中出現的問題,下面爲大家總結幾點比較常見的,如若還有其他疑問,可到wdlinux論壇尋找相關教程。

1、增加apache支持CGI程序

apache默認已支持CGI,但默認沒有開啓,如需要CGI支持,可用如下方法
1
vi /www/wdlinux/apache/conf/httpd-wdl.conf
在最後增加
AddHandler cgi-script .cgi .pl

echo "AddHandler cgi-script .cgi .pl" >>/www/wdlinux/apache/conf/httpd-wdl.conf

2
修改虛擬主機配置文件/www/wdlinux/apache/conf/vhost/wdlinux.cn.conf,如下位置
<Directory /www/web/wdlinux.cn/public_html>
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
修改替換爲
<Directory /www/web/wdlinux.cn/public_html>
    Options FollowSymLinks ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
實際上就是增加了 "ExecCGI"

重起apache
service httpd restart

現在可以測試一下
vi /www/web/wdlinux.cn/public_html/test.cgi
#!/usr/bin/perl
print "Content-type: text/html \n\n";
foreach $var (sort(keys(%ENV))) {
    $val = $ENV{$var};
    $val =~ s|\n|\\n|g;
    $val =~ s|"|\\"|g;
    print "${var}=\"${val}\"\n";
}
保存

還需要付以此文件有執行權,如
chmod 755 /www/web/wdlinux.cn/public_html/test.cgi

 

2、解決nginx 502 bad gateway問題

最近在把joomla 1.5.18的一個站點從虛擬主機的apache移到另一臺VPS主機的nginx上,根據joomla官方提供的nginx rewrite規則修改了nginx的配置,結果的大部分的網頁都正常顯示,只有一個contact us的頁面在發送郵件的時候,遇到錯誤:nginx 502 badgateway

系統環境:
CentOS6.4 86x64
wdcp: wgethttp://dl.wdlinux.cn:5180/lanmp_laster.tar.gz
0c5d80fd4b28b7049d18275962f1fc09  lanmp_laster.tar.gz
nginx1.0.15
mysql5.1.63
php5.2.17

有2條錯誤比較引人注意:
tail/www/wdlinux/nginx_php-5.2.17/logs/php-fpm.log
[WARNING] fpm_children_bury(), line 215: child 16523(pool default) exited on signal 15 SIGTERM after 1868.423609 seconds from start
tail /www/wdlinux/nginx/logs/error.log

[error] 16501#0: *5 recv() failed (104: Connectionreset by peer) while reading response header from upstream, client:123.456.789, server: www.shop-yishunbike.com, request: "POST/index.php?option=com_contact&view=contact&id=1&Itemid=210HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host:"............", referrer: "........................."

用site:()搜索:

site:(wdlinux.cn)recv() failed (104: Connection reset by peer)

谷歌百度對以上錯誤的搜索結果都是要修改php.ini,php-fpm.conf,nginx.conf等配置,結果都沒成功
回過頭來好好思考這2個錯誤提示,nginx的錯誤應該是由於nginx提交給php-fpm(127.0.0.1:9000)的請求沒有得到正確的回覆引起的,所以可能是php-fpm的問題。
所以想到重新編譯fpm-php,結果成功了

重新編譯過程:
參考wdcp中lanmp.sh腳本的安裝路徑:
./configure --prefix=$IN_DIR/$PHP_DIR--with-config-file-path=$IN_DIR/$PHP_DIR/etc --with-mysql=$IN_DIR/mysql--with-iconv=/usr --with-freetype-dir --with-jpeg-dir --with-png-dir--with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath--enable-discard-path --enable-inline-optimization --with-curl --enable-mbregex--enable-mbstring --with-mcrypt=/usr --with-gd --enable-gd-native-ttf--with-openssl --with-mhash --enable-ftp --enable-sockets --enable-zip $NV


再參考張宴大哥的那篇nginx文章,運行如下命令:
tarzxf php-5.4.13.tar.gz
cdphp-5.4.13
LIBS="-lm-ltermcap-lresolv"DYLD_LIBRARY_PATH="/www/wdlinux/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
LD_LIBRARY_PATH="/www/wdlinux/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"

#./configure階段,在後面加上-n選項不生成配置,僅測試是否能通過,通過的話去掉-n,再運行一次


./configure--prefix=/www/wdlinux/php2--with-config-file-path=/www/wdlinux/php2/etc--with-mysql=/www/wdlinux/mysql --with-mysqli=/www/wdlinux/mysql/bin/mysql_config--with-mcrypt=/usr --with-iconv-dir=/usr --with-libxml-dir=/usr--with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --enable-xml--disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem--enable-inline-optimization --with-curl --enable-mbregex --enable-fpm--enable-mbstring --with-gd --enable-gd-native-ttf --with-openssl --with-mhash--enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap -n
makeZEND_EXTRA_LIBS='-liconv'
makeinstall

關閉原來的php-fpm
/etc/init.d/php-fpmstop

打開新的php-fpm進程
/www/wdlinux/php2/sbin/php-fpm

打開contact us頁面,發送郵件,成功發送

 

 

3、lanmp一鍵包,wdcp後臺等故障排查法

雖然我測試的沒問題,但總還是有一些問題,也許是跟環境有關,又或許是跟操作有關。
請大家切記,務必按說明操作

首先用
netstat -lnpt
檢查有哪些端口

如果後臺打不開,從上面裏看有沒有8080端口
A 如果有,可能是防火牆的原因,iptables -L -n查看,或iptables -F清楚再打開
B 如果沒有,可能是沒啓動或是沒安裝成功,可以啓動看看,如service wdapache start

80,88,21都按如上所述的方法檢查
相關的目錄,啓動,說明請看
http://www.wdlinux.cn/bbs/thread-192-1-1.html

 

本文摘自wdlinux論壇http://www.wdlinux.cn/bbs/,歡迎轉載~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章