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 "Development Tools"
Ii. Install nginx
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] # wget http://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 PCRE library.
You 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 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] # 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 packages
[Root @ pangou php] # yum install-y libxml2-devel libjpeg-devel libpng-devel freetype-devel openssl-devel libcurl-devel libmcrypt-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_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 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
// 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. conf scgi_params uwsgi_params win-utf
Fastcgi. conf. default fastcgi_params.default koi-win mime. types. default nginx. conf. default scgi_params.default uwsgi_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
Copy codeThe Code is as follows: fastcgi_param SCRIPT_FILENAME/scripts $ fastcgi_script_name;
IsCopy codeThe Code is as follows: [/cfastcgi_param SCRIPT_FILENAME/opt/nginx/html $ fastcgi_script_name;
Ode]
The modified content is as follows:
[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 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
Copy codeThe Code is as follows: <? Php
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.