The configuration of the LNMP environment is to let our host support Nginx, MySQL, PHP, phpMyAdmin, so that the configuration can be used directly after the environment, and run the site above, I will configure the method below.
Let's look at the official instructions first.
LNMP One-click installation package is a Linux shell can be written for Centos/radhat, Debian/ubuntu VPS (VDS) or stand-alone host installation Lnmp (Nginx, MySQL, PHP, phpMyAdmin) Shell Program for production environment
1, install MySQL
to execute a command:
Apt-get install-y Mysql-server mysql-client
You can install MySQL, the installation process will ask the root password, type the password you need to return to.
After the installation is complete, perform the following command for one step of the security setting:
Mysql_secure_installation
Follow the prompts to ask if you want to change the root password, whether to remove anonymous users, and whether to prevent root remote logins, and so on.
2, install PHP
to execute a command:
Apt-get Install php5-fpm php5-gd php5-mysql Php5-memcache
The above command installs the Php5-memcache extension and continues to install Memcached.
Apt-get Install memcached
After installation, use Php5-fpm-v to view the version of PHP:
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 have directly installed all of the Nginx extensions (Nginx-full) to deal with the possible enhancements that might occur later.
Apt-get install-y Nginx-full
Then start Nginx:
The access results are as shown above, and then configure Nginx.
Vim/etc/nginx/sites-available/default
......
Location ~. php$ {
Fastcgi_split_path_info ^ (. +.php) (/.+) $;
# # Note:you should 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 the save is modified:
Next, we'll create a new phpinfo to view the details of PHP:
vim/usr/share/nginx/html/phpinfo.php
<?php phpinfo ();?>
Visit http://ip/phpinfo.php after saving, and if the Phpinfo page appears, you are done.
How to create a new site
and brother. Unlike a key package, the LNMP installed by this method requires that the site configuration file be manually added.
Enter the profile directory and create a new site profile, such as
VI dearroy.com.conf
server {
listen;
#ipv6
#listen [::]:80 default_server;
root/usr/share/nginx/html/dearroy.com;
#默认首页文件名
index index.php index.html index.htm;
#绑定域名
server_name localhost;
#伪静态规则
include wordpress.conf;
Location/{
try_files $uri $uri//index.html;
}
#定义错误页面
#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, restart Nginx, add and bind the Web site is complete.
Finally, attach two most commonly used programs nginx pseudo static:
Wordpress:
Copy Code code 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:
Copy Code code as follows:
rewrite ^ ([^.] *)/topic-(. +). 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-(w+)-([0-9]+). html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^ ([^.] *)/thread-([0-9]+)-([0-9]+)-([0-9]+). html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3d$4&page= $ last;
rewrite ^ ([^.] *)/group-([0-9]+)-([0-9]+). html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^ ([^.] *)/space-(USERNAME|UID)-(. +). html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^ ([^.] *)/([a-z]+)-(. +). html$ $1/$2.php?rewrite=$3 last;
if (!-e $request _filename) {
return 404;