search
HomeBackend DevelopmentPHP TutorialDetailed introduction to the Centos6.4 compilation and installation nginx php code example method

This article mainly introduces the method of compiling and installing nginx php in Centos6.4. Friends who need it can refer to

1. Prepare dependent libraries

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 regular expression library. Compiling nginx needs to rely on this library to implement url rewrite

Download 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 and install

cd pcre-8.33
./configure
make
make install

3. Compile and install zlib library

zlib is a gzip implementation

Download source code

cd /usr/local/src
wget http://www.php.cn/
tar -zxvf zlib-1.2.8.tar.gz

Compile and install

cd zlib-1.2.8
./configure
make
make install

IV. 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 source code

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

Compile and install

./configure
make
make install

5. Compile and install nginx

cd /usr/local/src
wget http://www.php.cn/
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

After the installation is completed, verify whether the installation is successful

/usr/local/nginx/nginx 
netstat -alptn|grep 80

6. Compile and install php

The new version of php has been integrated with php-fpm

1. Preparation

yum -y install libmcrypt-devel mhash-devel libxslt-devel\
 libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel\
 zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel\
 ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel\
 krb5 krb5-devel libidn libidn-devel openssl openssl-devel

2. Compile and install libmcrypt

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz
tar -zxvf libmcrypt-2.5.7.tar.gz 
cd libmcrypt-2.5.7 
./configure
make
make install

3. Download the source code

wget http://www.php.cn/
tar zvxf php-5.4.7.tar.gz

4. Compile and install cd php-5.4.7

./configure --prefix=/usr/local/php      \
   --enable-fpm         \
   --enable-mbstring        \
   --enable-sockets        \
   --enable-sysvsem        \
   --enable-sysvshm        \
   --enable-pcntl         \
   --enable-mbregex        \
   --enable-zip         \
   --enable-inline-optimization     \
   --disable-pdo         \
   --disable-debug        \
   --disable-rpath        \
   --with-mcrypt         \
   --with-zlib         \
   --with-bz2          \
   --with-mhash         \
   --with-curl         \
   --with-mysql         \
   --with-gd          \
   --with-pcre-regex        \
   --with-libdir=lib64

If the following error is reported

configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no

Modify the /etc/ld.so.conf file

vi /etc/ld.so.conf.d/local.conf
#添加2行
/usr/local/lib64 //64系统
/usr/local/src/libmcrypt-2.5.7/lib/.libs

#执行以下命令
chmod gu+x /etc/ld.so.conf.d/local.conf
#执行以下命令使生效
ldconfig -v

Execute the command again

Compile and install after success

7. Configuration startup

1. Configure php-fpm

cd /usr/local/php
cp /etc/php-fpm.conf.default /etc/php-fpm.conf
vi /etc/php-fpm.conf

Modify
user = llong
group = llong

2. Modify nginx to support php-fpm

Open nginx.conf

Add the following configuration to the server section, pay attention to the red content configuration, otherwise No input will appear file specified.Error

# 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

Create the index.php file under /usr/local/nginx/html , enter the following content

<? 
echo phpinfo(); 
?>

Start php-fpm and nginx

/usr/local/php/sbin/php-fpm (手动打补丁的启动方式/usr/local/php/sbin/php-fpm start)
 /usr/local/nginx/nginx

The above is the details of the Centos6.4 compilation and installation nginx php code example method The content of the introduction, for more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Explain how load balancing affects session management and how to address it.Explain how load balancing affects session management and how to address it.Apr 29, 2025 am 12:42 AM

Load balancing affects session management, but can be resolved with session replication, session stickiness, and centralized session storage. 1. Session Replication Copy session data between servers. 2. Session stickiness directs user requests to the same server. 3. Centralized session storage uses independent servers such as Redis to store session data to ensure data sharing.

Explain the concept of session locking.Explain the concept of session locking.Apr 29, 2025 am 12:39 AM

Sessionlockingisatechniqueusedtoensureauser'ssessionremainsexclusivetooneuseratatime.Itiscrucialforpreventingdatacorruptionandsecuritybreachesinmulti-userapplications.Sessionlockingisimplementedusingserver-sidelockingmechanisms,suchasReentrantLockinJ

Are there any alternatives to PHP sessions?Are there any alternatives to PHP sessions?Apr 29, 2025 am 12:36 AM

Alternatives to PHP sessions include Cookies, Token-based Authentication, Database-based Sessions, and Redis/Memcached. 1.Cookies manage sessions by storing data on the client, which is simple but low in security. 2.Token-based Authentication uses tokens to verify users, which is highly secure but requires additional logic. 3.Database-basedSessions stores data in the database, which has good scalability but may affect performance. 4. Redis/Memcached uses distributed cache to improve performance and scalability, but requires additional matching

Define the term 'session hijacking' in the context of PHP.Define the term 'session hijacking' in the context of PHP.Apr 29, 2025 am 12:33 AM

Sessionhijacking refers to an attacker impersonating a user by obtaining the user's sessionID. Prevention methods include: 1) encrypting communication using HTTPS; 2) verifying the source of the sessionID; 3) using a secure sessionID generation algorithm; 4) regularly updating the sessionID.

What is the full form of PHP?What is the full form of PHP?Apr 28, 2025 pm 04:58 PM

The article discusses PHP, detailing its full form, main uses in web development, comparison with Python and Java, and its ease of learning for beginners.

How does PHP handle form data?How does PHP handle form data?Apr 28, 2025 pm 04:57 PM

PHP handles form data using $\_POST and $\_GET superglobals, with security ensured through validation, sanitization, and secure database interactions.

What is the difference between PHP and ASP.NET?What is the difference between PHP and ASP.NET?Apr 28, 2025 pm 04:56 PM

The article compares PHP and ASP.NET, focusing on their suitability for large-scale web applications, performance differences, and security features. Both are viable for large projects, but PHP is open-source and platform-independent, while ASP.NET,

Is PHP a case-sensitive language?Is PHP a case-sensitive language?Apr 28, 2025 pm 04:55 PM

PHP's case sensitivity varies: functions are insensitive, while variables and classes are sensitive. Best practices include consistent naming and using case-insensitive functions for comparisons.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor