Installing LNMP steps with Yum

Source: Internet
Author: User
Tags php introduction nginx server

Installing LNMP steps with Yum

Installing LNMP steps with Yum

Enter the command cat/etc/redhat-release to view the current Linux system version

# Cat/etc/redhat-release

CentOS Release 6.5 (Final)

Turn off firewall self-boot

#/etc/init.d/iptables Stop

# chkconfig Iptables off

Before deploying the LNMP environment, first, the user needs to install the NIGNX server, MySQL database, and the PHP environment-related development package and library files, if the lack of development package or library files, will cause subsequent LNMP environment deployment failure.

Configure Epel Source # Yum Install Epel-release-y

Execute the following command to install the development package and library files required for the LNMP environment, which, if not installed, will cause subsequent installation of the LNMP environment to fail. For example: OpenSSL, etc.

# yum-y Install NTP make OpenSSL openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b FreeType F Reetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libxpm libxpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel LIBXML2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 Curl Curl-devel

In the real production environment, if the user's server, installed Apache, MySQL, PHP. Please execute the command

# yum remove MySQL httpd php

Uninstall the relevant software, otherwise the system legacy software will affect the data in the deployed LNMP environment.

# package XX available, yet not installed # will not prompt

Installation of Nginx

# yum-y Install Nginx

Edit

# vi/etc/nginx/conf.d/default.conf

Listen [::]:80 default_server; # In this position, enter the DD command to delete this line, which is to delete the configuration where the listener is IPv6.

Start the Nginx server

# service Nginx Start

# chkconfig Nginx on # set boot Nginx

Install MySQL

Before installing MySQL, install MySQL and its components mysql-server,mysql-devel.

# yum-y install MySQL mysql-server mysql-devel

Start MySQL

# service Mysqld Start

# chkconfig mysqld on set boot MySQL

Install PHP

Install PHP and its common expansion packs. The lack of an expansion pack may cause PHP installation or failure to run.

# yum-y Install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php- Mbstring php-mcrypt php-mssql Php-snmp php-soap

Install the relevant components of PHP. This allows PHP to support MySQL, fastcgi mode.

# yum-y Install php-tidy php-common php-devel php-fpm php-mysql

Start PHP-FPM

# service PHP-FPM Start

Start PHP-FPM, the interface displays "OK". Because Nginx is a lightweight HTTP server, you must use a third-party fastcgi processor to be able to parse PHP, PHP-FPM is a third-party fastcgi process Manager, only for PHP.

# chkconfig PHP-FPM on # set boot php-fpm.

Configuring Nginx Support PHP

First, change the Nginx configuration file to a backup file and execute the following command:

# Mv/etc/nginx/nginx.conf/etc/nginx/nginx.conf.bak

Then, copy the default configuration file as the configuration file and execute the following command:

# cp/etc/nginx/nginx.conf.default/etc/nginx/nginx.conf

Execute command

# vim/etc/nginx/nginx.conf

Go to the edit page of nginx config file and add Nginx fastcgi support.

First, the 45th line of the file is modified to the following, that is, the home page support PHP language.

Index index.php index.html index.htm;

Then, remove the comment "#" before the 65-72 lines of the file and replace the "root" and "Fastcgi_param" parameter values as follows. That is, using

/usr/share/nginx/html

As the site root directory, access.

Modified two places

root/usr/share/nginx/html;

Fastcgi_param Script_filename/usr/share/nginx/html$fastcgi_script_name;

# as follows

Location ~. php$ {

root/usr/share/nginx/html;

Fastcgi_pass 127.0.0.1:9000;

Fastcgi_index index.php;

Fastcgi_param Script_filename/usr/share/nginx/html$fastcgi_script_name;

Include Fastcgi_params;

}

Execute command

# Vim/etc/php.ini

Go to the edit page of the file php.ini, and add the following before the "; Local Variables:" At the end. When finished, execute: WQ save and exit the edit page.

Cgi.fix_pathinfo = 1

# as follows

; Sysvshm.init_mem = 10000

Cgi.fix_pathinfo = 1

; Local Variables:

; Tab-width:4

; End:

Restart the Nginx and PHP-FPM servers. The parameters in the modified Nginx configuration file take effect.

# Service Nginx Restart

# Service PHP-FPM Restart

At this point, complete the LNMP environment of all the building content,

In the Nginx Web site access to the home directory, create a info.php file and go to the edit page of the new file. And on the edit page, enter the following code to display the PHP basic information page. When you are finished, enter: Wq, save and exit the edit page.

Execute command

# vim/usr/share/nginx/html/info.php

<?php

Phpinfo ();

?>

Finally, test whether Nginx successfully parses PHP. Open the local browser, and enter in the Address bar: http://xxx.xxx.xx.xx/info.php, if the page shows PHP introduction information, prove LNMP environment build success.

Lnmp

Yum installed directories are under/var/lib/

Yum install MySQL, PHP version is required when you can uninstall download the corresponding RPM package for installation

Installing LNMP steps with Yum

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.