目录
ubuntu14.04 LEMP(linux+nginx+mysql+php5)构建环境,
Install LEMP (Linux, Nginx, MySQL and PHP) Stack on Ubuntu Linux 14.04 LTS
What is new in Ubuntu 14.04 (Trusty Tahr) version?
Nginx Installation
#2 - Test Nginx
MySQL Installation On Ubuntu
#1 - Install MySQL and PHP support
#2 - Test MySQL
#3 - Securing access to MySQL
2.Change the root password
3.Remove anonymous user
4.Disallow root login remotely
5.Remove test database
6.Reload privilege tables
7.Done
PHP Installation For Server Side Scripting
#1 - Download and install PHP
Configure Nginx to work with PHP and MySQL Server on Ubuntu
#1 - Configure PHP5-FPM
#2 - Configure Nginx
#3 - Configure MySQL
首页 php教程 php手册 ubuntu14.04 LEMP(linux+nginx+mysql+php5)构建环境,

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

Jun 13, 2016 am 08:49 AM
lemp 构建 环境

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 2, 2014

I'm a new Ubuntu Linux user. How do I install the LEMP stack on an Ubuntu Linux 14.04 LTS server using command line options to serve dynamic web apps?
Tutorial details Difficulty Easy (rss) Root privileges Yes Requirements Ubuntu Estimated completion time 15m

What is new in Ubuntu 14.04 (Trusty Tahr) version?

You may see it on cyberciti.biz or visit the Ubuntu home page at ubuntu.com.

Nginx Installation

Nginx is one of the robust web server in Linux world. Nginx is a free, open source, high performance HTTP server and reverse proxy, as weell as an IMAP/POP3 proxy server. Now, we are going to install Nginx web server.

First, make sure system is upto date:
$ sudo apt-get update
#1 - Download and Install Nginx

The easiest way to download and install Nginx is using apt-get command. Here is the command:
$ sudo apt-get install nginx
Fig.01: Download and Install Nginx on Ubuntu Linux


#2 - Test Nginx

Once it get done, you can open your browser and type url http://localhost or http://your_ip_address to test it. If everything goes normal, you will see Nginx welcome page:
Fig.02: Welcome nginx page on Ubuntu Linux

MySQL Installation On Ubuntu

MySQL is one of the most powerful database management system in Linux world. Next, we are going to install it with PHP support.

#1 - Install MySQL and PHP support

Type the following command:
$ sudo apt-get install mysql-server php5-mysql
Fig.03: Ubuntu Linux Install MySQL to Manage Site Data with PHP


#2 - Test MySQL

Once mysql installation finished, we can test it. Open your console and type the following command:
$ mysql -u root -p
Fig.04: Ubuntu test Mysql installation


#3 - Securing access to MySQL

If we are going to use MySQL as a production database, we may want to secure it. MySQL provides a shell script to help us securing it. Just type the following command on your console:
$ sudo mysql_secure_installation
1. Enter your root password

Enter your current root password to continue to the next step.
Fig.05: MySQL enter your root db password

2.Change the root password

If you want to change it, press Y. Otherwise, press N.
Fig.06: MySQL security

3.Remove anonymous user

It is recommended to remove anonymous user to mitigate risk who can log in into your database.
Fig.07: MySQL security

4.Disallow root login remotely

To make sure that no one remote your database as root from another machines, we need to disallow root login remotely.
Fig.08: MySQL security

5.Remove test database

Sometimes some MySQL installation will create a database named ëtestí for testing purpose. We can remove it if we donít use it.
Fig.09: MySQL security

6.Reload privilege tables

Then we need to reloading the privilege tables to ensure all changes made so far will take effect immediately.
Fig.10: MySQL security

7.Done

Fig.11: MySQL security

PHP Installation For Server Side Scripting

Since PHP is popular, a lot of websites is built using PHP language. As of January 2013, PHP was installed on more than 240 millions websites. Now we are going to install PHP on Ubuntu 14.04

#1 - Download and install PHP

As usual, we can download and install PHP using apt-get command. Just type the following command on your Ubuntu console or over the ssh based session:
$ sudo apt-get install php5-fpm
Fig.12: Install PHP for Server Side Processing on Ubuntu


Configure Nginx to work with PHP and MySQL Server on Ubuntu

Now we have all components installed. The next step is we need to configure Nginx with PHP and MySQL. Let's start to configure them.

#1 - Configure PHP5-FPM

PHP5-FPM configuration file is located at /etc/php5/fpm/php.ini. Open it with your text editor
$ sudo vi /etc/php5/fpm/php.ini
cgi.fix_pathinfo=1
cgi.fix_pathinfo=0
$ sudo service php5-fpm restart

#2 - Configure Nginx

Nginx configuration file is located at /etc/nginx/nginx.conf. But basically, we don't need to touch it. The configuration of nginx website is located in /etc/nginx/sites-available/default file.
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; }

Then restart the services.
$ sudo service nginx restart
$ tail /var/log/nginx/error.log
fastcgi_pass unix:/var/run/php5-fpm.sock

location ~ \.php$ {

#3 - Configure MySQL

After the configuration section is done, now we need to test them to make sure that our configuration is working as required. On Ubuntu 14.04 the root document folder is located in /usr/share/nginx/html. So create a file called /usr/share/nginx/html/phpinfo.php with the following code:

[php] view plaincopy

After restarting PHP-FPM and Nginx, open the browser and browse to the php file, we got only a blank screen. No error message on the screen. No error message on PHP-FPM and Nginx log file.

  • "margin:0px; padding:0px; word-wrap:break-word; color:rgb(0,0,0)"> "_blank" href="http://www.php.net/phpinfo" style="margin:0px; padding:0px; word-wrap:break-word; color:rgb(128,128,128); text-decoration:none">"margin:0px; padding:0px; word-wrap:break-word; color:rgb(0,0,102)">phpinfo"margin:0px; padding:0px; word-wrap:break-word; color:rgb(102,204,102)">("margin:0px; padding:0px; word-wrap:break-word; color:rgb(102,204,102)">); "margin:0px; padding:0px; word-wrap:break-word; color:rgb(0,0,0)">?>
  • And then open the browser again and type url http://your_ip_address/phpinfo.php

  • "margin:0px; padding:0px; word-wrap:break-word; color:rgb(0,0,0)"> ... your code ... "margin:0px; padding:0px; word-wrap:break-word; color:rgb(0,0,0)">?>
  • To enable short php tag, we need to change the value of short_open_tag parameter on php.ini file:
    sudo service php5-fpm restart
    Then try again to test your phpinfo file. Next, we will see if the MySQL support is enabled or not. Scroll down the php configuration screen on your browser, if you see MySQL block there, then MySQL support already enabled.

    You are now ready to use Nginx, PHP5 and MySQL on Ubuntu server. I hope this quick article help anyone who wish to install Linux, Nginx, PHP and MySQL on Ubuntu 14.04.

    本站声明
    本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

    热AI工具

    Undresser.AI Undress

    Undresser.AI Undress

    人工智能驱动的应用程序,用于创建逼真的裸体照片

    AI Clothes Remover

    AI Clothes Remover

    用于从照片中去除衣服的在线人工智能工具。

    Undress AI Tool

    Undress AI Tool

    免费脱衣服图片

    Clothoff.io

    Clothoff.io

    AI脱衣机

    Video Face Swap

    Video Face Swap

    使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

    热工具

    记事本++7.3.1

    记事本++7.3.1

    好用且免费的代码编辑器

    SublimeText3汉化版

    SublimeText3汉化版

    中文版,非常好用

    禅工作室 13.0.1

    禅工作室 13.0.1

    功能强大的PHP集成开发环境

    Dreamweaver CS6

    Dreamweaver CS6

    视觉化网页开发工具

    SublimeText3 Mac版

    SublimeText3 Mac版

    神级代码编辑软件(SublimeText3)

    无法引导到Windows恢复环境 无法引导到Windows恢复环境 Feb 19, 2024 pm 11:12 PM

    Windows恢复环境(WinRE)是用于修复Windows操作系统错误的环境。进入WinRE后,您可以执行系统还原、出厂重置、卸载更新等操作。如果无法引导到WinRE,本文将指导您使用修复程序解决此问题。无法引导到Windows恢复环境如果无法引导至Windows恢复环境,请使用下面提供的修复程序:检查Windows恢复环境的状态使用其他方法进入Windows恢复环境您是否意外删除了Windows恢复分区?执行Windows的就地升级或全新安装下面,我们已经详细解释了所有这些修复。1]检查Wi

    Python和Anaconda之间有什么区别? Python和Anaconda之间有什么区别? Sep 06, 2023 pm 08:37 PM

    在本文中,我们将了解Python和Anaconda之间的差异。Python是什么?Python是一种开源语言,非常重视使代码易于阅读并通过缩进行和提供空白来理解。Python的灵活性和易于使用使其非常适用于各种应用,包括但不限于对于科学计算、人工智能和数据科学,以及创造和发展的在线应用程序。当Python经过测试时,它会立即被翻译转化为机器语言,因为它是一种解释性语言。有些语言,比如C++,需要编译才能被理解。精通Python是一个重要的优势,因为它非常易于理解、开发,执行并读取。这使得Pyth

    构建自定义的WordPress用户流程,第三部分:密码重置 构建自定义的WordPress用户流程,第三部分:密码重置 Sep 03, 2023 pm 11:05 PM

    在本系列的前两个教程中,我们构建了用于登录和注册新用户的自定义页面。现在,登录流程中只剩下一个部分需要探索和替换:如果用户忘记密码并想要重置WordPress密码,会发生什么?在本教程中,我们将解决最后一步并完成我们在整个系列中构建的个性化登录插件。WordPress中的密码重置功能或多或少遵循当今网站上的标准方法:用户通过输入用户名或电子邮件地址并请求WordPress重置密码来启动重置。创建临时密码重置令牌并将其存储在用户数据中。包含此令牌的链接将发送到用户的电子邮件地址。用户点击链接。在重

    ChatGPT Java:如何构建一个智能音乐推荐系统 ChatGPT Java:如何构建一个智能音乐推荐系统 Oct 27, 2023 pm 01:55 PM

    ChatGPTJava:如何构建一个智能音乐推荐系统,需要具体代码示例引言:随着互联网的迅猛发展,音乐已经成为人们日常生活中必不可少的一部分。而随着音乐平台的不断涌现,用户经常面临一个共同的问题:如何找到符合自己口味的音乐?为了解决这个问题,智能音乐推荐系统应运而生。本文将介绍如何使用ChatGPTJava构建一个智能音乐推荐系统,并提供具体代码示例。第

    构建流畅无阻:如何正确配置Maven镜像地址 构建流畅无阻:如何正确配置Maven镜像地址 Feb 20, 2024 pm 08:48 PM

    构建流畅无阻:如何正确配置Maven镜像地址在使用Maven构建项目时,配置正确的镜像地址是非常重要的。正确配置镜像地址可以加快项目构建的速度,避免网络延迟等问题。本文将介绍如何正确配置Maven镜像地址,并给出具体的代码示例。为什么需要配置Maven镜像地址Maven是一个项目管理工具,可以自动化构建项目、管理依赖、生成报告等。在Maven构建项目时,通常

    在 Windows 3 上设置环境变量的 11 种方法 在 Windows 3 上设置环境变量的 11 种方法 Sep 15, 2023 pm 12:21 PM

    在Windows11上设置环境变量可以帮助您自定义系统、运行脚本和配置应用程序。在本指南中,我们将讨论三种方法以及分步说明,以便您可以根据自己的喜好配置系统。有三种类型的环境变量系统环境变量–全局变量处于最低优先级,可由Windows上的所有用户和应用访问,通常用于定义系统范围的设置。用户环境变量–优先级越高,这些变量仅适用于在该帐户下运行的当前用户和进程,并由在该帐户下运行的用户或应用程序设置。进程环境变量–具有最高优先级,它们是临时的,适用于当前进程及其子进程,为程序提供

    优化Maven项目打包流程,提升开发效率 优化Maven项目打包流程,提升开发效率 Feb 24, 2024 pm 02:15 PM

    Maven项目打包步骤指南:优化构建过程,提高开发效率随着软件开发项目变得越来越复杂,项目构建的效率和速度成为了开发过程中不可忽视的重要环节。作为一种流行的项目管理工具,Maven在项目构建中扮演了关键角色。本指南将探讨如何通过优化Maven项目的打包步骤,提高开发效率,并提供具体的代码示例。1.确认项目结构在开始优化Maven项目打包步骤之前,首先需要确

    如何利用Python构建智能语音助手 如何利用Python构建智能语音助手 Sep 09, 2023 pm 04:04 PM

    如何利用Python构建智能语音助手引言:在现代科技快速发展的时代,人们对于智能化助手的需求越来越高。智能语音助手作为其中的一种形式,已经被广泛应用于手机、电脑、智能音箱等各种设备中。本文将介绍如何利用Python编程语言构建一个简单的智能语音助手,帮助您从零开始实现一个属于自己的个性化智能助手。准备工作在开始构建语音助手之前,我们首先需要准备一些必要的工具

    See all articles