1-minute installation of the latest CentOS + Nginx + PHP-FPM + MySQL

Source: Internet
Author: User
Tags apc tidy epel repo
This is much better than what one-click installation package has been circulated on the internet. it is strongly recommended that this method be installed. it is suitable for all Cainiao and experts. it is good to compile and install all the source code on my server.

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 + MySQL.

This is much better than what one-click installation package has been circulated on the internet. it is strongly recommended that this method be installed. it is suitable for all Cainiao and experts. it is difficult to compile and install all the source code on my server.

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

This article is 21andy.com original, reproduced please with hyperlink to indicate the source http://www.21andy.com

Same File: change centos yum to a Chinese image to speed up yum

Create a repo first

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

Add the following content

[21Andy.com]
Name = 21Andy.com Packages for Enterprise Linux 5-$ basearch
Baseurl = http://www.21andy.com/centos/5/?basearch/
Enabled = 1
Gpgcheck = 0
Protect = 1

Enable EPEL repo
I386

Rpm-ihv http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm

X86_64

Rpm-ihv http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm

Import key

Rpm -- import/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL

All right, one-click installation

# Yum install nginx php-fpm mysql-server

Great!

If you want to use the latest stable version 0.7.65 for nginx
Yum-y install nginx
Change
Yum-y install nginx-stable
You can.

More complete installation

Yum-y update
Yum-y mysql-server
Service mysqld start
Mysqladmin-u root password root
Service mysqld stop
Yum-y install nginx 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
# APC conflicts with eAccelerator. Select 2 and select 1.
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

Dependencies Resolved

========================================================== ============================
Package Arch Version Repository Size
========================================================== ============================
Installing:
Mysql x86_64 5.0.89-1. el5 21Andy.com 3.5 M
Mysql-server x86_64 5.0.89-1. el5 21Andy.com 10 M
Nginx x86_64 0.8.33-3. el5 21Andy.com 422 k
Php-cli x86_64 5.3.1-2. el5 21Andy.com 2.4 M
Php-eaccelerator x86_64. 9.6-1. el5 21Andy.com 118 k
Php-fpm x86_64 5.3.1-2. el5 21Andy.com 1.2 M
Php-gd x86_64 5.3.1-2. el5 21Andy.com 110 k
Php-mbstring x86_64 5.3.1-2. el5 21Andy.com 1.1 M
Php-mcrypt x86_64 5.3.1-2. el5 21Andy.com 27 k
Php-mysql x86_64 5.3.1-2. el5 21Andy.com 84 k
Php-pdo x86_64 5.3.1-2. el5 21Andy.com 91 k
Php-pear noarch. 9.0-1. el5 21Andy.com 420 k
Php-pecl-memcache x86_64 2.2.5-3. el5 21Andy.com 44 k
Php-tidy x86_64 5.3.1-2. el5 21Andy.com 31 k
Php-xml x86_64 5.3.1-2. el5 21Andy.com 115 k
Php-xmlrpc x86_64 5.3.1-2. el5 21Andy.com 48 k
Installing for dependencies:
Gmp x86_64 4.1.4-10. el5 base 201 k
LibXaw x86_64 1.0.2-8.1 base 329 k
LibXmu x86_64 1.0.2-5 base 63 k
LibXpm x86_64 3.5.5-3 base 44 k
Libedit x86_64 2.11-2.20080712cvs.el5 epel 80 k
Libmcrypt x86_64 2.5.8-4. el5.centos extras 105 k
Libtidy X 86_64 0.99.0-14.20070615.el5 epel 140 k
Php-common x86_64 5.3.1-2. el5 21Andy.com 554 k
Sqlite2 x86_64 2.8.17-5. el5 21Andy.com 165 k
T1lib x86_64 5.1.1-7. el5 epel 208 k
Updating for dependencies:
Libevent x86_64 1.4.12-1. el5 21Andy.com 129 k

Transaction Summary
========================================================== ============================
Install 26 Package (s)
Update 1 Package (s)
Remove 0 Package (s)

At last, we only need to update yum-y, which is the latest.
Don't forget to start

Chkconfig -- level 345 mysqld on
Chkconfig -- level 345 php-fpm on
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

Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;

# Vi/etc/nginx. conf

User nobody;


Worker_processes 8; # Here, based on your CPU and memory configuration, set both 2 and 10 OK

Error_log/www/logs/nginx_error.log crit;

Pid/usr/local/nginx/logs/nginx. pid;

# Specifies the value for maximum file descriptors that can be opened by this process.
Worker_rlimit_nofile 51200;

Events {
Use epoll;
Worker_connections 51200;
}

Http {
Include mime. types;
Default_type application/octet-stream;

# Charse gb2312; # default encoding, which can be left unspecified

Server_names_hash_bucket_size 128;
Client_header_buffer_size 16 k;
Large_client_header_buffers 4 16 k;
Client_max_body_size 8 m;

Sendfile on;
Tcp_nopush on;

Keepalive_timeout 60;

Tcp_nodelay on;

Fastcgi_connect_timeout 300;
Fastcgi_send_timeout 300;
Fastcgi_read_timeout 300;
Fastcgi_buffer_size 64 k;
Fastcgi_buffers 4 64 k;
Fastcgi_busy_buffers_size 128 k;
Fastcgi_temp_file_write_size 128 k;

Gzip on;
Gzip_min_length 1 k;
Gzip_buffers 4 16 k;
Gzip_http_version 1.0;
Gzip_comp_level 5;
Gzip_types text/plain text/javascript application/x-javascript text/css application/xml;
Gzip_vary on;

# Limit_zone crawler $ binary_remote_addr 10 m;
Server {
Listen 80;
Server_name localhost;
Root/www;
Location/status {
Stub_status on;
Access_log off;
}
Location /{
# Here we will convert all non-existing files and directories to index. php for processing.
Try_files $ uri // index. php? Q = $ uri & $ args;
}

# Put it here separately to the server. conf for convenience during server activation and unified calling. put it in the/etc/nginx/directory.
Include server. conf;

Log_format access' $ remote_addr-$ remote_user [$ time_local] "$ request "'
'$ Status $ body_bytes_sent "$ http_referer "'
'"$ Http_user_agent" $ http_x_forwarded_for ';
Access_log/www/logs/access. log access;
}

Server {
Listen 80;
Server_name www.21andy.com 21andy.com * .21andy.com;
Root/www/21andy.com;
If ($ host !~ * 21andy \. com $ ){
Return 444;
}
Location /{
Try_files $ uri // index. php? Q = $ uri & $ args;
}
Include server. conf; # reuse here, saving time
Access_log/www/logs/21andy.com _ access. log access;
}
}

# Vi/etc/nginx/server. conf

Index index.html index.htm index. php;


# Limit_conn crawler 20;

Location ~ /\. Ht {
Deny all;
}

Location ~ . * \. (Sqlite | sq3) $ {
Deny all;
}

Location ~ . * \. Php $ {
Fastcgi_pass unix:/tmp/php-cgi.sock;
# Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Include fastcgi_params;
}

Location ~ . * \. (Gif | jpg | jpeg | png | bmp | swf | ico) $ {
Expires 30d;
Access_log off;
}

Location ~ . * \. (Js | css )? $ {
Expires 30d;
Access_log off;
}

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.

Location ~ \. Php $ {
Root/www;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
# Add the following line to/etc/nginx/fastcgi_params.
# Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Include fastcgi_params;
}

If the port 9000 method is used, set the php-fpm parameter accordingly.
# Vi/etc/php-fpm.conf

127.0.0.1: 9000

Address: http://www.21andy.com/blog/20100219/1701.html

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.