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. Linux常用命令速查-汇总篇

    Linux常用命令速查-用户管理 Linux常用命令速查-文件管理 Linux常用命令速查-系统监控 Linux常用命令速查-网络管理 Linux常用命令速查-定时任务 Linux常用命令速查-Vim

  2. Pytorch实战1:线性回归(Linear Regresion)

    GitHub代码练习地址:https://github.com/Neo-ML/MachineLearningPractice/blob/master/Pytorch01_LinearRegressio ...

  3. oracle 常用索引分析,使用原则和注意事项

    本文参考: https://www.cnblogs.com/wishyouhappy/p/3681771.html https://blog.csdn.net/weivi001/article/det ...

  4. python基础-函数(9)

    一.函数的介绍 如果在开发程序时,需要某块代码多次,但是为了提高编写的效率以及代码的重用,所以把具有独立功能的代码块组织为一个小模块,这就是函数 函数的语法格式: def 函数名(): 函数的功能代码 ...

  5. 《深入理解Java虚拟机》-----第6章 类文件结构——Java高级开发必须懂的

    代码编译的结果从本地机器码转变为字节码,是存储格式发展的一小步,却是编程语言发展的一大步. 6.1 概述 记得在第一节计算机程序课上我的老师就讲过:“计算机只认识0和1,所以我们写的程序需要经编译器翻 ...

  6. 【Android Studio安装部署系列】十九、Android studio使用SVN

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 概述 在AndroidStudio中开发版本控制,除了Git就是SVN,和Eclipse不同,Android Studio没有提供单独的插 ...

  7. 在github上搭建一个静态的个人网站

    说一下大概步骤 1.创建一个新仓库 仓库名必须是你的用户名+github.io后缀 例:用户名:tom 仓库名就要是:tom.github.io (这里具体步骤可以自己百度一下) 2.创建好仓库我们该 ...

  8. Kubernetes知识小普及

    大部分概念Kubernetes官网都有详细介绍,Kubernetes中文官网 https://kubernetes.io/zh/docs/tutorials/kubernetes-basics/ 官网 ...

  9. 使用 线性规划 解决 数字 排序问题, +Leapms模型

    问题 将如下一组数字从大到小排序. {10, 20, -32, 177, 0, -11.5, 19, 7, 6.2, -6.28, -2.71, 44} 解决办法 建立数学模型,给出各个数字的次序值. ...

  10. 内核mailbox

    只罗列增加取走消息: static int add_to_rbuf(struct mbox_chan *chan, void *mssg) { int idx; unsigned long flags ...