Linux/centos the complete process of various service frameworks

Source: Internet
Author: User
Tags fpm install php

In 2012, because of the need to take care of the new Linux and related services to understand and learn, I have specifically made all of our start-up projects in the service building process to write a document, so that they can learn and reference. Following this document as a manuscript, to make some changes and the deletion of sensitive information, to share to everyone, hope for the benefit of everyone.
Description, the following Rafael is my English name, the application is currently changing direction of Kung Fu letter, English straight write pinyin gongfuxin. In addition to the Linux account number, the basic configuration of some security, there are Php/php-fpm/mysql/redis/nginx installation and configuration.
Reprint please indicate the source.
Update record:
Gu Yichin October 26, 2012 Install the machine from the virtual machine and begin to describe the installation steps
Gu Yichin December 04, 2012 installs the machine through the virtual machine, and installs the complete service of the internal test, consummates the entire installation procedure
Gu Yichin August 7, 2014 in the network sharing purposes, have been deleted and amended

The first part of the installation of a clean server
========================
1. Download CentOS 6.3 (currently up to 6.5) 64bit CD1 (not Livedvd or LiveCD) and follow the wizard settings, here are some points of note for the settings:
1) boot from CD, install CentOS 6.3
2) Select the default English installation
3) disk Select entire Hard drive
4) Time Select Shanghai, do not select UTC
5) When setting the root password, back up this password
6) Select the basic server installation method
7) Customize the selection package, select the Chinese package in the language

2. Network and System Configuration
1) Internal testing machine, can use static IP, also can be dynamic IP. The public network machine must use static IP, set with the Setup command, or you can change the corresponding configuration file directly:
/etc/sysconfig/network-scripts/ifcfg-eth0, especially to change the value of onboot to Yes, generally modified after the best restart, you can use the network
2) then perform yum update, complete the system updates, and it is best to reboot once
3) If the kernel is upgraded, do not delete all old kernels, keep at least the last old kernel, in case the new kernel has problems
4) Turn off SELinux and modify/etc/selinux/config to achieve. The server can be secured later through a firewall

3. Account Setup and Maintenance
1) Create an administrative user, such as Useradd Rafael
2) password settings for newly created users, such as passwd Rafael, which are usually backed up by this password
4) Add Rafael to the wheel user group and configure it in/etc/group
5) Set the wheel user group to Sudo's trusted user group, make changes in the/etc/sudoers, note that this file should be changed to writable, and then go back
6) Disable root user remote SSH login, configure in/etc/ssh/sshd_config, set Permitrootlogin No, and restart sshd
7) Try to telnet to this machine via SSH later.

The second part installs Nginx, MySQL, PHP, Redis, etc.
========================
1. Set the Epel Update source (official source is too old)
1) The main reference http://www.if-not-true-then-false.com/2011/install-nginx-php-fpm-on-fedora-centos-red-hat-rhel/, there will be some small changes , whichever is the following. First, complete the following two steps:
A. Sudo rpm-uvh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm (preferably to http:// mirrors.ustc.edu.cn/fedora/epel/6/x86_64/look at the latest version of Epel, should be more than 6-8)
B. sudo rpm-uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm (best to http://mirrors.ustc.edu.cn/fedora/ epel/6/x86_64/look at the latest version)?
2) then find the Nginx source, to http://nginx.org/en/download.html find CentOS6 line, and then you can download the corresponding RPM, can also be directly through the following command: sudo RPM-UVH/http nginx.org/packages/centos/6/noarch/rpms/nginx-release-centos-6-0.el6.ngx.noarch.rpm

2. Install the required software
1) Install PHP and nginx, such as: sudo yum--enablerepo=remi install nginx php php-fpm Php-common
2) Install PHP components, such as: sudo yum--enablerepo=remi install PHP-PECL-APC php-cli php-pear php-pdo php-mysql php-pgsql Php-pecl-mongo Php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-devel
3) Php-redis Please follow the instructions on Https://github.com/nicolasff/phpredis to download and compile and install with git (install gcc and git first: sudo yum--enablerepo=remi install gcc git), and then need to manually add redis.conf and related content to the/etc/php.d/
4) Install MySQL and redis, such as: sudo yum--enablerepo=remi install MySQL mysql-devel mysql-server redis
5) then configure Php-fpm/nginx/mysql/redis to automatically start at the 2/3/4/5 level, which can be set by chkconfig

Part III: Configuring MySQL, Redis, Nignx, PHP, etc.
========================
1. Configure MySQL
1) Start Mysql:sudo service mysqld start and you will be prompted for some initial considerations for the first launch
2) Set the root local password, back up the password, can see if the situation is set to root remote account
3) login MySQL, create other user and password with command line, must set gongfuxin account number and password, backup password, this account is used for website login
4) Set up UTF8-based database gongfuxin, then import Gfx_recreate_all.sql, and the corresponding tables of cities, provinces, and universities, assigning all the permissions of the Gongfuxin database to the Gongfuxin account: Grant all privileges on gongfuxin.* to [email protected];
5) can be set up in remote login mysql, it is more convenient, but to configure the remote account, and to open the 3306 (TCP) port of the firewall, the previous account creation, database creation can use this way, but the security defect
6) for MySQL configuration file, can be found in/usr/share/mysql/, and then according to the specific memory size selection, overwriting to/etc/my.cnf can be, and then restart: sudo service mysqld restart

2. Configure Redis
1) configuration file in/etc/redis.conf, temporarily do not need to configure
2) Start Redis:sudo service Redis start

3. Configure PHP
1) Edit/etc/php.ini, modify the following (the configuration is for the on-line server, not for the development environment):
? implicit_flush = On
? expose_php = Off
? error_log =/var/log/php-fpm/php_error.log
2) Modify the/var/lib/php/session permissions so that it belongs to the Nginx user group, not the Apache user group (root should be the user at this time, do not need to change)
3) Modify the/VAR/LOG/PHP-FPM permissions so that it belongs to the Nginx user, not the Apache user (root should be the user group at this time, do not need to change)
4) Modify the/etc/php-fpm.d/www.conf so that both user and group are Nginx
5) Start Php-fpm:sudo service php-fpm start

4. Configure Nginx
1)/etc/nginx/nginx.conf According to the actual situation configuration, for the internal test environment does not need to configure, note, generally need to modify the system process maximum number of threads and the number of handles, with ulimit-a can be viewed; the thread stack size of the process is automatically modified in the program
2)/etc/nginx/conf.d/default.conf, need to be configured as our publishing directory, if there are multiple publishing directories need a number of similar configuration files, and configured to PHP parsing, as follows:
File start*********
Listen 8050;
server_name localhost;

CharSet Utf-8;
Access_log/var/log/nginx/access.log main;
Root/usr/share/nginx/gongfuxin;

Location/{
Index index.php;
}

Location ~ \.php$ {
Include Fastcgi_params;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Client_max_body_size 8m;
}

# Deny access to. htaccess files, if Apache ' s document Root
# concurs with Nginx ' s one
Location ~/\.ht {
Deny all;
}
}
File end*********
3) Modify the php-cgi's listening port according to the configuration (said below), then open the firewall settings (TCP, regular server, must be 80 port) or 8050 (TCP, internal test, or other unused ports)
4) need to create/usr/share/nginx/gongfuxin folder
5) Start Nginx:sudo service Nginx start
?
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.