Tutorial _ php instance for configuring LNMP In Debian system

Source: Internet
Author: User
Tags ubuntu vps
This article mainly introduces how to configure LNMP In the Debian system. Compared with the common LAMP, Apache is replaced with a high-performance Nginx server, you can refer to the LNMP environment configuration to allow our host to support Nginx, MySQL, PHP, and phpMyAdmin. After this configuration, you can directly use this environment, and run the website on it. Next I will configure it.

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:

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:

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:

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.

apt-get install memcached

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

 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

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:

service nginx start

The access result is as follows: Configure Nginx.

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:

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.

cd /etc/nginx/conf.d

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

Vi dearroy.com. confserver {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 the domain name server_name localhost; # pseudo static rule include wordpress. conf; location/{try_files $ uri // index.html;} # define the 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:

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:

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.