Centos6.4 compiles the method to install nginx php

  • 2020-05-24 06:44:39
  • OfStack

1. Prepare a dependency library

Install make:


yum -y install gcc automake autoconf libtool make

Install g + + :


yum install gcc gcc-c++

2. Compile and install pcre

pcre is a library of regular expressions, and compiling nginx relies on this library to implement url rewrite

Download the source code


cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.bz2
tar jxvf pcre-8.33.tar.bz2

Compile the installation


cd pcre-8.33
./configure
make
make install

3. Compile and install the zlib library

zlib is an gzip implementation

Download the source code


cd /usr/local/src
wget http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz

Compile the installation


cd zlib-1.2.8
./configure
make
make install

4. Install openssl

Check if ssl is installed


# rpm -qa|grep openssl
openssl-devel-1.0.1e-16.el6_5.14.x86_64
openssl-1.0.1e-16.el6_5.14.x86_64

If not installed

Download the source code


cd /usr/local/src
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz

Compile the installation


./configure
make
make install

5. Compile and install nginx


cd /usr/local/src
wget http://nginx.org/download/nginx-1.2.8.tar.gz
tar -zxvf nginx-1.2.8.tar.gz
cd nginx-1.2.8

 ./configure --sbin-path=/usr/local/nginx/nginx \
 --conf-path=/usr/local/nginx/nginx.conf \
 --pid-path=/usr/local/nginx/nginx.pid \
 --with-http_ssl_module \
 --with-pcre=/usr/local/src/pcre-8.33 \
 --with-zlib=/usr/local/src/zlib-1.2.8 \
 --with-openssl=/usr/local/src/openssl-1.0.1c
 make
 make install

Verify whether the installation is successful after successful installation


yum install gcc gcc-c++
0

6. Compile and install php

php-fpm has been integrated into the new version of php

1. Preparation


yum install gcc gcc-c++
1

2. Source code compilation and installation of libmcrypt


yum install gcc gcc-c++
2

3. Download the source code


wget http://cn2.php.net/distributions/php-5.4.7.tar.gz
tar zvxf php-5.4.7.tar.gz

4. Compile and install cd php-5.4.7


yum install gcc gcc-c++
4

If the following error is reported


yum install gcc gcc-c++
5

Modify/etc/ld. so. conf file


yum install gcc gcc-c++
6

Execute the command again

Compile and install after success

7. Configure startup

1. Configuration php - fpm


yum install gcc gcc-c++
7

Modify the
user = llong
group = llong

2. Modify nginx to support php-fpm

Open the nginx conf

In the server segment, the following configuration is added. Note the red content configuration, otherwise, No input file specified


# 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 $document_root$fastcgi_script_name;
include fastcgi_params;
}

3. Test whether the configuration is successful

Under/usr local/nginx/html create index. php file, enter the following content


yum install gcc gcc-c++
9

Start php-fpm and nginx


/usr/local/php/sbin/php-fpm ( Manual patching startup mode /usr/local/php/sbin/php-fpm start)
 /usr/local/nginx/nginx

Related articles: