1. 1、先更新ubuntu系统

    更新命令

    sudo apt-get update

    sudo apt-get upgrade

  2. 2

    添加ubuntu nginx更新源镜像

    cd /etc/apt/

    sudo cp sources.list sources.list_bak

    将如下代码添加到sources.list文件中

    deb http://nginx.org/packages/ubuntu/ precise nginx

    deb-src http://nginx.org/packages/ubuntu/ precise nginx

    使用

    sudo vi sources.list

    如果提示: W: GPG error: http://nginx.org precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ABF5BD827BD9BF62 由于官方不信任该源

    解决方法: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ABF5BD827BD9BF62

  3. 3

    3、更新和安装update and install

    sudo apt-get update

    sudo apt-get install nginx

  4. 4、启动nginx

    sudo /etc/init.d/nginx start

  5. 5、check version

    nginx -v

  6. 6、配置php+mysql

    sudo apt-get install php5-cli php5-cgi mysql-server php5-mysql

  7. 7、安装FastCgi

    sudo apt-get install spawn-fcgi

  8. 8、配置nginx

    8.1、修改nginx的配置文件:/etc/nginx/sites-available/default 修改主机名

    server_name localhost;

    8.2、修改index的一行,添加index.php

    index index.php index.html index.htm;

    8.3、去掉下面部分的注释用于支持 php 脚本:

    location ~ .php$ {    include /etc/nginx/fastcgi_params; #需放在第一行,否则会出错    fastcgi_pass 127.0.0.1:9000;    fastcgi_index index.php;    fastcgi_param SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name; }

  9. 9、 重新启动nginx

    /etc/init.d/nginx stop

    /etc/init.d/nginx start

  10. 10、启动fastcgi php

    spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi

  11. 11、nginx提示502 错误

    nginx 502 Bad Gateway没有启动,启动命令是:

    spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi

  12. 12、设置开机自启动

    Ubuntu开机之后会执行/etc/rc.local文件中的脚本

    所以我们可以直接在/etc/rc.local中添加启动脚本。

    spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi 添加到语句: exit 0

    前面才行

  13. 13、no input file specified错误

    sudo vi /etc/nginx/sites-available/default

    其中这个字段

    location ~ .php$ {

    root html;

    fastcgi_pass 127.0.0.1:9000;

    fastcgi_index index.php;

    fastcgi_param SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name;

    include fastcgi_params;

    }

    注意

    fastcgi_param SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name;

    /var/www/nginx-default 改为你的网站根目录,一般就是改成这个。

    server 字段下root 目录和网站根目录保持一致

    其中FastCGI和php5-fpm都用来解析php模块的,所以随意安装其中一个即可,然后配置文件里有两个 location ~ .php$ ,只取消最下面的这个注释;先安装Nginx,然后测试下可否工作,再 安装php cgi spawn-fcgi 这些模块,修改下配置文件,即可。

Ubuntu Nginx安装的更多相关文章

  1. ubuntu nginx 安装以及配置文件详解

    1.到nginx官网下载源码包.最好下载稳定版本,nginx官网http://www.nginx.org/ 2.安装nginx依赖包运行命令: sudo apt-get install libssl- ...

  2. ubuntu nginx安装及相关linux性能參数优化

    一.安装 下载源代码,解压:tar -xzvf nginx-1.4.7.tar.gz ./configure make && make install 改动默认nginx的监听port ...

  3. ubuntu nginx 安装 certbot(letsencrypt)

    https://certbot.eff.org 到上面网站按照步骤安装certbot, 安装完成后,certbot 生成证书有两种方式 第一种:standalone模式,certbot 会启动自带的n ...

  4. Ubuntu下安装Nginx

    转载自:http://www.cnblogs.com/skynet/p/4146083.html 1.Nginx安装 我使用的环境是64位 Ubuntu 14.04, Nginx是Nginx 1.10 ...

  5. ubuntu server nginx 安装与配置

    ubuntu server nginx 安装与配置 一:关于nginx http://wiki.ubuntu.org.cn/Nginx http://nginx.org/cn http://wiki. ...

  6. Ubuntu下安装Nginx,PHP5(及PHP-FPM),MySQL

    .简介: Tomcat在高并发环境下处理动态请求时性能很低,而在处理静态页面更加脆弱.虽然Tomcat的最新版本支持epoll,但是通过Nginx来处理静态页面要比通过Tomcat处理在性能方面好很多 ...

  7. Ubuntu编译安装nginx,php,mysql

    摘要: 整理的Ubuntu编译安装nginx,php,mysql的步骤,主要来自对驻云的sh-1.4.1中脚本的整理,随时代进步,内容中的软件或者命令请自行更新 目录准备 创建用户 userdel w ...

  8. Ubuntu下安装LNMP之php7的安装并配置Nginx支持php及卸载php

    据了解,php7是比之前的版本性能快很多的.http://php.net/get/php-7.2.2.tar.gz/from/a/mirror 安装前也可提前将相关依赖库安装好,或者在安装php时若安 ...

  9. Ubuntu 编译安装 nginx

    有关博客: <Windows 编译安装 nginx 服务器 + rtmp 模块>.<Ubuntu 编译安装 nginx>.<Arm-Linux 移植 Nginx> ...

随机推荐

  1. //获取url中"?"符后的字串

    //获取url中"?"符后的字串 function getParamByUrl(url) {    var theRequest = new Object();    var in ...

  2. A convenient way of installing(compiling) VIM with YCM

    Ah, while I am still downloading LLVM from github(very slow.. and very large in size). I come with m ...

  3. Box2d b2World的RayCast方法

    RayCast方法: world.RayCast(callback:Function,point1:b2Vec2,point2:b2Vec2); * callback 回调函数 * point1 射线 ...

  4. 学习笔记——代理模式Proxy

    代理模式,主要是逻辑和实现解耦.具体逻辑如何,由代理Proxy自己来设计,我们只需要把逻辑Subject交给代理即可. 主要应用场景,包括创建大开销对象时,使用代理来慢慢创建:远程代理,如网络不确定时 ...

  5. 关于VC中的错误处理

    include <exception> try {} cache(exception &e) { cout<<e.what()<<endl; }     但 ...

  6. Android Studio的使用(十)--读取assets、Raw文件夹下文件,以及menu、drawable文件夹

    1.直接在/src/main目录下面新建assets目录 2.接下来即可读取文件 3.读取Raw文件夹下文件也类似.首先在res文件夹下新建raw目录,然后放入需要的文件即可读取. 4.menu和dr ...

  7. linq to sql DAL

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data. ...

  8. 剑指offer 二叉搜索树后续遍历序列 判断

    最后一个元素是 根节点. 左子树的元素都小于根节点,右子树都大于根节点 然后递归判断 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ...

  9. zf-关于业务量统计柱形图(上月份的没显示出来的解决办法)

    首先要想到是存储过程里面除了问题,导致没有显示出来 因为本年度和本季度 是能显示出来的 所以后台代码是没问题的 存储过程里 有个tj_type  这个tj_type有3个值 1 代表本年度 2 代表本 ...

  10. 把自己的电脑做服务器发布tomcat的项目外网访问

    1.首先你要确定你有一个外网ip地址.如果你分配到的是一个局域网IP地址需要经过一系列的转换为外网ip地址,然后继续下面操作. 2.拿到外网IP地址,进行tomcat的server.xml文件的配置. ...