Install nginx, MySQL, PHP-FPM, and redis in yum

Source: Internet
Author: User

Purpose

Install nginx, MySQL, PHP-FPM, and redis through yum in centos 6.2.

Environment preparation

You can install centos 6.2 on a USB flash drive.

Why is yum used for installation?

In addition to the tarball method, install the software on Linux Through the package management program. One advantage of Yum installation is that the upgrade is very convenient. Of course, tarball also has its advantages. Please try to use tarball for compilation and installation in the product environment. As for the solution, you will be wise.

Start Installation

1. If you are not on the machine (IP address of the machine in the experiment is 192.168.1.100), please connect to the server through SSH. It is best to log on as root.

SSH root@letaotao.net.cn

2. Check whether your machine is connected to the network. (If NO network exists, can Yum be used ?)

Ping-C4 mirrors.163.com

If Ping is not available, perform the following operations in sequence:

Modify the IP address of a machine

Vim/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE="eth0"HWADDR="00:15:58:1D:43:DA"NM_CONTROLLED="no"ONBOOT="yes"IPADDR=192.168.1.100NETMASK=255.255.255.0GATEWAY=192.168.1.1

Modify DNS server configurations

Vim/etc/resolv. conf

nameserver 8.8.8.8nameserver 8.8.4.4

Modify network configurations

Vim/etc/sysconfig/Network

NETWORKING=yes

Restart the network

/Etc/init. d/network restart

3. Configure the bashurl of the CentOS-Base.repo to mirrors.163.com so that Yum will download the installation package much faster.

Vim/etc/yum. Repos. d/CentOS-Base.repo

Add # To all rows in the queue list, remove the # Of All baseurls, and change the domain name to mirrors.163.com. For example:

Baseurl = http://mirrors.163.com/centos/?releasever/ OS /?basearch/ (other similar operations)

4. Install Yum-Priorities

Yum install Yum-Priorities

5. Add other software libraries epel and Remi. Because Remi depends on epel, add epel and Remi first.

Rpm-uvh http://mirrors.ustc.edu.cn/epel/6/i386/epel-release-6-7.noarch.rpm

Edit the repo configuration file of epel.

Vim/etc/yum. Repos. d/epel. Repo

Add # To all rows in the queue list, remove the # Of All baseurls, and change the domain name to mirrors.ustc.edu.cn. For example:

Baseurl = http://mirrors.ustc.edu.cn/epel/6/?basearch (other similar operations)

Rpm-uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

6. Modify the repo configuration file priority of epel and Remi.

Vim/etc/yum. Repos. d/epel. Repo

Then add priority = 10 to each item.

Vim/etc/yum. Repos. d/Remi. Repo

Also, each item is added with priority = 10.

7. Install nginx, MySQL, PHP-FPM and related modules in yum, and redis (it's great to install so many things at a time !)

Nginx, MYSQL client, MySQL server, PHP and related modules, memcache module, and PHP accelerator eaccelerator

Yum install nginx MySQL 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-devel PHP-PECL-memcache PHP-eaccelerator

8. Add the System user web (nginx and PHP-FPM will run as this user) and web directory

Useradd-R web

Mkdir/Web

9. Configure and start nginx

Vim/etc/nginx. conf

Change the user item to Web

Vim/etc/nginx/CONF. d/Default. conf

And modify it

Server {Listen 80; SERVER_NAME www.bukanshu.com; root/Web; # root directory Autoindex on; # display directory when no index file exists. Set it to off location/{Index in the product environment. PHP index.html index.htm;} location ~ \. Php $ {fastcgi_pass 127.0.0.1: 9000; fastcgi_index index. php; fastcgi_param script_filename $ document_root $ fastcgi_script_name; Include fastcgi_params ;}}

Reminder: each configuration must end with a semicolon; fastcgi_param should replace the hard-code path with $ document_root.

Add nginx as a startup project

Chkconfig nginx on

Start nginx

/Etc/init. d/nginx start

10. Start and configure MySQL

MySQL is special. You need to start and configure

/Etc/init. d/mysqld start

Configure the root password

Mysql_secure_installation

Because root does not have the initial password, when prompted to enter the password, press enter to skip and then configure the root password. Otherwise, press enter to use the default password.

Add mysqld as the startup project

Chkconfig mysqld on

11. Start redis and install the PHP-redis module.

Add redis to the startup project

Chkconfig redis on

Start redis Service

/Etc/init. d/redis start

First, wrap the development tool group.

Yum groupinstall "development tools"

Then compile and install the PHP-redis module.

CD/tmp

Wget-O https://github.com/nicolasff/phpredis/zipball/master

Unzip php-redis.zip

Unzip the directory is: nicolasff-phpredis-21d6614

CD nicolasff-phpredis-21d6614

Phpize

./Configure

Make

Make install

Check whether the so file has been placed in the correct directory.

Ll/usr/lib/PHP/modules/redis. So

Create redis. ini and add extension = redis. So to enable redis Extension

Vim/etc/PhP5/FPM/CONF. d/redis. ini

12. Configure and start PHP-FPM

Vim/etc/php-fpm.d/www. conf

Change the user and group items in to Web

Vim/etc/PHP. ini

Find display_errors and change off to on to facilitate subsequent debugging. Set the product environment to off.

Find session. save_handler and change files to redis.

Find the session. save_path and change it to session. save_path = "TCP: // 127.0.0.1: 6379? Timeout = 2 ″

Add PHP-FPM as the startup project

Chkconfig PHP-FPM on

Start FMP Service

/Etc/init. d/PHP-FPM start

13. Check various processes and services through shell scripts

Vim check. Sh

Add code

#!/bin/shPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/binfor soft in nginx mysqld php-fpm redisdo    echo -e "-------------------- stat of $soft --------------------"    /etc/init.d/$soft status; echo -e " "    ps aux|grep $soft --color=auto; echo -e " "    netstat -ntulp|grep $soft --color=autodone

Then execute this script

Sh check. Sh

View the status of various processes and services (pay attention to the highlighted red font)

14. Install the MySQL management tool phpMyAdmin.

CD/Web

Wget http://nchc.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.5.1/phpMyAdmin-3.5.1-english.tar.gz

Tar zxvf phpMyAdmin-3.5.1-english.tar.gz

Music phpMyAdmin-3.5.1-english phpMyAdmin

Chown-R web. Web phpMyAdmin

CP PHPmyAdmin/config. sample. Inc. php PHPmyAdmin/config. Inc. php

15. Open Port 80.

Vim/etc/sysconfig/iptables

Add the following sentence to-a input-M State-State new-m tcp-p tcp-dport 22-J accept:

-A input-M State-State new-m tcp-p tcp-dport 80-J accept

Restart iptables.

/Etc/init. d/iptables restart

16. Access phpMyAdmin

Http://www.u151.com/phpmyadmin/

If phpMyAdmin can operate MySQL normally, it indicates that the nginx service configured by the system, the PHP-FPM service, and the MySQL database and redis cache service are all normal!

In the product environment, remove phpMyAdmin or disable all directory permissions: chmod 0000 phpMyAdmin

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.