One, operating system
Install the system in the form of a minimal server, and add a development tool library for later compilation and use.
Here is basically the next step, the next step, no more nonsense.
After the installation is complete, enter the system, adjust the network, close the firewall or open the corresponding WEB port.
The following installation operations are performed in the /root directory by default.
Second, nginx installation
Download pcre and zlib, everyone on earth knows…
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.tar.gz
tar -zxvf pcre-8.32.tar.gz
cd pcre-8.32
./configure
make && make install
wget http://zlib.net/zlib-1.2.7.tar.gz
tar -zxvf zlib-1.2.7.tar.gz
cd zlib-1.2.7
./configure
make && make install
Download the current latest stable version nginx-1.2.7
cd
wget http://nginx.org/download/nginx-1.2.7.tar.gz
tar -zxvf nginx-1.2.7.tar.gz
cd nginx-1.2.7
./configure –prefix=/usr/local/nginx/
–with-pcre=/root/pcre-8.32
–with-zlib=/root/zlib-1.2.7
make && make install
/usr/local/nginx/sbin/nginx
Started, open the browser to test nginx.
Three, install the PHP environment
Download the current stable version php-5.3.22
wget
http://www.php.net/get/php-5.3.22.tar.gz/from/cn1.php.net/mirror
tar -zxvf php-5.3.22.tar.gz
Before starting to compile, install some basic php packages and install them directly with yum.
yum -y install gd curl curl-devel libjpeg libjpeg-devel libpng
libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql
mysql-devel
When ready, go to the php directory to compile
cd php-5.3.22
./configure –prefix=/usr/local/php –enable-fastcgi
–enable-fpm –enable-debug –with-gd –with-jpeg-dir
–with-png-dir –with-freetype-dir –enable-mbstring –with-curl
–with-mysql=/usr/bin/mysql –with-mysqli=/usr/bin/mysql_config
make && make install
cp php.ini-development /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default
/usr/local/php/etc/php-fpm.conf
After the installation is complete, you can start php
/usr/local/php/sbin/php-fpm
After running, no error was prompted and the startup was successful.
Fourth, associate nginx and php
Open the nginx configuration file and find the following configuration
vi /usr/local/nginx/conf/nginx.conf
# location ~
\.php${
#
root
html;
#
fastcgi_pass 127.0.0.1:9000;
#
fastcgi_index index.php;
#
fastcgi_param SCRIPT_FILENAME
/scripts$fastcgi_script_name;
#
include
fastcgi_param;
# }
Remove the comment from this configuration and change include fastcgi_param to include fastcgi.conf
Save and restart nginx
/usr/local/nginx/sbin/nginx -s reload
The default web directory is the html folder, create a new test file below
touch /usr/local/nginx/html/test.php
vi /usr/local/nginx/html/test.php
Write
After saving, visit the page in the browser, if the php configuration information is displayed, you’re done.