Nginx 安装

系统平台:CentOS 7.4 64位。

一,安装编译工具及文件

yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

 

二,安装PCRE

可以使Nginx支持Rewrite功能

1.安装

[root@localhost ]  # cd /usr/local/src/
[root@localhost src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

2,解压安装包

@localhost src]# tar zxvf pcre-8.35.tar.gz

3,进入安装目录

[root@localhost src]# cd pcre-8.35

4,编译安装

[root@localhost pcre-8.35]# ./configure
[root@localhost pcre-8.35]# make && make install

5,查看pcre版本

[root@localhost pcre-8.35]# pcre-config --version

三,安装Nginx

1,安装  

wget http://nginx.org/download/nginx-1.15.5.tar.gz -P /usr/src

2,解压

[root@localhost src]# tar xf nginx-1.15..tar.gz

3,编译安装到指定目录

[root@localhost src]# cd nginx-1.15.
[root@localhost nginx-1.15.]# ./configure --prefix=/usr/local/src/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
[root@localhost nginx-1.15.]# make
[root@localhost nginx-1.15.]# make install

4,查看版本

[root@localhost nginx-1.15.]# /usr/local/src/nginx/sbin/nginx -v

安装完成

5,检查配置文件

[root@localhost nginx-1.15.]# /usr/local/src/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/src/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/src/nginx/conf/nginx.conf test is successful

四,启动Nginx

[root@localhost nginx-1.15.]# /usr/local/src/nginx/sbin/nginx

五,Nginx常用命令

/nginx/sbin/nginx -s reload            # 重新载入配置文件
/nginx/sbin/nginx -s reopen # 重启 Nginx
/nginx/sbin/nginx -s stop # 停止 Nginx

六,Nginx配置文件

worker_processes ; #设置值和CPU核心数一致
error_log /usr/local/webserver/nginx/logs/nginx_error.log crit; #日志位置和日志级别
pid /usr/local/webserver/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile ;
events
{
use epoll;
worker_connections ;
}
http
{
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for'; #charset gb2312; server_names_hash_bucket_size ;
client_header_buffer_size 32k;
large_client_header_buffers 32k;
client_max_body_size 8m; sendfile on;
tcp_nopush on;
keepalive_timeout ;
tcp_nodelay on;
fastcgi_connect_timeout ;
fastcgi_send_timeout ;
fastcgi_read_timeout ;
fastcgi_buffer_size 64k;
fastcgi_buffers 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 16k;
gzip_http_version 1.0;
gzip_comp_level ;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on; #limit_zone crawler $binary_remote_addr 10m;
#下面是server虚拟主机的配置
server
{
listen ;#监听端口
server_name localhost;#域名
index index.html index.htm index.php;
root /usr/local/webserver/nginx/html;#站点目录
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
{
expires 30d;
# access_log off;
}
location ~ .*\.(js|css)?$
{
expires 15d;
# access_log off;
}
access_log off;
} }

Centos7安装配置Nginx的更多相关文章

  1. virtualBox安装centos7并配置nginx php mysql运行环境

    virtualBox安装centos7并配置nginx php mysql运行环境 一:virtualBox安装centos7并进行基础设置 1.下载dvd.iso安装文件,下载地址:https:// ...

  2. Centos7安装配置gitlab

    Centos7安装配置gitlab 这篇文字我会介绍在Centos7上安装gitlab,配置gitlab的smtp,并且创建项目demo. sudo yum install openssh-serve ...

  3. ELK 6安装配置 nginx日志收集 kabana汉化

    #ELK 6安装配置 nginx日志收集 kabana汉化 #环境 centos 7.4 ,ELK 6 ,单节点 #服务端 Logstash 收集,过滤 Elasticsearch 存储,索引日志 K ...

  4. (转)windows 下安装配置 Nginx 详解

    windows 下安装配置 Nginx 详解 本文转自https://blog.csdn.net/kingscoming/article/details/79042874 nginx功能之一可以启动一 ...

  5. Centos7安装配置Apache+PHP+Mysql+phpmyadmin

    转载自: Centos7安装配置Apache+PHP+Mysql+phpmyadmin 一.安装Apache yum install httpd 安装成功后,Apache操作命令: systemctl ...

  6. Centos7安装配置JDK8

    Centos7安装配置JDK8 一.准备工作 第一步,去甲骨文官网下载Jdk相应的版本,我这里下载的是jdk1.8. 第二步将你从官网上下载下来的jdk使用FTP工具上传到云服务器上的相应目录,我的是 ...

  7. centos7命令行和图形界面的相互切换(附centos7安装配置教程)

    一.最近安装了centos7,发现在命令行和图形界面的相互切换命令上,与centos以往版本有很大不同,先整理如下,加深记忆. 1,centos7默认安装后,跟其他版本一样,启动默认进入图形界面: 2 ...

  8. (转)Centos7安装配置NFS服务和挂载

    Centos7安装配置NFS服务和挂载 原文:https://www.u22e.com/601.html NFS简介 NFS(Network File System)即网络文件系统,是FreeBSD支 ...

  9. CentOS7 安装配置笔记

    CentOS7 安装配置笔记 1.通过镜像安装 CentOS7 ==============================* 使用 UltraISO 9.7 或者 rufus-3.5p 制作ISO的 ...

随机推荐

  1. WinServer配置MySQL主从同步

    为什么要配置主从同步? 如果一台数据库服务器挂了,还有一个备用 为了方便配置,我采用两台WinServer2003虚拟机: 1.前期准备工作:安装好镜像文件,VMTOOLS,MySQL5.5 我这里以 ...

  2. 初始hibernate 和环境搭建

    hibernate是一个开源的数据持久化框架. hibernate的优点: hibernate进行操作数据库提高了代码的开发速度,大大降低了代码量,降低了维护成本. hibernate支持许多面向对象 ...

  3. SQL Server常用函数使用方法(学习)

    1.转载至 https://www.cnblogs.com/Brambling/p/6779434.html Substring()函数,用于截取字符串方法,三个参数 参数1:用于指定要操作的字符串 ...

  4. Docker 删除&清理镜像

    文章首发自个人网站:https://www.exception.site/docker/docker-delete-image 本文中,您将学习 Docker 如何删除及清理镜像? 一.通过标签删除镜 ...

  5. 【Netty】(7)---搭建websocket服务器

    [Netty](7)---搭建websocket服务器 说明:本篇博客是基于学习某网有关视频教学. 目的:创建一个websocket服务器,获取客户端传来的数据,同时向客户端发送数据 一.服务端 1. ...

  6. ConfirmCancelDialog【确认取消对话框】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 对确认取消对话框的封装. 前提:调用对话框的Activity必须继承FragmentActivity及其子类(比如AppCompat ...

  7. 使用阿里云的图片识别成表格ocr(将图片表格转换成excel)

    为了简便财务总是要对照着别人发来的表格图片制作成自己的表格 图片识别 识别成表格 表格识别 ocr 使用阿里云api 购买(印刷文字识别-表格识别) https://market.aliyun.com ...

  8. 浅析Servlet执行原理

    在JavaWeb学习研究中,Servlet扮演重要的作用,学好它,是后续JavaWeb学习的良好基础.无论是SSH,还是SSM,微服务JavaWeb技术,都应先学好Servlet,从而达到事半功倍的效 ...

  9. SpringBoot系列——Spring-Data-JPA(究极进化版) 自动生成单表基础增、删、改、查接口

    前言 我们在之前的实现了springboot与data-jpa的增.删.改.查简单使用(请戳:SpringBoot系列——Spring-Data-JPA),并实现了升级版(请戳:SpringBoot系 ...

  10. python的小技巧 让你的代码更美观

    持续更新.. 1,活用lambda表达式 匿名函数 lambda 可以提供很多便利.下面是举例. dic = {1:lambda a,b : a+b} 2,代码一行化. 当逻辑语句后只有一行代码的时候 ...