1.

  How To Install Linux & Nginx & MySQL & PHP (LEMP) stack on Raspberry Pi 3  

      Raspberry Pi 3,LEMP,Linux,Nginx,PHP(PHP-FPM), MySQL(MariaDB)          

Nginx (pronounced "Engine x") is a free, open-source, high-performance HTTP server.

Nginx is known for its stability, rich feature set, simple configuration, and low resource consumption.

This tutorial shows how you can install Nginx on an Ubuntu 14.04 server with PHP5 support (through PHP-FPM) and MySQL support (LEMP = Linux + Nginx (pronounced "Engine x") + MySQL + PHP) .

What’s a LEMP stack?

LEMP is a variation of the ubiquitous LAMP stack used for developing and deploying web applications. Traditionally, LAMP consists of Linux, Apache, MySQL, and PHP. Due to its modular nature, the components can easily be swapped out. With LEMP, Apache is replaced with the lightweight yet powerful Nginx.

Why LEMP instead of LNMP?

We go with LEMP due to the pronunciation for Nginx: Engine-X (en-juhn-ecks). Think of how in English, the article an is used instead of a for hour even though it begins with a consonant. The importance is the sound of the first letter rather than its written representation. Besides, LEMP is actually pronounceable and doesn’t sound like reciting the alphabet.

https://lemp.io/

1

https://www.howtoforge.com/installing-nginx-with-php5-fpm-and-mysql-on-ubuntu-14.04-lts-lemp

Installing Nginx With PHP5 (And PHP-FPM) And MySQL Support (LEMP)

On Ubuntu 14.04 LTS

https://www.howtoforge.com/tutorial/installing-nginx-with-php-and-mysql-on-ubuntu-lemp/

Installing Nginx with PHP and MariaDB (as MySQL replacement) - LEMP

on Ubuntu 15.10 (Wiley Werewolf)

Links

1

1

1

1

1

1

1

1

1

1

1 . PHP FastCGI Example

https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/

This example is for newer PHP (>= 5.3.3) using the included PHP FPM (FastCGI Process Manager).

This guide assume PHP FPM already installed and configured either using tcp port (127.0.0.1:9000) or unix socket (/var/run/php-fpm.sock).

There are many guide about configuring NGINX with PHP FPM, but many of them are incomplete (doesn’t handle PATH_INFO correctly) or contain security issues (doesn’t check whether the script is indeed php file).

FastCGI Params

First thing, I recommend keeping all your typical FCGI settings in a single file and importing them.

For example on debian and ubuntu by default there is /etc/nginx/fastcgi_params file that should looks like this:

fastcgi_param   QUERY_STRING            $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name; fastcgi_param HTTPS $https; # PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

Please note if you’re using Ubuntu Precise (12.04), I change SCRIPT_FILENAME and add PATH_INFO params.

Connecting NGINX to PHP FPM

Now we must tell NGINX to proxy requests to PHP FPM via the FCGI protocol:

location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
} fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}

If you’re using unix socket change fastcgi_pass to:

fastcgi_pass unix:/var/run/php5-fpm.sock;

Restart NGINX.

Testing

Create test.php on NGINX document root containing just:

<?php var_export($_SERVER)?>

In the browser try to request: # /test.php # /test.php/ # /test.php/foo # /test.php/foo/bar.php # /test.php/foo/bar.php?v=1

Pay attention to the value of REQUEST_URI, SCRIPT_NAME, PATH_INFO and PHP_SELF.

Here’s the correct output for http://lemp.test/test.php/foo/bar.php?v=1

array (
'USER' => 'www-data',
'HOME' => '/var/www',
'FCGI_ROLE' => 'RESPONDER',
'QUERY_STRING' => 'v=1',
'REQUEST_METHOD' => 'GET',
'CONTENT_TYPE' => '',
'CONTENT_LENGTH' => '',
'SCRIPT_FILENAME' => '/var/www/test.php',
'SCRIPT_NAME' => '/test.php',
'PATH_INFO' => '/foo/bar.php',
'REQUEST_URI' => '/test.php/foo/bar.php?v=1',
'DOCUMENT_URI' => '/test.php/foo/bar.php',
'DOCUMENT_ROOT' => '/var/www',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'SERVER_SOFTWARE' => 'nginx/1.4.0',
'REMOTE_ADDR' => '192.168.56.1',
'REMOTE_PORT' => '44644',
'SERVER_ADDR' => '192.168.56.3',
'SERVER_PORT' => '80',
'SERVER_NAME' => '',
'HTTPS' => '',
'REDIRECT_STATUS' => '200',
'HTTP_HOST' => 'lemp.test',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:20.0) Gecko/20100101 Firefox/20.0',
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.5',
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
'HTTP_CONNECTION' => 'keep-alive',
'PHP_SELF' => '/test.php/foo/bar.php',
'REQUEST_TIME' => 1367829847,
)

Notes

  1. The location regex capable to handle PATH_INFO and properly check that the extension indeed .php (not .phps) whether there is PATH_INFO or not.
  2. The fastcgi_split_path_info regex capable to correctly handle request like /test.php/foo/blah.php or /test.php/.
  3. The if lets NGINX check whether the *.php does indeed exist to prevent NGINX to feeding PHP FPM non php script file (like uploaded image).

Some guides recommend to use try_files instead of if, if you do that, beware of NGINX bug #321. I personally think ifis more appropriate for this, even If Is Evil agree this is one of the 100% safe thing to use if with.

This guide run fine on php.ini cgi.fix_pathinfo = 1 (the default). Some guide insist to change it to cgi.fix_pathinfo =0 but doing that make PHP_SELF variable broken (not equal to DOCUMENT_URI).

1

1

1

1

1

1

1

1

How To Install Linux & Nginx & MySQL & PHP (LEMP) stack on Raspberry Pi 3,Raspberry Pi 3,LEMP,Nginx,PHP, LEMP (not LNMP)的更多相关文章

  1. How to Install Linux, Apache, MySQL, PHP (LAMP) stack on CentOS 6 【Reliable】

    About LAMP LAMP stack is a group of open source software used to get web servers up and running. The ...

  2. The MEAN stack is a modern replacement for the LAMP (Linux, Apache, MySQL, PHP/Python) stack

    w https://www.mongodb.com/blog/post/building-your-first-application-mongodb-creating-rest-api-using- ...

  3. ubuntu14.04 LEMP(linux+nginx+mysql+php5)构建环境

    Install LEMP (Linux, Nginx, MySQL and PHP) Stack on Ubuntu Linux 14.04 LTS by VIVEK GITE on DECEMBER ...

  4. How To Install Linux, nginx, MySQL, PHP (LEMP) stack on CentOS 6

    About Lemp LEMP stack is a group of open source software to get web servers up and running. The acro ...

  5. Linux Debian 7部署LEMP(Linux+Nginx+MySQL+PHP)网站环境

    我们在玩VPS搭建网站环境的时候,都经常看到所谓的LAMP.LNMP.LEMP,LAMP, 其中的A代表APECHE WEB驱动环境,LNMP中的N代表NGINX驱动环境,只不过海外的叫法NGINX ...

  6. 阿里云服务器部署php的laravel项目,在阿里云买ECS 搭建 Linux+Nginx+Mysql+PHP环境的

    在阿里云买ECS的时候选择自己习惯的镜像系统,我一般都是使用Linux Ubuntu,所以,以下的配置都是在Ubuntu 14.04稳定支持版的环境中搭建Linux+Nginx+Mysql+PHP环境 ...

  7. LNMP(linux+nginx+mysql+php)服务器环境配置

    一.简介 Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为 “engine X”, 是一个高性能的HTTP和反向代理服务器,同时也是一个IMAP/POP3/SMTP 代理服 ...

  8. linux jdk+mysql+tomcat+nginx 项目部署步骤

    1.下载linux jdk1.7.0_79.tar.gz ; 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk7-dow ...

  9. [Linux] Ubuntu Server 12.04 LTS 平台上搭建WordPress(Nginx+MySql+PHP) Part II

    接着上一节继续搭建我们的LNMP平台,接下来我们安装PHP相关的服务 sudo apt-get install php5-cli php5-cgi php5-fpm php5-mcrypt php5- ...

随机推荐

  1. apk开发环境!多亏这份《秋招+金九银十-腾讯面试题合集》跳槽薪资翻倍!再不刷题就晚了!

    开头 最近很多网友反馈:自己从各处弄来的资料,过于杂乱.零散.碎片化,看得时候觉得挺有用的,但过个半天,啥都记不起来了.其实,这就是缺少系统化学习的后果. 为了提高大家的学习效率,帮大家能快速掌握An ...

  2. 一体化的Linux系统性能和使用活动监控工具–Sysstat

    [转]原文出处: Tecmint-Kuldeep Sharma   译文出处:Linux Story-天寒   欢迎分享原创到伯乐头条 在监控系统资源.系统性能和使用活动方面,Sysstat的确是一个 ...

  3. CPU处理器架构和工作原理浅析

    CPU处理器架构和工作原理浅析 http://c.biancheng.net/view/3456.html 汇编语言是学习计算机如何工作的很好的工具,它需要我们具备计算机硬件的工作知识. 基本微机设计 ...

  4. NodeJS入门学习教程

    一.概念 1.什么是nodejs Node.js是JavaScript 运行时环境,通俗易懂的讲,Node.js是JavaScript的运行平台 Node.js既不是语言,也不是框架,它是一个平台 2 ...

  5. 【算法】数位 dp

    时隔多日,我终于再次开始写博客了!! 上午听了数位 dp,感觉没听懂,于是在网上进行一番愉 ♂ 快 ♀ 的学习后,写篇博来加深一下印象~~ 前置的没用的知识 数位 不同计数单位,按照一定顺序排列,它们 ...

  6. Spring整合SpringMVC + Mybatis基础框架的配置文件

    目录 前言 1. Mybatis层编写 2. Spring层编写 1. Spring整合Mybatis 2. Spring整合service 3. SpringMVC层编写 1. 编写web.xml ...

  7. Excel 快速填充:填充柄+数据验证

    鼠标左键拖拽填充或者双击填充 右键拖拽填充: 可以填充等比数列.工作日等等 数据验证: 通过下拉箭头快速选择数据: 选择单元格区域-[数据]-[数据验证]-序列 数据科学交流群,群号:18915878 ...

  8. 反弹SHELL介绍及原理

    如果我们需要到服务器上执行 Shell 命令,但是因为防火墙等原因,无法由客户端主动发起连接的情况,就可以使用反弹 Shell 来满足登陆和操作的需求. 什么是反弹Shell 正常情况下,我们登陆服务 ...

  9. Java——介绍

    Java基础语法: 一个Java程序可以认为是一系列对象的集合,而这些对象通过彼此的方法来协同工作. 对象: 对象是类的一个实例,有状态和行为.例如,一条狗是一个对象,它的状态有:颜色.名字.品种:行 ...

  10. 使用session实现网站N天免登陆()

    问题描述: 一些网站的N天之内免登陆实现方式. 方式一: 首先想到的是使用cookie保存用户登录信息,设置有效期,在用户下次访问时免去登录环节,直接通过cookie获取用户信息. 方式二: 方式二: ...