参考 https://blog.csdn.net/dyllove98/article/details/41120789

1,去官网下载最新的包

官网地址:http://nginx.org/download/

也可以直接 wget http://nginx.org/download/nginx-1.9.9.tar.gz (我这下载很慢所有直接去官网下,在上传到服务器)

2,下载相关依赖包

  1. [root@localhost src] wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
  2. [root@localhost src] tar zxvf pcre-8.40.tar.gz
  3. [root@localhost src] cd pcre-8.40
  4.  
  5. [root@localhost pcre-8.40]# ./configure && make && make install
  6.  
  7. 下面两个安装步骤和上面的一致
  8. [root@localhost src] wget http://zlib.net/zlib-1.2.11.tar.gz
  9.  
  10. [root@localhost src] wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz

3,解压nginx

  1. tar zxvf nginx-1.9.9.tar.gz
  2.  
  3. cd nginx-1.9.9/
  1. ./configure --prefix=/usr/local/nginx --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module

4,编译nginx

  make && make install

添加一个nginx主程序的符号链接 
ln -sf /usr/local/nginx/sbin/nginx  /usr/sbin

检查配置是否正常

nginx -t

首先把原来的配置文件清空:

  1. > /usr/local/nginx/conf/nginx.conf

“>” 这个符号之前阿铭介绍过,为重定向的意思,单独用它,可以把一个文本文档快速清空。

  1. vim /usr/local/nginx/conf/nginx.conf
  2.  
  3. 写入如下内容:
  1. user nobody nobody;
  2. worker_processes 2;
  3. error_log /usr/local/nginx/logs/nginx_error.log crit;
  4. pid /usr/local/nginx/logs/nginx.pid;
  5. worker_rlimit_nofile 51200;
  6.  
  7. events
  8. {
  9. use epoll;
  10. worker_connections 6000;
  11. }
  12.  
  13. http
  14. {
  15. include mime.types;
  16. default_type application/octet-stream;
  17. server_names_hash_bucket_size 3526;
  18. server_names_hash_max_size 4096;
  19. log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
  20. '$host "$request_uri" $status'
  21. '"$http_referer" "$http_user_agent"';
  22. sendfile on;
  23. tcp_nopush on;
  24. keepalive_timeout 30;
  25. client_header_timeout 3m;
  26. client_body_timeout 3m;
  27. send_timeout 3m;
  28. connection_pool_size 256;
  29. client_header_buffer_size 1k;
  30. large_client_header_buffers 8 4k;
  31. request_pool_size 4k;
  32. output_buffers 4 32k;
  33. postpone_output 1460;
  34. client_max_body_size 10m;
  35. client_body_buffer_size 256k;
  36. client_body_temp_path /usr/local/nginx/client_body_temp;
  37. proxy_temp_path /usr/local/nginx/proxy_temp;
  38. fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
  39. fastcgi_intercept_errors on;
  40. tcp_nodelay on;
  41. gzip on;
  42. gzip_min_length 1k;
  43. gzip_buffers 4 8k;
  44. gzip_comp_level 5;
  45. gzip_http_version 1.1;
  46. gzip_types text/plain application/x-javascript text/css text/htm application/xml;
  47.  
  48. server
  49. {
  50. listen 80;
  51. server_name localhost;
  52. index index.html index.htm index.php;
  53. root /usr/local/nginx/html;
  54.  
  55. location ~ \.php$ {
  56. include fastcgi_params;
  57. fastcgi_pass 127.0.0.19000;
  58. fastcgi_index index.php;
  59. fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
  60. }
  61.  
  62. }
  63.  
  64. }

5,启动nginx

  /usr/local/nginx/sbin/nginx

  在检查下配置

  nginx -t

  查看nginx 是否启动

  ps -ef | grep nginx

6,测试

 php安装参考 : https://www.cnblogs.com/chancy/p/9238149.html

  1. vim /usr/local/nginx/html/index.php
  2.  
  3. 内容如下:
  1. <?php
  2.     echo phpinfo();
  3. ?>

  1.  

liunx安装nginx的更多相关文章

  1. LIUNX 安装 nginx

    安装依赖 yum install gcc yum install pcre-devel yum install zlib zlib-devel yum install openssl openssl- ...

  2. liunx 利用nginx 实现负载均衡

    一般采用软件实现负载均衡的有Nginx.apache.nginx 近年来使用频繁,其官网上面显示可以承载5万并发访问量,太牛了. nginx 相比 apache优势明显:Nginx 服务程序比较稳定, ...

  3. linux系统虚拟机下安装nginx基础

    虽然安装nginx什么的 .以及如何配置等等一系列的资料案例已经很多了 但是作为菜鸟的我还是搞了半天哈 官网上面也有.但是一些细节方面的并没有说明.导致踩了半天坑才搞好 本案例的系统环境     wi ...

  4. (转)AIX7.1安装Nginx 1.13的方法

    原文:https://blog.csdn.net/lvshaorong/article/details/79401860 https://blog.csdn.net/lvshaorong/articl ...

  5. Liunx之nginx配置

    一.nginx安装 卸载yum安装的ngjnx yum remove nginx -y 编译安装nginx步骤 编译安装nginx的步骤 1.解决软件依赖 yum install gcc patch ...

  6. centos直接yum安装nginx

    Ubuntu下安装nginx,直接apt-get install nginx就行了,很方便. 但是今天装了CentOS6.2,直接yum install nginx不行,要先处理下源,下面是安装完整流 ...

  7. 安装Nginx服务

    Nginx最大特点: 静态小文件(1M),支持高并发,同时占用系统资源很少.3W并发,10个进程,内存150M. Nginx特点: 1.配置简单,灵活,轻量. 2.高并发(静态小文件),静态几万的并发 ...

  8. Linux下安装nginx

    一直会使用nginx,也学习了好多nginx知识.也在本地安装过nginx,这次是第一次在正式的环境安装nginx,把这些记录下来总结经验. 一.安装环境 操作系统:CentOS release 6. ...

  9. centos系统编译安装nginx+php环境另加独立mysql教程

    以前看过的安装nginx+php环境都带了mysql数据库了,这个是因为很多站长都是nginx+php+mysql都在同一台服务器了,那么今天我们是单独处理了,一个是nginx+php环境,然后mys ...

随机推荐

  1. 3、原生jdbc链接数据库之锁与事务

    一.锁的概念1.作用:是保证数据的一致性,只能一个人修改数据,不能同时多用户修改2.分类:行级锁和表级锁   乐观锁和悲观锁 二.事务1.为了保证数据的一致性和完整性,让数据库的多项操作合并为一个整体 ...

  2. jenkins使用5----gi服务器搭建连接

    ♦安装git ♦服务器创建git用户 [root@localhost home]# id git id: git:无此用户 [root@localhost home]# useradd git [ro ...

  3. centos7 搭建openvpn服务器

    OpenVPN是一个开源代码的VPN应用程序,可让您在公共互联网上安全地创建和加入专用网络.相比pptp,openvpn更稳定.安全. 本篇博客主要介绍下面两点: 1. Centos 7下安装与配置O ...

  4. 摒弃FORM表单上传图片,异步批量上传照片

    之前作图像处理一直在用form表单做图片数据传输, 个人感觉low到爆炸而且用户体验极差,现在介绍一个一部批量上传图片的小技巧,忘帮助他人的同时也警醒自己在代码的编写时不要只顾着方便,也要考虑代码的健 ...

  5. IDEA+控制台使用搜索\查找功能

  6. Linux VNC安装

    cat /etc/centos-release CentOS Linux release 7.4.1708 (Core) uname -r 3.10.0-693.el7.x86_64 VNC下载:ht ...

  7. js 原生ajax实现

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  8. 从零开始搭建django前后端分离项目 系列二(项目搭建)

    在开始项目之前,假设你已了解以下知识:webpack配置.vue.js.django.这里不会教你webpack的基本配置.热更新是什么,也不会告诉你如何开始一个django项目,有需求的请百度,相关 ...

  9. Python学到什么程度才可以去找工作?掌握这4点足够了!

    大家在学习Python的时候,有人会问"Python要学到什么程度才能出去找工作",对于在Python培训机构学习Python的同学来说这都不是问题,因为按照Python课程大纲来 ...

  10. 【原创】自己动手写一个能操作redis的客户端

    引言 redis大家在项目中经常会使用到.官网也提供了多语言的客户端供大家操作redis,如下图所示 但是,大家有思考过,这些语言操作redis背后的原理么?其实,某些大神会说 只要按照redis的协 ...