Tengine + mysql + nginx + PHP

Source: Internet
Author: User
Tags openssl iptables

Tengine + mysql + nginx + PHP

1. Configure the Firewall
Vim/etc/sysconfig/iptables

# Allow 80 ports to pass through the firewall
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
# Allow 3306 ports to pass through the firewall
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT
# allow 21 ports to pass through the firewall
-A input-p tcp-m state-m tcp--dport--state new-j ACCEPT
# Disable Ping
-A input-p ICMP--icmp-type 8-s 0/0-j DROP

Note:
Adding the configuration needs to be prevented between commit code

Reboot:
/etc/init.d/iptables restart

2, Installation Tengine
2.1 Updating Yum
Yum Update
2.2 Remove the package that comes with the system
Yum Remove httpd* php*
Compiling libraries
Yum Install gcc-c++

Installing dependent libraries
Yum-y install zlib zlib-devel OpenSSL openssl-devel pcre pcre-devel

Installing the Ngx_cache_purge module
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

# download Tengine
Cd/usr/local/lib

wget http://tengine.taobao.org/download/tengine-2.0.3.tar.gz
# Unzip, rename, delete Tengine package
TAR-ZXVF tengine-2.0.3.tar.gz && RM-RF tengine-2.0.3.tar.gz

Installing 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

Set boot up
Vi/etc/rc.d/init.d/nginx
Edit the startup file to add the following content
#!/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 are 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 "$" 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

Add Users, Groups
/usr/sbin/groupadd-f Nginx
/usr/sbin/useradd-g Nginx Nginx

/*
Execute Start Error
[Email protected] tengine-2.0.3]#/etc/rc.d/init.d/nginx restart
stopping nginx: [FAILED]
Starting Nginx:nginx: [Emerg] Getpwnam ("Nginx") failed
[FAILED]
Solve:

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

3. mysql Installation
Installation
Yum install MySQL Mysql-server
Start
/etc/init.d/mysqld start
Set boot up
Chkconfig mysqld on


4, Installation PHP5

# Enter Y as prompted until the installation is complete

Yum Install PHP php-fpm

# Here to install the above installation package, according to the prompt input y enter

Yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-b Cmath Php-mhash Libmcrypt

# Set PHP-FPM boot up

Chkconfig PHP-FPM on

# Boot PHP-FPM (restart: Restart, stop: Stop, start: ON)

/ETC/INIT.D/PHP-FPM (Restart|stop|start)

Service PHP-FPM (Restart|stop|start)

5, Configuration Nginx support PHP

Modify Nginx Configuration
Vi/usr/local/nginx/conf/nginx.conf
Remove
Remove Pre-PHP configuration
# 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;
}

Also modify the Fastcgi_param path to point the path to the php file directory

New PHP file

<?php phpinfo ()?>

Re-start Nginx

Configuration complete

Reference http://www.cnblogs.com/hzh1990/p/3570453.html

Tengine + mysql + nginx + PHP

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.