Perfect LNMP environment with Yum under centos6.5 (php5.6)

Source: Internet
Author: User
Tags fpm install php

Preparatory work
  1. Configure the firewall to turn on 80 ports, 3306 ports
    Delete the original iptables and add the appropriate configuration

    rm-rf/etc/sysconfig//etc/sysconfig/iptables

    Add the following content:

    ################################ After adding the firewall rules as follows #################################Firewall configuration written by System-config-firewall#Manual Customization of this file are not recommended.*Filter: INPUT ACCEPT [0:0]: FORWARD ACCEPT [0:0]: OUTPUT ACCEPT [0:0]-A input-m state--state established,related-J ACCEPT-A input-p ICMP-J ACCEPT-A input-i lo-J ACCEPT-A input-m State--stateNEW-M tcp-p TCP--dport 22-J ACCEPT-A input-m State--stateNEW-M Tcp-p TCP--dport 80-J ACCEPT-A input-m State--stateNEW-M tcp-p TCP--dport 8080-J ACCEPT-A input-m State--stateNEW-M tcp-p TCP--dport 8081-J ACCEPT-A input-m State--stateNEW-M tcp-p TCP--dport 8082-J ACCEPT-A input-m State--stateNEW-M tcp-p TCP--dport 3306-J ACCEPT-A input-j REJECT--reject-with icmp-host-prohibited-A forward-j REJECT--reject-with icmp-host-Prohibitedcommit#######################################################################################

     

    :wqSave exit, restart firewall to make configuration effective

    /etc/init.d/iptables restart

     
  2. Turn off SELinux

    RM-RF  /etc/selinux//etc/selinux/config

    Add a line of content:

    Selinux=disabled
    : Wq Save Exit
    #重启系统
    Shutdown-r now
  3. Installing a third-party yum Source
    # Install the Download tool Yum Install wget # Download wget http://www.atomicorp.com/installers/atomic# install sh./Atomic  # update yum source Yum Check-update
Start installing one. Installing Nginx
# remove the system's own package yum remove httpd* php*# install nginx yum installs-y nginx#  Set nginx boot chkconfig nginxon# start nginxservice Nginx

Two. Install PHP
Check the currently installed PHP package YumListInstalled |grep php If there is a PHP package installed, first remove themSuch as:Yum Remove php. x86_64 php-cli.x86_64 Php-common.x86_64 Configuring the installation package source:#Centos 5.XRPM-UVH http://mirror.webtatic.com/yum/el5/latest.rpm    #CentOs 6.xRPM-UVH http://mirror.webtatic.com/yum/el6/latest.rpm    #CentOs 7.XRPM-UVH https://mirror.webtatic.com/yum/el7/epel-release.rpmRPM-UVH https://mirror.webtatic.com/yum/el7/webtatic-release.rpmIf you want to remove the package installed above, reinstall the RPM-qa |grep webstatic rpm-e [package found above] Execute install Yum-y install php56w.x86_64 Yum-Y--enablerepo=webtatic Install php56w-devel Yum-y install php56w-xml.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-MySQL. x86_64 php56w-pdo.x86_64 Php56w-opcache.x86_64 installing PHP FPM yum-Y Install php56w-FPM#set php-fpm boot upChkconfig php-FPM on#Start PHP-FPM/etc/init.d/php-FPM Start Note: If you want to change to PHP5. version 5 or 5.4, just switch the above 56w to 55w or 54w.

Three. Install MySQL
  1. install
     yum install-y mysql  mysql - Span style= "COLOR: #000000" >server  #   Start MySQL /etc/init.d/mysqld start  #   set to boot start  chkconfig mysqld on  #   Copy profile (Note: if the/etc directory has a default MY.CNF, you can overwrite it directly)  cp/usr/share/ mysql /my-medium.cnf/etc/my.cnf 

     

  2. Set a password for the root account
    mysql_secure_installation # Enter , according to the prompt input y, enter 2 times password, return, according to the prompt input Y, and finally appear: Thanks for using mysql! #   mysql Password setup complete, restart MySQL:#  Restart/etc/init.d/mysqld restart# stop /etc/init.d/mysqld stop# starts/etc/init.d/mysqld start

Configuration 1. Configure Nginx
RM-RF/ETC/NGINX/CONF.D/*vi/etc/nginx/conf.d/default.conf
Add the following content:server{Listen80;    server_name _; Index index. PHP index.html Index.htm; Root/var/www; Location~ .*\. (PHP|PHP5)?$    {            #Fastcgi_pass Unix:/tmp/php-cgi.sock;Fastcgi_pass 127.0.0.1:9000; Fastcgi_index Index.PHP; includeFastCGI.conf; } Location/{try_files$uri $uri//index.php?$query _string; }} Description: /var/www for Web root directory, location/... Rewrite for URLs, hide index.php
2. Configure PHP-FPM
Vi/etc/php-fpm.d/www. conf Set the user and user group to Nginx, default to Apache, such as:# Modify user to Nginx=# fix to Nginx Group = Nginx
Description
Start command:#nginx Reboot | start | stopService Nginx Restart | Start |Stop#php-fpm Restart | start | StopService PHP-FPM Restart | Start |Stop#mysql Restart | start | StopService Mysqld Restart | Start |Stop directory for some files:#nginx.conf/etc/nginx/nginx.conf#php.ini/etc/php.INI#my.cnf/etc/my.CNF#Project root directory/var/www
Start testing
VI/var/www/index. PHP Add the following code <? PHP Phpinfo ();? >:wq! Save Exit # Set Permissions chown Nginx.nginx/var/www-R# Restart nginxservice nginx Restart  # Restart php-fpmservice php-fpm restart

In the client browser enter the server IP address (for example: 127.0.0.1), you can see the relevant configuration information!
Description LNMP Configuration succeeded!

Perfect LNMP environment with Yum under centos6.5 (php5.6)

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.