Detailed instructions on how to install LNMP server commands in Debian 7

Source: Internet
Author: User
Tags fpm install php memcached phpinfo ubuntu vps zend

Let's take a look at the official instructions.

The one-click installation package for LNMP is a Linux Shell program that can be compiled for CentOS/RadHat, Debian/Ubuntu VPS (VDS), or independent hosts to install LNMP (Nginx, MySQL, PHP, phpMyAdmin) shell program in the production environment


1. Install MySQL
Run the following command:

The code is as follows: Copy code

Apt-get install-y mysql-server mysql-client

You can install MySQL. During the installation process, you will be asked about the root password. Enter the required password and press enter.

After the installation is complete, run the following command to perform one-step security settings:

The code is as follows: Copy code

Mysql_secure_installation

Follow the prompts to check whether the root password is changed, whether anonymous users are removed, and whether root remote logon is prohibited.
2. Install PHP
Run the following command:

The code is as follows: Copy code

Apt-get install php5-fpm php5-gd php5-mysql php5-memcache php5-curl

The above Command installed the php5-memcache extension, so continue to install Memcached.

The code is as follows: Copy code

Apt-get install memcached

After the installation is complete, use php5-fpm-v to view the PHP version:

The code is as follows: Copy code
Root @ ztbox :~ # Php5-fpm v
PHP 5.4.16-1 ~ Dotdeb.1 (fpm-fcgi) (built: Jun 8 2013 22:20:42)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

3. Install Nginx
For Nginx, pick up your teeth:

Nginx ("engine x") is a high-performance HTTP and reverse proxy server and an IMAP/POP3/SMTP proxy server. Nginx was developed by the Rambler.ru site with the highest access volume in Russia as Igor Sysoev. It has been running on this site for more than three years. Igor publishes source code in the form of a class BSD license.

Nginx surpasses Apache's high performance and stability, making it more and more websites using Nginx as Web servers in China, including Sina blog, Sina podcast, NetEase News, Tencent network, sohu blog and other portal website channels, discuz! Well-known forums such as official forums and the Shui Mu community, online game websites such as Shanda Online and Kingsoft Xiaoyao net, and emerging Web 2.0 websites such as Douban, Renren, YUPOO album, Kingsoft aiqiba, and Thunder online.

Here, I directly installed all the Nginx extension functions (nginx-full) to cope with possible functional enhancements in the future.

Apt-get install-y nginx-full

Then start Nginx:

The code is as follows: Copy code

Service nginx start

As shown in the preceding figure, Configure Nginx.

The code is as follows: Copy code

Vim/etc/nginx/sites-available/default

......
Location ~ . Php $ {
Fastcgi_split_path_info ^ (. +. php) (/. +) $;
# NOTE: You shoshould have "cgi. fix_pathinfo = 0;" in php. ini
    #
# With php5-cgi alone:
# Fastcgi_pass 127.0.0.1: 9000;
# With php5-fpm:
Fastcgi_pass unix:/var/run/php5-fpm.sock;
Fastcgi_index index. php;
Include fastcgi_params;
    }
......

Restart Nginx after saving the changes:

Service nginx restart

Next we will create a new phpinfo to view the php details:

The code is as follows: Copy code

Vim/usr/share/nginx/html/phpinfo. php

<? Php phpinfo ();?>

After saving the file, access http: // ip/phpinfo. php. If the phpinfo page appears, this is done.

How to create a site
Unlike the one-click package of June, the LNMP installed in this method needs to be manually added to the site configuration file.

The code is as follows: Copy code
Cd/etc/nginx/conf. d

Enter the configuration file directory and create a new site configuration file, such

The code is as follows: Copy code

Vi dearroy.com. conf
,

Server {
Listen 80;

# Ipv6
# Listen [:]: 80 default_server;

Root/usr/share/nginx/html/dearroy.com;

# Default homepage file name
Index. php index.html index.htm;

# Bind a domain name
Server_name localhost;

# Pseudo-static rules
Include wordpress. conf;

Location /{
Try_files $ uri // index.html;
    }
# Define error page
# Error_page 404/404 .html;

Location ~ . Php $ {
Fastcgi_split_path_info ^ (. +. php) (/. +) $;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Include fastcgi_params;
     }
# PHP
}

After saving the file, restart Nginx and add and bind the website.

Finally, two common programs Nginx pseudo-static are attached:

WordPress:

The code is as follows: Copy code
Location /{
If (-f $ request_filename/index.html ){
Rewrite (. *) $1/index.html break;
        }
If (-f $ request_filename/index. php ){
Rewrite (. *) $1/index. php;
        }
If (! -F $ request_filename ){
Rewrite (. *)/index. php;
        }
}

Discuz X:

The code is as follows: Copy code

Rewrite ^ ([^.] *)/topic-(.20.20..html $1/portal. php? Mod = topic & topic = $2 last;
Rewrite ^ ([^.] *)/article-(%0-9%%*-(%0-9%%%%%%%.html $1/portal. php? Mod = view & aid = $2 & page = $3 last;
Rewrite ^ ([^.] *)/forum-(w1_0000-(0-91_00000000.html $1/forum. php? Mod = forumdisplay & fid = $2 & page = $3 last;
Rewrite ^ ([^.] *)/thread-(%0-9%%%)-(%0-9%%%%%%%%%%.html $1/forum. php? Mod = viewthread & tid = $2 & extra = page % 3D $4 & page = $3 last;
Rewrite ^ ([^.] *)/group-(%0-9%%*-(%0-9%%%%%%%.html $1/forum. php? Mod = group & fid = $2 & page = $3 last;
Rewrite ^ ([^.] *)/space-(username | uid+-(.20.20..html $1/home. php? Mod = space & $2 = $3 last;
Rewrite ^ ([^.] *)/([a-z?##-(.w.20..html $1/$ 2.php? Rewrite = $3 last;
If (! -E $ request_filename ){
Return 404;

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.