Linux中Nginx安装教程
一、安装编译工具及库文件
[root@test src]# yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
二、首先要安装 PCRE
PCRE 作用是让 Nginx 支持 Rewrite 功能。
1、下载 PCRE 安装包,下载地址: http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
[root@test src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
2、解压安装包
[root@test src]# tar zxvf pcre-8.35.tar.gz
3、进入安装包目录
[root@test src]# cd pcre-8.35
4、编译安装
[root@test pcre-8.35]# ./configure
[root@test pcre-8.35]# make && make install
5、查看pcre版本
[root@test pcre-8.35]# pcre-config --version
安装 Nginx:
1、下载 Nginx,下载地址:http://nginx.org/download/nginx-1.6.2.tar.gz
[root@test src]# wget http://nginx.org/download/nginx-1.6.2.tar.gz
2、解压安装包
[root@test src]# tar zxvf nginx-1.6.2.tar.gz
3、进入安装包目录
[root@test src]# cd nginx-1.6.2
4、编译安装
[root@test nginx-1.6.2]# ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
[root@test nginx-1.6.2]# make
[root@test nginx-1.6.2]# make install
5、查看nginx版本
[root@test nginx-1.6.2]# /usr/local/webserver/nginx/sbin/nginx -v
到此,nginx安装完成。
Nginx 配置:
1、创建 Nginx 运行使用的用户 www:
[root@test conf]# /usr/sbin/groupadd www
[root@test conf]# /usr/sbin/useradd -g www www
2、配置nginx.conf ,将/usr/local/webserver/nginx/conf/nginx.conf替换为以下内容
[root@test conf]# cat /usr/local/webserver/nginx/conf/nginx.conf user www www;
worker_processes 2; #设置值和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 65535;
events
{
use epoll;
worker_connections 65535;
}
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 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m; sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on; #limit_zone crawler $binary_remote_addr 10m;
#下面是server虚拟主机的配置
server
{
listen 80;#监听端口
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:9000;
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;
} }
3、检查配置文件ngnix.conf的正确性命令
[root@test conf]# /usr/local/webserver/nginx/sbin/nginx -t
启动 Nginx:
[root@test conf]# /usr/local/webserver/nginx/sbin/nginx
至此,Nginx就安装成功了!
Nginx 其他命令:
以下包含了 Nginx 常用的几个命令:
/usr/local/webserver/nginx/sbin/nginx -s reload # 重新载入配置文件
/usr/local/webserver/nginx/sbin/nginx -s reopen # 重启 Nginx
/usr/local/webserver/nginx/sbin/nginx -s stop # 停止 Nginx
Linux几个常用命令:
以下包含了 linux常用的几个命令:
1.查看文件内容:
cat 文件名
2.编辑文件内容:
1. vi 文件名
2. 点击 i 键后进行编辑
3. 编辑完成后,点击ESC键 :wq Enter键保存并退出
3.删除文件:
rm -rf 文件名
4.下载文件:
wget 文件链接
5.解压文件:
unzip 压缩包文件名 -d 解压文件名
或者:
tar zxvf 压缩包名
6.移动文件(夹) 或者 重命名文件(夹):
例子:将目录A重命名为B mv A B 例子:将/a目录移动到/b下,并重命名为c mv /a /b/c
7.显示文件或目录:
ls
8.创建目录:
mkdir 目录名
9.创建空文件:
touch 文件名
Linux中Nginx安装教程的更多相关文章
- Linux中Nginx安装与配置详解
转载自:http://www.linuxidc.com/Linux/2016-08/134110.htm Linux中Nginx安装与配置详解(CentOS-6.5:nginx-1.5.0). 1 N ...
- linux中Nginx安装
linux中Nginx安装 编译安装 Nginx的优点太多,这里不再赘述,详情请看这篇博客深入理解nginx. Nginx的安装有rpm包安装.编译安装和docker安装.本文将介绍编译安装方 ...
- linux中RabbitMQ安装教程
linux中RabbitMQ安装教程 在做一个微服务项目时候用到消息队列,于是深入了解了消息队列知识,并在linux上安装了Rabbitmq,本博客介绍Rabbitmq的安装教程,想要深入了解消息队列 ...
- Linux中Nginx安装部署
前言 Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器. Nginx 是由 Igor Sys ...
- Linux中JDK安装教程
JDK在官网下载,也可以从某个文件服务器进行下载. 1.在usr目录创建一个java文件夹: mkdir java 2.进入刚创建的java文件夹,下载jdk: cd /usr/java 例如: wg ...
- Linux中Nginx安装与配置详解 test(待整理 补全)
http://www.linuxidc.com/Linux/2016-08/134110.htm http://www.cnblogs.com/freeweb/p/5425554.html http: ...
- linux环境中,nginx安装过程
需求描述: 记录在linux平台,nginx安装的过程. 环境描述: 操作系统:Red Hat Enterprise Linux Server release 6.6 (Santiago) 操作内核版 ...
- linux中nginx、mysql安装碰到的问题
服务器到期新买了一台服务器,记录一下重新安装基本环境碰到了一些问题 安装nginx 1. 启动失败 403 forbidden nginx 解决方案:(个人使用直接用了root账号,修改对应nginx ...
- 转:xdebug在linux下的安装教程
原文:xdebug在linux下的安装教程 [注意,本人是PHP7.1.7 Nginx ,第7步没有做,但是xdebug.so就已经在PHP的扩展文件夹里面了.目录是phpinfo的extension ...
随机推荐
- 使用密钥登录CentOS系统(基于密钥的认证)
在Window客户端有多种软件可以登陆ssh,比如putty,xshelll,secureCRT,我就以xshell为例设置使用公钥和私钥验证登陆服务器. 使用Xshell密钥认证机制远程登录Linu ...
- 本文讲述下windows下使用rsync备份数据
本文讲述下windows下使用rsync备份数据 需要使用的软件如下: 环境需求: 上海monitor上跑有定时任务计划备份线上数据库,现在需要把上海monitor上的备份数据拉回到179.12数据回 ...
- problem: 记一次聊天框的表情包弹框不显示的找问题过程
左边是列表,包含了群和成员,右侧是聊天窗口.点击群列表,右侧显示群聊窗口,点击学员,右侧显示私聊窗口. 群聊窗口和私聊窗口是不同的组件,但是窗口中的子组件,例如窗口的头部.中间内容部分.输入框都是复用 ...
- js无间隙向上滚动
一.优点:div可以load:缺点:滚动的时候有点娘,磨磨唧唧,不够干脆爽快 html <div id="my_msg" class="my-msg bg-whit ...
- Python抓取百度汉字笔画的gif
偶然发现百度汉语里面,有一笔一划的汉字顺序: 觉得这个动态的图片,等以后娃长大了,可以用这个教写字.然后就去找找常用汉字,现代汉语常用字表 .拿到这里面的汉字,做两个数组出来,一共是 ...
- Butterknife--Android Butterknife使用方法总结(转)
原文链接:http://blog.csdn.net/donkor_/article/details/77879630 前言: ButterKnife是一个专注于Android系统的View注入框架,以 ...
- 记录2-在mac上安装ubuntu 16.04 LTS
前几天升级了我用了六七年mac硬件,内存由4G变为8G,硬盘也换成1T SSD,索性把一直想装的ubuntu也装了,方便温习下以前的工作环境. 我比较喜欢LTS的版本,所以安装了16.04. 主要步骤 ...
- Windows下虚拟机安装Mac OS X —– VMware Workstation12安装Mac OS X 10.11
1下载 镜像:Instal OS X Yosemite 10.10.3(14D131).cdr 密码:qhhm 2 unlocker208文件(链接:https://pan.baidu ...
- ef err
InvalidCastException: The field of type jcz.DomainModels.Sex must be a string, array or ICollection ...
- EF core2.1+MySQL报错'Void Microsoft.EntityFrameworkCore.Storage.Internal.RelationalParameterBuilder..ctor(Microsoft.EntityFrameworkCore.Storage.IRelationalTypeMapper)
一.使用.net core 2.0 EF mysql 运行一直报错如下: An unhandled exception occurred while processing the request. M ...