Manual construction of LNMP environment based on CentOS6.5

Source: Internet
Author: User
Tags snmp
This article mainly introduces the CentOS6.5 based on the LNMP environment hand-built, has a certain reference value, now share to everyone, have the need for friends can refer to

  LNMP installation There are two ways, one is a key installation, due to the installation process to upgrade the system files, in the compilation of Golang problems, to be further resolved; the second is the distribution installation, the process can be compiled after installation of the relevant program. 1. Check the environment: [root@localhost ~]# Cat/etc/redhat-releasecentos Release 6.5 (Final) [Root@localhost ~]# 2, turn off the firewall: [Root@localhos T ~]# service iptables stopiptables:setting chains to Policy accept:filter [OK]iptables:flushing Firewall Rules: [OK]iptables:unloading modules: [OK][root@localhost ~]# Service Iptables Statusiptables:firewall is not running. [Root@localhost ~]# 3, configuring CentOS 6.0 third Party yum Source (no Nginx package in CentOS default standard source) [Root@localhost src]# wget http://www.atomicorp.co m/installers/atomic [root@localhost src]# sh./atomic [root@localhost src]# yum check-update 4, installing the package and library files: [Root@lo Calhost src]# yum-y Install NTP make OpenSSL openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6 b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libxpm libxpm-devel ncurses ncurses-devel libmcryptLibmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 Curl Curl-devel 5, uninstall already Installed Apache, MySQL, PHP, (executed separately) [root@localhost src]# yum Remove httpd [root@localhost src]# yum Remove Mysql[root@localhost s rc]# Yum Remove PHP 6, installing nginx;[root@localhost src]# yum install nginx[root@localhost src]# service Nginx Start[root@loc Alhost src]# chkconfig–levels 235 nginx on//Set 2, 3, 5 level boot start 7, installation mysql;[root@localhost src]# yum install MySQL Mysql-serve R mysql-devel[root@localhost src]# service mysqld start[root@localhost src]# chkconfig--levels 235 mysqld on login MySQL, delete  Save the user and modify the user password; [root@localhost src]# mysql-uroot-penter password:welcome to the MySQL monitor. Commands End With; or \g.your MySQL connection ID is 2Server version:5.5.55 mysql Community Server (GPL) by Atomicorpcopyright (c) 2000, 201 7, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other namesMarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql> use MySQL Reading table information for completion of table and C Olumn Namesyou can turn off this feature to get a quicker startup With-adatabase changed//view MySQL user information; Mysql>select US Er,host,password from mysql.user;//Delete empty user;mysql> drop "@localhost; Query OK, 0 rows Affected (0.00 sec) mysql> Delete from user where user = '; Query OK, 1 row Affected (0.00 sec)//update user password;mysql> update mysql.user Set password = password (' root ') where user= ' root ' ; Query OK, 4 rows Affected (0.00 sec) Rows Matched:4 changed:4 warnings:0//authorization: Allows root user to log in with root password, * * Indicates which table of the library, and which IP address to access ;mysql> Grant all privileges on *. * to root@ '% ' identified by ' root ' with GRANT option; Query OK, 0 rows Affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows Affected (0.00 sec)//update database is in effect;mysql> flush privileges; Query OK, 0 rows Affected (0.00 sec)//exit mysql> exit; Bye 8, installationPHP; [root@localhost src]# yum install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear p Hp-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap//install PHP and required components to enable PHP to support MySQL, fastcgi mode; [Root@localho St src]# Yum install php-tidy php-common php-devel php-fpm php-mysql//Start PHP service and set boot start; [root@localhost src]# service P HP-FPM startstarting php-fpm:no log handling enabled-turning on stderr loggingcreated directory:/var/lib/net-snmp/mib_ indexes [OK][root@localhost src]# chkconfig--levels 235 php -FPM on[root@localhost src]# 9, configuration nginx, support Php;[root@localhost wwwroot]# cd/etc/nginx/conf.d/[root@localhost conf.d]# V    I default.conf//config file as follows: server {Listen 80;    server_name localhost;        Location/{root/home/wwwroot;        Index index.html index.htm index.php;        if (!-e $request _filename) {rewrite ^ (. *) $/index.php?s=$1 last;   }    } Error_page 502 503 504/50x.html;    Location =/50x.html {root/usr/share/nginx/html;        } location ~ \.php$ {root/home/wwwroot;        Fastcgi_pass 127.0.0.1:9000;        Fastcgi_index index.php;        Include Fastcgi_params;        Fastcgi_param script_filename $document _root$fastcgi_script_name;        Set $path _info "";        Set $fastcgi _script_name_new $fastcgi _script_name;                if ($fastcgi _script_name ~* "^ (. +\.php) (/.+) $") {set $fastcgi _script_name_new $;         Set $path _info;        } fastcgi_param script_filename $document _root$fastcgi_script_name_new;        Fastcgi_param script_name $fastcgi _script_name_new;    Fastcgi_param path_info $path _info;                                            }} 10, restart Nginx and php-fpm;[root@localhost conf.d]# service Nginx restartstopping nginx: [OK] Starting nginx: [OK][root@localhOST conf.d]# service php-fpm restartstopping php-fpm: [OK]starting PHP-FPM: [OK] [Root@localhost conf.d]# 11, test, in the Nginx parsing directory to create info.php files, and in the browser to access http://localhost/info.php, see if the PHP page is displayed;// The contents of the info.php file are as follows: <?php phpinfo ();? >
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.