Build a basic platform for nginx + php in vmlinux

Source: Internet
Author: User
Tags nginx host
Nginx is a very popular lightweight web server building platform. Compared with the classic apache, Nginx cannot match its functions at all, however, Nginx has already taken the lead in some areas with specific business requirements. Because of the increasing attention to service quality, the first thing to consider is to optimize services on the original device platform.

Nginx is a very popular lightweight web server building platform. Compared with the classic apache, Nginx cannot match its functions at all, however, Nginx has already taken the lead in some areas with specific business needs, because today, with increasing attention to service quality, the first thing to consider is to make optimal service provision on the original device platform. The development of Nginx can be said to be in line with this trend and stand out with its low demand for hardware devices. Nginx currently uses the Fast-cgi technology. This platform is as good as the APIs used by IIS in windows!

Experiment Platform RHEL5.4 (Red Hat) configure the yum source before the experiment

Software Used

Nginx-1.1.4.tar.gz

Php-5.2.17-fpm-0.5.14.Diff. Gz (software used for connection, a patch)
Php-5.2.17.tar.gz

Experiment process:

I. Nginx installation and configuration

[Root @ localhost ~] # Yum-y install prce *
[Root @ localhost ~] # Tar zxvf nginx-1.1.4.tar.gz

[Root @ localhost nginx-1.1.4] #./configure -- prefix =/usr/local/nginx

[Root @ localhost nginx-1.1.4] # make & make install

[Root @ localhost ~] #Cd/Usr/local/nginx/html/
[Root @ localhost html] # vi indEx. Php
Phpinfo ();
?>
[Root @ localhost html] # cd ../conf/
[Root @ localhost conf] # vi nginx. conf (the local address and webpage path are in red)

LoCatIon ~ \. Php $ {
Root html;
Fastcgi_pass 192.168.1.192: 9000 ;//
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/usr/local/nginx/html $ fastcgi_script_name;
INcLude fastcgi_params;
[Root @ localhost conf] # cd/etc/init. d/
[Root @ localhost init. d] # vi nginxd (write the started shell)

#! /Bin/bash
# Author ethnicity (Just a check of others)
# Time 2011-9-24
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/var/run/nginx. pid
}

# Reload nginx service functions.
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

[Root @ localhost init. d] #Chkconfig--DdNginxd

[Root @ localhost init. d] # chkconfig nginxd on

[Root @ localhost ~] # Service nginxd restart
Stopping nginx: [OK]
Starting nginx: [OK]

Ii. php configuration

[Root @ localhost ~] # Tar zxvf php-5.2.17.tar.gz

[Root @ localhost ~] # GZip-Php-5.2.17-fpm-0.5.14.diff.gz cd |Patch-D php-5.2.17-p1 // patching steps

[Root @ localhost php-5.2.17] #./configure -- prefix =/usr/local/php-5.2.17 --Enable-Fastcgi -- enable-fpm

[Root @ localhost php-5.2.17] # make & make install
[Root @ localhost ~] # Cd/usr/local/php-5.2.17/etc/
[Root @ localhost etc] # viPhp-fpm. Conf (find and modify the following statement)

  192.168.1.192: 9000 // The actual IP address of the Local Machine

Unix user of processes Nobody

Unix group of processes Nobody

192.168.1.192 // This IP address is the IP address of the Nginx host. It is installed on the same machine, so the same ip address is used.

[Root @ localhost etc] # cd ~ Php-5.2.17
[Root @ localhost php-5.2.17] #CpPhp. ini-recommended/usr/local/lib/php. ini (set the main configuration file of php)

[Root @ localhost sbin] #./php-fpm restart (enable monitoring)
Shutting down php_fpm done
Starting php_fpm. done

Iii. Test part

[Root @ localhost ~] #/Etc/init. d/nginxd restart
Stopping nginx: [OK]
Starting nginx: [OK]
[Root @ localhost ~] #/Usr/local/php-5.2.17/sbin/php-fpm restart
Shutting down php_fpm. done
Starting php_fpm done
Enter http: // 192.168.1.192/index. php In the IE address bar to display the php classic test webpage!

Here is a test of the combination of Nginx and php. Next we need to add the dynamic part, which will be implemented in subsequent experiments!


 

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.