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 ...
随机推荐
- Optaplanner终于支持多线程并行运行 - Multithreaded incremental solving
Optaplanner 7.9.0.Final之前,启动引擎开始对一个Problem进行规划的时候,只能是单线程进行的.也就是说,当引擎对每一个possible solution进行分数计算的过程中, ...
- 京东饭粒捡漏V1.0.8
20180617 更新 V1.0.81.捡漏策略更新:自动检测商品,有货后自动下单:2.加车自动使用最优满减券组合: 功能介绍1.京东商城专用,支持饭粒模式下单,自己获得京豆返利 2.捡漏模式:帮助用 ...
- WAMP中mysql服务突然无法启动 解决方法
wamp的mysql服务前两天还能用,今天突然不能无法启动了,原因可能是近期电脑强行关机,删除wamp\bin\mysql\mysql5.6.17\data目录下的ib_logfile0和ib_log ...
- Linux中的configure,make,make install到底在做些什么
在Linux下经常要安装部署一些软件包或者工具,拿到安装包之后一看,简单,configure,make, make install即可搞定. 有时候我就在想,这个configure,make ,mak ...
- 7.2 if else 语句
7.2 if else 语句 if else语句的通用形式是: if ( expression ) statement1 else statement2 如果expression为真(非0),则执行s ...
- nginx+uwsgi配置
nginx #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; ...
- Neject 在MVC框架中使用
Neject 开始是用3.3.0.0,不能自动生成NinjectWebCommon文件,测试了很久发现,是版本的问题 ,后来用Nuget卸载后,重新下了Ninject,Ninject.Web.Comm ...
- linux 怎么与网络对时
首先来了解下面几个知识点:1. date命令:#date显示系统时间2.hwclock命令 (即hardwareclock系统硬件时间)#hwclock显示硬件时间#hwclock -w将系统时间写入 ...
- Dao层抽取BaseDao公共方法
设计IBseDao接口,定义公共的CRUD方法. // IBaseDao 接口,定义公共的CRUD方法 public interface IBaseDao<T> { public void ...
- 关于No qualifying bean of type [XXX.XXX] found for dependency 的一次记录
异常开始于spring+springmvc+mybatis 注解配置,启动tomcat服务器出现No qualifying bean of type [com.***.service] found f ...