tengine + mysql + nginx + php

來源:互聯網
上載者:User

標籤:

tengine + mysql + nginx + php

1、配置防火牆
vim /etc/sysconfig/iptables

# 允許80連接埠通過防火牆
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
# 允許3306連接埠通過防火牆
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
# 允許21連接埠通過防火牆
-A INPUT -p tcp -m state -m tcp --dport 21 --state NEW -j ACCEPT
# 禁用ping
-A INPUT -p icmp --icmp-type 8 -s 0/0 -j DROP

備忘:
添加配置需要防止於commit代碼之間

重新啟動:
/etc/init.d/iptables restart

2、安裝tengine
2.1 更新 yum
yum update
2.2 刪除系統內建的軟體包
yum remove httpd* php*
編譯庫
yum install gcc-c++

安裝依賴庫
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel

安裝ngx_cache_purge模組
cd /usr/local
wget http://labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz
tar -zxvf ngx_cache_purge-2.1.tar.gz
rm -rf ngx_cache_purge-2.1.tar.gz

# 下載Tengine
cd /usr/local/lib

wget http://tengine.taobao.org/download/tengine-2.0.3.tar.gz
# 解壓,重新命名,刪除tengine包
tar -zxvf tengine-2.0.3.tar.gz && rm -rf tengine-2.0.3.tar.gz

安裝Tengine

cd tengine-2.0.3 && ./configure --add-module=/usr/local/ngx_cache_purge-2.1 --with-http_stub_status_module --prefix=/usr/local/nginx --user=nginx --group=nginx && make && make install

設定開機啟動
vi /etc/rc.d/init.d/nginx
編輯開機檔案添加下面內容
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it‘s not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/usr/local/nginx/logs/nginx.pid
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
echo "nginx already running...."
exit 1
fi
echo -n $"Starting $prog: "
daemon $nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n $"Stopping $prog: "
killproc $nginxd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid
}
reload() {
echo -n $"Reloading $prog: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;

status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
exit 1
esac
exit $RETVAL


#賦執行許可權
chmod 775 /etc/rc.d/init.d/nginx

#設定開機啟動

chkconfig --level 012345 nginx on

添加使用者,組
/usr/sbin/groupadd -f nginx
/usr/sbin/useradd -g nginx nginx

/*
執行啟動報錯
[[email protected] tengine-2.0.3]# /etc/rc.d/init.d/nginx restart
Stopping nginx: [FAILED]
Starting nginx: nginx: [emerg] getpwnam("nginx") failed
[FAILED]
解決:

/usr/sbin/groupadd -f nginx
/usr/sbin/useradd -g nginx nginx
*/

3、mysql安裝
安裝
yum install mysql mysql-server
啟動
/etc/init.d/mysqld start
設定開機啟動
chkconfig mysqld on


4、安裝PHP5

 

 

# 根據提示輸入Y直到安裝完成

yum install php php-fpm

 

# 這裡選擇以上安裝包進行安裝,根據提示輸入Y斷行符號

yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt

 

# 設定php-fpm開機啟動

chkconfig php-fpm on

 

# 啟動php-fpm (restart:重啟, stop:停止, start:啟動)

/etc/init.d/php-fpm (restart|stop|start)

service php-fpm (restart|stop|start)

 

5、配置nginx支援php

修改nginx 配置
vi /usr/local/nginx/conf/nginx.conf
去除
去除php前配置
# 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 /www/php$fastcgi_script_name;
include fastcgi_params;
}

同時修改 fastcgi_param 路徑 ,將該路徑指向PHP 檔案目錄

建立php檔案

<?php phpinfo()?>

重新啟動 nginx

配置完成

參考http://www.cnblogs.com/hzh1990/p/3570453.html

 

tengine + mysql + nginx + php

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.