Configure the PHP environment and install LNMP in CentOS6.4 system

Source: Internet
Author: User
1. download rmpforge from pkgs.org. Rpmforge is a third-party yum source. Select a version to download and install. // After the installation is successful, clear yumlist and obtain [root @ pangouDesktop] # yumcleanallLoadedplugins: fastestmirror, refresh-packagekit, se

I. preparations

Download rmpforge from pkgs.org. Rpmforge is a third-party yum source.

Select a version to download and install.

// After the installation is successful, clear the yum list and obtain 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 the existing apache service and php

[Root @ pangou Desktop] # yum remove httpd php *

Install development Tools

[Root @ pangou Desktop] # yum-y groupinstall "DevelopmentTools"

II. InstallationNginx

Create the nginx Directory, download nginx, and decompress

[Root @ pangou Downloads] # mkdir nginx

[Root @ pangou Downloads] # cd nginx/

[Root @ pangou nginx] # pwd

/Root/Downloads/nginx

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

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

Resolving nginx.org... 206.251.20.63

Connecting to nginx.org | 206.251.20.63 |: 80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 773451 (755 K) [application/octet-stream]

Saving to: “nginx-1.4.0.tar.gz"

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

23:13:48 (166 KB/s)-invalid 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

// Compile and install the path/opt/nginx

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

If an error occurs during compilation, such:

./Configure: error: the HTTP rewrite module requires the PCRElibrary.

You can either disable the module by using -- without-http_rewrite_module

Option, or install the PCRE library into the system, or buildthe PCRE library

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

Is to use yum to determine dependencies

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

Then re-compile the above

// Compile and install the path/opt/nginx

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

// After compilation is successful

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

// The installation is complete.

Start the nginx service

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

[Root @ pangou sbin] #./nginx

Access 127.0.0.1

The service is started successfully.

3. install php

Create a php folder, Download php, and decompress

[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] # wgethttp: // 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 packages

[Root @ pangou php] # yum install-y libxml2-devel libjpeg-devellibpng-devel freetype-devel openssl-devel libcurl-devellibmcrypt-devel

Compile 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_RULESREADME.TESTING stamp-h.in

Aclocal. m4 ext main pear README. namespaces README. TESTING2stub. c

Build EXTENSIONS makedist php5.spec. in README.NEW-OUTPUT-APIREADME.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. gcovphp. ini-development README.PHP4-TO-PHP5-THIN-CHANGES run-tests.phpTSRM

Coding_standsas genfiles Makefile. global php. ini-productionREADME.REDIST.BINS sapi UPGRADING

Config. guess header makerpm README. EXTENSIONSREADME. RELEASE_PROCESS scripts UPGRADING. INTERNALS

Config. sub INSTALL missing README.EXT_SKELREADME.SELF-CONTAINED-EXTENSIONS server-tests-config.phpvcsclean

Configure install-sh mkinstalldirs README.GIT-RULESREADME.STREAMS server-tests.php win32

Configure. in LICENSE netware README. input_filterREADME.SUBMITTING_PATCH snapshot Zend

[Root @ pangou php-5.4.14] #./configure -- prefix =/opt/php -- with-config-file-path =/opt/php/etc ---Mysql=/Usr/---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 --- xmlrpc -- enable-zip -- enable-soap -- without-pear -- with-gettext -- with-mime-magic

// Compilation time may be a little long...

// After compilation is successful, install

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

// Installation time is also relatively long

After the installation is successful, the php location 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

// 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. confscgi_params uwsgi_params win-utf

Fastcgi. conf. default fastcgi_params.default koi-winmime.types.default nginx. conf. default scgi_params.defaultuwsgi_params.default

[Root @ pangou conf] # vim nginx. conf

1. remove the # sign of # user nobody; and change it to 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;

#}

Previous,

And modify

Fastcgi_param SCRIPT_FILENAME/scripts $ fastcgi_script_name;

Is

Fastcgi_param SCRIPT_FILENAME/opt/nginx/html $ fastcgi_script_name;

The modified content is as follows:

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 enable php-fpm.

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

[Root @ pangou ~] #/Opt/php/sbin/php-fpm

// Create a phpinfo file

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

Content is

Phpinfo ();

?>

Access http: // 127.0.0.1/phpinfo. php

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

I am a little lazy here. I didn't compile and install mysql, but I used mysql installed in yum.

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.