1 minute perfect installation of the latest CentOS + Nginx + PHP-FPM + MySQL_PHP tutorial

Source: Internet
Author: User
Tags tidy epel repo
1 minute perfect installation of the latest CentOS + Nginx + PHP-FPM + MySQL. PHP5.3.1MySQL5.0.89Nginx0.8.33 or 0.7.65 (optional) now, we can quickly and fully automated get CentOS + Nginx + PHP-FPM + MySQL installed this comparable to what circulated on the Internet one click PHP 5.3.1

MySQL 5.0.89

Nginx 0.8.33 or 0.7.65 (optional)

Now, we can do this quickly and automatically.CentOS + Nginx + PHP-FPM + MySQLInstalled

This is much better than what one-click installation package is available on the internet. it is strongly recommended that this installation method be suitable for all Cainiao and experts.

It's hard to compile and install all the source code used on my server.

I have installed some common extensions including PHP, PDO, eaccelerator, memcache, and tidy.

Create a repo first

  
  
  1. # vi /etc/yum.repos.d/centos.21andy.com.repo
 

Add the following content

 
 
  1. [21Andy.com]
  2. name=21Andy.com Packages for Enterprise Linux 5 - $basearch
  3. baseurl=http://www.21andy.com/centos/5/$basearch/
  4. enabled=1
  5. gpgcheck=0
  6. protect=1

Enable EPEL repo

I386

 
 
  1. rpm -ihv
  2. http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

X86_64

 
 
  1. rpm -ihv
  2. http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

Import key

 
 
  1. rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL

All right, one-click installation

 
 
  1. # yum install nginx php-fpm mysql-server

If you want to use the latest stable version of nginx 0.7.65, replace yum-y install nginx with yum-y install nginx-stable.

More complete installation

 
 
  1. Yum-y update
  2. Yum-y mysql-server
  3. Service mysqld start
  4. Mysqladmin-u root password root
  5. Service mysqld stop
  6. Yum-y install nginx php-fpm
  7. Php-cli php-pdo php-mysql php-mcrypt php-mbstring
  8. Php-gd php-tidy php-xml php-xmlrpc
  9. Php-pear php-pecl-memcache php-eaccelerator
  10. # APC conflicts with eAccelerator. Select 2 and select 1.
  11. Yum-y install php-pecl-apc

Let's take a look at my complete installation.

Yum-y install nginx mysql-server php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php- pear php-pecl-memcache php-eaccelerator

Installation result, fully automated

 
 
  1. Dependencies Resolved
  2. ==========================================================
  3. Package Arch Version Repository Size
  4. ==========================================================
  5. Installing:
  6. mysql x86_64 5.0.89-1.el5 21Andy.com 3.5 M
  7. mysql-server x86_64 5.0.89-1.el5 21Andy.com 10 M
  8. nginx x86_64 0.8.33-3.el5 21Andy.com 422 k
  9. php-cli x86_64 5.3.1-2.el5 21Andy.com 2.4 M
  10. php-eaccelerator x86_64 2:0.9.6-1.el5 21Andy.com 118 k
  11. php-fpm x86_64 5.3.1-2.el5 21Andy.com 1.2 M
  12. php-gd x86_64 5.3.1-2.el5 21Andy.com 110 k
  13. php-mbstring x86_64 5.3.1-2.el5 21Andy.com 1.1 M
  14. php-mcrypt x86_64 5.3.1-2.el5 21Andy.com 27 k
  15. php-mysql x86_64 5.3.1-2.el5 21Andy.com 84 k
  16. php-pdo x86_64 5.3.1-2.el5 21Andy.com 91 k
  17. php-pear noarch 1:1.9.0-1.el5 21Andy.com 420 k
  18. php-pecl-memcache x86_64 2.2.5-3.el5 21Andy.com 44 k
  19. php-tidy x86_64 5.3.1-2.el5 21Andy.com 31 k
  20. php-xml x86_64 5.3.1-2.el5 21Andy.com 115 k
  21. php-xmlrpc x86_64 5.3.1-2.el5 21Andy.com 48 k
  22. Installing for dependencies:
  23. gmp x86_64 4.1.4-10.el5 base 201 k
  24. libXaw x86_64 1.0.2-8.1 base 329 k
  25. libXmu x86_64 1.0.2-5 base 63 k
  26. libXpm x86_64 3.5.5-3 base 44 k
  27. libedit x86_64 2.11-2.20080712cvs.el5 epel 80 k
  28. libmcrypt x86_64 2.5.8-4.el5.centos extras 105 k
  29. libtidy x86_64 0.99.0-14.20070615.el5 epel 140 k
  30. php-common x86_64 5.3.1-2.el5 21Andy.com 554 k
  31. sqlite2 x86_64 2.8.17-5.el5 21Andy.com 165 k
  32. t1lib x86_64 5.1.1-7.el5 epel 208 k
  33. Updating for dependencies:
  34. libevent x86_64 1.4.12-1.el5 21Andy.com 129 k
  35. Transaction Summary
  36. ==========================================================
  37. Install 26 Package(s)
  38. Update 1 Package(s)
  39. Remove 0 Package(s

Last as longYum-y updateIt's all the latest

Don't forget to start

 
 
  1. chkconfig --level 345 mysqld on
  2. chkconfig --level 345 php-fpm on
  3. chkconfig --level 345 nginx on

Let's take a look at the strong results of my virtual machine testing.

Http://www.21andy.com/blog/20100219/1703.html

Supplement: All the configuration files are under the/etc directory, including the nginx, php-fpm, and mysql configuration files. please find your own settings. The following is an example of my nginx configuration.

Create a new/WwwDirectories, websites, and logs are all stored here.

Do not forget to create a log storage directory, which is used by access_log in the configuration file./Www/logs

Note: fastcgi_params must be added to this line.

# Vim/etc/nginx/fastcgi_params

  
 
  1. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

# Vi/etc/nginx. conf

 
 
  1. User nobody;
  2. Worker_processes 8; # Here, based on your CPU and memory configuration, set both 2 and 10 OK
  3. Error_log/Www/logs/nginx_error.log crit;
  4. Pid/usr/local/nginx/logs/nginx. pid;
  5. # Specifies the valueForMaximum file descriptors that can be opened by this process.
  6. Worker_rlimit_nofile 51200;
  7. Events {
  8. UseEpoll;
  9. Worker_connections 51200;
  10. }
  11. Http {
  12. IncludeMime. types;
  13. Default_type application/octet-stream;
  14. # Charse gb2312; # default encoding, which can be left unspecified
  15. Server_names_hash_bucket_size 128;
  16. Client_header_buffer_size 16 k;
  17. Large_client_header_buffers 4 16 k;
  18. Client_max_body_size 8 m;
  19. Sendfile on;
  20. Tcp_nopush on;
  21. Keepalive_timeout 60;
  22. Tcp_nodelay on;
  23. Fastcgi_connect_timeout 300;
  24. Fastcgi_send_timeout 300;
  25. Fastcgi_read_timeout 300;
  26. Fastcgi_buffer_size 64 k;
  27. Fastcgi_buffers 4 64 k;
  28. Fastcgi_busy_buffers_size 128 k;
  29. Fastcgi_temp_file_write_size 128 k;
  30. Gzip on;
  31. Gzip_min_length 1 k;
  32. Gzip_buffers 4 16 k;
  33. Gzip_http_version 1.0;
  34. Gzip_comp_level 5;
  35. Gzip_types text/plain text/javascript application/x-javascript text/css application/xml;
  36. Gzip_vary on;
  37. # Limit_zone crawler$ Binary_remote_addr10 m;
  38. Server {
  39. Listen 80;
  40. Server_name localhost;
  41. Root/www;
  42. Location/status {
  43. Stub_status on;
  44. Access_log off;
  45. }
  46. Location /{
  47. # Here we will convert all non-existing files and directories to index. php for processing.
  48. Try_files$ Uri $ Uri// Index. php? Q =$ Uri&$ Args;
  49. }
  50. # Put it here separately to the server. conf for convenience during server activation and unified calling. put it in the/etc/nginx/directory.
  51. IncludeServer. conf;
  52. Log_format access'$ Remote_addr-$ remote_user [$ time_local] "$ request "'
  53. '$ Status $ body_bytes_sent "$ http_referer "'
  54. '"$ Http_user_agent" $ http_x_forwarded_for';
  55. Access_log/www/logs/access. log access;
  56. }
  57. Server {
  58. Listen 80;
  59. Server_name www.21andy.com 21andy.com * .21andy.com;
  60. Root/www/21andy.com;
  61. If($ Host!~ * 21andy.com $ ){
  62. Return444;
  63. }
  64. Location /{
  65. Try_files$ Uri $ Uri// Index. php? Q =$ Uri&$ Args;
  66. }
  67. IncludeServer. conf; # reuse here, which saves time
  68. Access_log/www/logs/21andy.com _ access. log access;
  69. }
  70. }

# Vi/etc/nginx/server. conf

 
 
  1. index index.html index.htm index.php;
  2. #limit_conn crawler 20;
  3. location ~ /.ht {
  4. deny all;
  5. }
  6. location ~ .*.(sqlite|sq3)$ {
  7. deny all;
  8. }
  9. location ~ .*.php$ {
  10. fastcgi_pass unix:/tmp/php-cgi.sock;
  11. #fastcgi_pass 127.0.0.1:9000;
  12. fastcgi_index index.php;
  13. include fastcgi_params;
  14. }
  15. location ~ .*.(gif|jpg|jpeg|png|bmp|swf|ico)$ {
  16. expires 30d;
  17. access_log off;
  18. }
  19. location ~ .*.(js|css)?$ {
  20. expires 30d;
  21. access_log off;
  22. }

The following content can be skipped

You can also use the following settings for php-fpm, but we recommend that you use the settings above, which is relatively stable.

 
 
  1. Location ~ . Php $ {
  2. Root/www;
  3. Fastcgi_pass 127.0.0.1: 9000;
  4. Fastcgi_index index. php;
  5. # Add the following line to/etc/nginx/fastcgi_params.
  6. # Fastcgi_param SCRIPT_FILENAME$ Document_root$ Fastcgi_script_name;
  7. IncludeFastcgi_params;
  8. }

Both nginx and php-fpm must be set to the same either by using the php-cgi.sock or port 9000 method

Nginx settings have been mentioned above, remember to modify the php-fpm.conf at the same time the corresponding place

# Vi/etc/php-fpm.conf

 
  127.0.0.1:9000
 

Or

 
  unix:/tmp/php-cgi.sock
 

Original article address:Http://www.21andy.com/blog/20100219/1701.html


Http://www.bkjia.com/PHPjc/445841.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445841.htmlTechArticlePHP 5.3.1 MySQL 5.0.89 Nginx 0.8.33 or 0.7.65 (optional) now, we can quickly and fully automated get CentOS + Nginx + PHP-FPM + MySQL installed this comparable to what one-click spread on the internet...

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.