CentOS 6.4 System to compile the installation lnmp and configure the PHP environment specific steps _linux

Source: Internet
Author: User
Tags fpm http request mcrypt mkdir openssl pear phpinfo win32

First, preparatory work

Download Rmpforge on pkgs.org. Rpmforge is a third party yum source.

Select the appropriate version of the download installation.

After the installation is successful, clear the Yum list and retrieve it again

[Root@pangou desktop]# Yum Clean all

Loaded Plugins:fastestmirror, Refresh-packagekit, security

Cleaning repos:base Extras rpmforge Updates

Cleaning up Everything

Cleaning up list of fastest mirrors

[Root@pangou desktop]# yum-y List

Loaded Plugins:fastestmirror, Refresh-packagekit, security

Determining fastest Mirrors

// ......

Uninstall an existing Apache service and PHP

[Root@pangou desktop]# yum Remove httpd php*

Install development Tools

[Root@pangou desktop]# yum-y groupinstall "Development Tools"

Second, install Nginx

Create nginx directory, download Nginx, and unzip

[Root@pangou downloads]# mkdir Nginx

[Root@pangou downloads]# CD nginx/

[Root@pangou nginx]# pwd

/root/downloads/nginx

[Root@pangou nginx]# wget http://nginx.org/download/nginx-1.4.0.tar.gz

--2013-04-30 23:13:44--http://nginx.org/download/nginx-1.4.0.tar.gz

Resolving nginx.org ... 206.251.255.63

Connecting to nginx.org|206.251.255.63|:80 ... Connected.

HTTP request sent, awaiting response ... OK

length:773451 (755K) [Application/octet-stream]

Saving to: "Nginx-1.4.0.tar.gz"

100%[================================================================>] 773,451 184K/s in 4.5s

2013-04-30 23:13:48 (166 kb/s)-"nginx-1.4.0.tar.gz" saved [773451/773451]

[Root@pangou nginx]# ls

Nginx-1.4.0.tar.gz

[Root@pangou nginx]# TAR-ZXVF nginx-1.4.0.tar.gz

[Root@pangou nginx]# ls

nginx-1.4.0 nginx-1.4.0.tar.gz

Compile and install Nginx

Compiling the installation path/opt/nginx

[Root@pangou nginx-1.4.0]#./configure--prefix=/opt/nginx/

If the error occurs in the compilation, such as:

./configure:error:the HTTP Rewrite module requires the PCRE library.

Can either disable the module by using--without-http_rewrite_module

option, or install the PCRE library into the system, or build the PCRE library

Statically from the source with Nginx by using--with-pcre= option.

is to use Yum to own the outcome of the dependency relationship

[Root@pangou nginx-1.4.0]# yum install pcre pcre-devel

And then re-compile the top

Compiling the installation path/opt/nginx

[Root@pangou nginx-1.4.0]#./configure--prefix=/opt/nginx/

After successful compilation

[Root@pangou nginx-1.4.0]# make && make install

Final installation Complete

Start the Nginx service

[Root@pangou nginx]# cd/opt/nginx/sbin/

[Root@pangou sbin]#./nginx

Visit 127.0.0.1

The service started successfully.

Third, the installation of PHP

Create folders php, download PHP, and unzip

[Root@pangou nginx-1.4.0]# cd/root/downloads/

[Root@pangou downloads]# mkdir PHP

[Root@pangou downloads]# CD php/

[Root@pangou php]# pwd

/root/downloads/php

Download

[Root@pangou php]# wget Http://cn2.php.net/get/php-5.4.14.tar.gz/from/this/mirror

Extract

[Root@pangou php]# TAR-ZXVF php-5.4.14.tar.gz

Install Dependency Pack

[Root@pangou php]# yum install-y libxml2-devel libjpeg-devel libpng-devel freetype-devel openssl-devel libcurl-devel Lib Mcrypt-devel

Compiling PHP

[Root@pangou php]# ls

php-5.4.14 php-5.4.14.tar.gz

[Root@pangou php]# CD php-5.4.14

[Root@pangou php-5.4.14]# pwd

/root/downloads/php/php-5.4.14

[Root@pangou php-5.4.14]# ls

ACINCLUDE.M4 credits ltmain.sh NEWS README. Mailinglist_rules README. Testing stamp-h.in

ACLOCAL.M4 ext main pear readme.namespaces README. TESTING2 STUB.C

Build EXTENSIONS makedist php5.spec.in README. New-output-api README. Unix-build-system Svnclean.bat

buildconf footer Makefile.frag php.gif README. Parameter_parsing_api README. Win32-build-system Tests

Buildconf.bat generated_lists Makefile.gcov php.ini-development README. Php4-to-php5-thin-changes run-tests.php TSRM

Coding_standards genfiles makefile.global php.ini-production README. REDIST. Bins SAPI Upgrading

Config.guess header makerpm README. EXTENSIONS README. release_process scripts upgrading. Internals

Config.sub INSTALL missing README. Ext_skel README. Self-contained-extensions server-tests-config.php Vcsclean

Configure Install-sh Mkinstalldirs README. Git-rules README. STREAMS server-tests.php Win32

Configure.in LICENSE NetWare Readme.input_filter README. Submitting_patch Snapshot Zend

[Root@pangou php-5.4.14]#./configure--prefix=/opt/php--with-config-file-path=/opt/php/etc--with-mysql=/usr/-- With-mysqli=/usr/bin/mysql_config--with-iconv-dir--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib-- WITH-LIBXML-DIR=/USR--enable-xml--disable-rpath--enable-discard-path--enable-magic-quotes--enable-safe-mode-- Enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--with-curl--with-curlwrappers-- Enable-mbregex--enable-fastcgi--enable-fpm--enable-force-cgi-redirect--enable-mbstring--with-mcrypt-- Enable-ftp--with-gd--enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets--with-xmlrpc --enable-zip--enable-soap--without-pear--with-gettext--with-mime-magic

Compile time may be a bit long ...

After the compilation is successful, install

[Root@pangou php-5.4.14]# make && make install

The installation time is also very long

After the installation is successful, the location of PHP should be in the/opt/php directory, followed by the configuration

Copy the configuration file to the configuration directory

[Root@pangou php-5.4.14]# Cp/root/downloads/php/php-5.4.14/php.ini-production/opt/php/etc/php.ini

[Root@pangou php-5.4.14]# cp/opt/php/etc/php-fpm.conf.default/opt/php/etc/php-fpm.conf

[Root@pangou php-5.4.14]# cd/opt/php/etc/

[Root@pangou etc]# ls

php-fpm.conf Php-fpm.conf.default php.ini

Then configure the Nginx configuration file so that it can run PHP

[Root@pangou etc]# cd/opt/nginx/conf/

[Root@pangou conf]# ls

fastcgi.conf fastcgi_params koi-utf mime.types nginx.conf scgi_params uwsgi_params Win-utf

Fastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.default scgi_params.default Params.default

[Root@pangou conf]# Vim nginx.conf

1, remove #user nobody; #, become user nobody;

2, remove

#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_params;

#}

Before the # number,

and modify

Copy Code code as follows:

Fastcgi_param Script_filename/scripts$fastcgi_script_name;

For
Copy Code code as follows:

[/cfastcgi_param Script_filename/opt/nginx/html$fastcgi_script_name;
Ode
The final modified content is:
[Code]
Location ~ \.php$ {

root HTML;

Fastcgi_pass 127.0.0.1:9000;

Fastcgi_index index.php;

Fastcgi_param Script_filename/opt/nginx/html$fastcgi_script_name;

Include Fastcgi_params;

}



Restart the Nginx service and open the PHP-FPM

[Root@pangou ~]#/opt/nginx/sbin/nginx

[Root@pangou ~]#/OPT/PHP/SBIN/PHP-FPM

Creating Phpinfo Files

[Root@pangou ~]# vim/opt/nginx/html/phpinfo.php

Content is

Copy Code code as follows:

<?php
Phpinfo ();
?>

Visit http://127.0.0.1/phpinfo.php

The installation was successful. Mysql,mysqli and other extensions are available.

Here is a little lazy, and did not compile to install MySQL, but to use yum installed MySQL.

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.