Table of Contents
1 安装前提示
2 安装 MySQL 5 数据库
3 安装 Nginx
4 安装 PHP5
5 配置 nginx
Home Database Mysql Tutorial Ubuntu 14.04 LTS 安装 LNMP Nginx/PHP5 (PHP-FPM)/MySQL_MySQL

Ubuntu 14.04 LTS 安装 LNMP Nginx/PHP5 (PHP-FPM)/MySQL_MySQL

Jun 01, 2016 pm 01:13 PM
resource

LNMPUbuntuNginx

最近在Ubuntu14.04 LTS 安装 LNMP 一键安装包的时候出现了问题,PHP 5 服务没有启动,只好使用 Ubuntu 官方源进行安装:

Nginx (读音 “engine x”)免费、开源、高效的 HTTP 服务。Nginx 是以稳定著称,功能丰富,结构简单,低资源消耗。本教程将演示如何在ubuntu 14.04 服务器中安装 nginx、PHP5(php-fpm)、MySQL。

----------------------------------------分割线----------------------------------------

Ubuntu 13.04 安装 LAMP/Vsftpd/Webmin/phpMyAdmin 服务及设置http://www.linuxidc.com/Linux/2013-06/86250.htm

CentOS6.4 下的LNMP 生产环境搭建及安装脚本http://www.linuxidc.com/Linux/2013-11/92428.htm

生产环境实用之LNMP架构的编译安装+SSL加密实现http://www.linuxidc.com/Linux/2013-05/85099.htm

LNMP 全功能编译安装 for CentOS 6.3笔记http://www.linuxidc.com/Linux/2013-05/83788.htm

CentOS 6.3 安装LNMP (PHP 5.4,MyySQL5.6)http://www.linuxidc.com/Linux/2013-04/82069.htm

在部署LNMP的时候遇到Nginx启动失败的2个问题http://www.linuxidc.com/Linux/2013-03/81120.htm

Ubuntu安装Nginx php5-fpm MySQL(LNMP环境搭建)http://www.linuxidc.com/Linux/2012-10/72458.htm

----------------------------------------分割线----------------------------------------

1 安装前提示

本文采用的主机名称:server1.example.com,IP地址:192.168.0.100。可能与你的主机有所不同,自行修改。

安装中我们使用root账户,先进行用户切换:

sudo su

2 安装 MySQL 5 数据库

安装 MySQL 运行命令:

apt-get install mysql-server mysql-client

安装过程中会询问建立 Root 账户密码,连续输入两次:

New password for the MySQL “root” user:Repeat password for the MySQL “root” user:

Mysqlpasswd

3 安装 Nginx

在安装 Nginx 之前,如果你已经安装 Apache2 先删除在安装 nginx:

service apache2 stop
update-rc.d -f apache2 remove
apt-get remove apache2

apt-get install nginx

启动 nginx 服务:

service nginx start

试试安装是否成功,在浏览器输入IP或主机地址 (e.g.http://192.168.0.100),如下图所示,说明安装成功:

在 Ubuntu 14.04 中默认的根目录为/usr/share/nginx/html.

4 安装 PHP5

我们必须通过PHP-FPM才能让PHP5正常工作,安装命令:

apt-get install php5-fpm

php-fpm是一个守护进程。

5 配置 nginx

使用Vi打开配置文件/etc/nginx/nginx.conf:

vi /etc/nginx/nginx.conf

配置不是很容易明白,可以参考:http://wiki.nginx.org/NginxFullExample和http://wiki.nginx.org/NginxFullExample2

我们需要调整工作进程数设置,如下面的值设置:

[...]worker_processes4;[...]keepalive_timeout 2;[...]
Copy after login

默认虚拟主机设置文件/etc/nginx/sites-available/default按如下设置:

vi /etc/nginx/sites-available/default

[...]server {	listen 80;	listen [::]:80 default_server ipv6only=on;	root /usr/share/nginx/html;	index index.php index.html index.htm;	# Make site accessible from http://localhost/	server_name _;	location / {		# First attempt to serve request as file, then		# as directory, then fall back to displaying a 404.		try_files $uri $uri/ /index.html;		# Uncomment to enable naxsi on this location		# include /etc/nginx/naxsi.rules	}	location /doc/ {		alias /usr/share/doc/;		autoindex on;		allow 127.0.0.1;		allow ::1;		deny all;	}	# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests	#location /RequestDenied {	# proxy_pass http://127.0.0.1:8080;	#}	#error_page 404 /404.html;	# redirect server error pages to the static page /50x.html	#	error_page 500 502 503 504 /50x.html;	location = /50x.html {		root /usr/share/nginx/html;	}	# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000	#	location ~ .php$ {		try_files $uri =404;		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;	}	# deny access to .htaccess files, if Apache's document root	# concurs with nginx's one	#	location ~ /.ht {		deny all;	}}[...]
Copy after login

取消同时侦听 IPv4IPv6 的80端口。

server_name _;默认主机名 (当然你可以修改,例如修改为:www.example.com).

index主页这一行我们加入index.php。

PHP 重要配置配置location ~ .php$ {}这几行我们需要启动,反注释掉。另外再添加一行:try_files $uri =404。

(其他配置查看http://wiki.nginx.org/Pitfalls#Passing_Uncontrolled_Requests_to_PHP和http://forum.nginx.org/read.php?2,88845,page=3).

保存文件并重新加载 nginx 命令:

service nginx reload

如果加载失败,直接用删除所有配置内容,用上面的信息替换。

更多详情见请继续阅读下一页的精彩内容:http://www.linuxidc.com/Linux/2014-05/102351p2.htm

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to find resources on 115 network disk How to find resources on 115 network disk Feb 23, 2024 pm 05:10 PM

There will be a lot of resources in the 115 network disk, so how to find resources? Users can search for the resources they need in the software, then enter the download interface, and then choose to save to the network disk. This introduction to the method of finding resources on 115 network disk can tell you the specific content. The following is a detailed introduction, come and take a look. How to find resources on 115 network disk? Answer: Search the content in the software, and then click to save to the network disk. Detailed introduction: 1. First enter the resources you want in the app. 2. Then click the keyword link that appears. 3. Then enter the download interface. 4. Click Save to network disk inside.

Why did Han Xiaoquan suddenly have no resources? Why did Han Xiaoquan suddenly have no resources? Feb 24, 2024 pm 03:22 PM

Han Xiaoquan is a software that can watch many Korean dramas, so why is there suddenly no resource? This software may have no resources due to network problems, version problems, or copyright issues. This article about the reason why Han Xiaoquan suddenly has no resources can tell you the specific content. The following is a detailed introduction, come and take a look. Why did Han Xiaoquan suddenly have no resources? Answer: Due to network problems, version problems, and copyright issues, detailed introduction: 1. Solution to network problems: You can choose a different network, and then log in to the software again to try. 2. Solution to version problems: Users can download the latest version of this software from the official website. 3. Solutions to copyright issues: Some Korean dramas are removed from the shelves due to copyright issues. You can choose other Korean dramas to watch.

Explorer.exe crashing in Windows 11 safe mode no longer occurs Explorer.exe crashing in Windows 11 safe mode no longer occurs Aug 30, 2023 pm 11:09 PM

Explorer.exe crashes in Safe Mode on Windows 11? Not anymore. Microsoft has just released a new patch to the Dev Channel, and while there are no new features in this release, many fixes and improvements are making their way into the Windows Insider program, including an annoying bug where Explorer.exe crashes in Safe Mode. Well, you can say goodbye to it now, at least in the Windows Insider Program. But as with all these updates, they will also be coming to live Windows servers. Fixed an issue that caused Explorer.exe to not work in safe mode. However, there are a few other fixes coming to File Explorer, so Microsoft is keen to get it working

How to refresh Dying Light resources infinitely How to refresh Dying Light resources infinitely Jan 24, 2024 pm 04:03 PM

In the game Dying Light, many players may be surrounded by countless zombies in the early stage due to lack of resources. Sometimes they will also take risks to rescue trapped wanderers, and these wanderers may also provide some side tasks, which will be richly rewarded upon completion. Dying Light Unlimited Resource Acquisition First, find a relief package and put it in the warehouse. On the home page of the [Inventory], select an item with a larger quantity and click with the left mouse button when selected. 2. Then, press [ESC] without moving the mouse. Press F+A quickly. Just press once. After about 0.25 seconds, when you feel that the warehouse page is about to pop up, press the left and right buttons of the mouse. Do not move the mouse and do not press and hold. The prompt to store the items will pop up and it will be successful. 3Finally, find [Disaster Package] in the warehouse and be prompted by

Go language graphical interface development: explore existing tools and resources Go language graphical interface development: explore existing tools and resources Mar 23, 2024 pm 03:06 PM

Guiding principle: The Go language itself does not directly support graphical interface development, but graphical interface development can be achieved by calling libraries in other languages ​​or using existing tools. This article will introduce some commonly used tools and resources to help readers better explore the possibility of using Go language for graphical interface development. 1. Current status of graphical interface development in Go language Go language is an efficient and concise programming language that is suitable for various application fields, but it is not good at graphical interface development. Due to the performance and concurrency features of the Go language, many developers want

Sudden! ChatGPT Plus discontinued Sudden! ChatGPT Plus discontinued Apr 07, 2023 pm 09:01 PM

Now, ChatGPT no longer supports Plus payment. △The reason for the screenshot of ChatGPT is very simple: High demand. Demand was so high that OpenAI had to suspend sales of the Plus. There is no word on when it will open later. A few days ago, ChatGPT caused heated discussions due to large-scale account bans, and now it has officially closed the application for Plus paid membership. Many netizens attribute it to insufficient computing resources, which is no longer a problem that can be solved with money alone. The financial backer, Microsoft, also needs to provide its own user base. There is no longer enough computing power on earth to meet demand. Some netizens who have already paid expressed their gratitude: I really can’t imagine going back to the days of GPT-3.5. ChatGPT closePlu

Java Error: Application resource cannot be found, how to solve and avoid Java Error: Application resource cannot be found, how to solve and avoid Jun 24, 2023 pm 06:58 PM

Java is a programming language widely used for developing applications and creating websites. However, when developing and deploying Java applications, you may encounter the following error: The application resource cannot be found. This error often occurs when packaging and deploying Java applications. This article discusses the causes, solutions, and ways to avoid this error. Error Cause The application resource cannot be found error is usually caused by some of the following reasons: 1.1 File is missing or damaged: When the application package or dependent library file is missing or damaged,

What are some resources for learning advanced Python programming? What are some resources for learning advanced Python programming? Sep 01, 2023 pm 02:45 PM

The demand for Python as a programming language has driven its rich resources for learning its different aspects. While beginners have a variety of tutorials and guides to help them get started, advanced learners often struggle to find resources that meet their specific needs. In this article, we'll explore a series of resources designed to improve your Python skills, covering topics such as advanced language features, design patterns, performance optimization, and more. Advanced Python language featuresTogetthemostoutofPython,it’simportanttomasteritsadvancedlanguagefeatures.Thesefeaturesenableefficient,rea

See all articles