1.到nginx官网下载源码包。最好下载稳定版本,nginx官网http://www.nginx.org/
2.安装nginx依赖包运行命令:
sudo apt-get install libssl-dev
sudo apt-get install libpcre3 libpcre3-dev
3.解压下载的nginx源码包。检查编译环境 ./configure --prefix=/usr/local/nginx
4.编译安装 make && make install
5.到nginx安装目录执行启动命令:/usr/local/nginx/sbin/nginx
关闭命令:/usr/local/sbin/nginx -s stop (停止)
重启命令:/usr/local/sbin/nginx -s reload (重启)
启动之后浏览器中http://localhost/查看是否成功。
6.nginx配置文件所在目录/usr/local/nginx/conf/nginx.conf
配置文件详解如下:
#运行用户
#user nobody;
#启动进程
worker_processes 1;
#全局错误日志及PID文件
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
#工作模式及连接数上限
events {
use epoll;
worker_connections 1024;
}
#设定http服务器,利用它的反向代理功能提供负载均衡支持
http {
#设定mime类型
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"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
#客户端和nginx之间空闲链接超时时间
keepalive_timeout 120;
#设定负载均衡的服务器列表
upstream mysvr {
#weigth参数表示权值,权值越高被分配到的几率越大
#本机上的Squid开启3128端口
server 127.0.0.1:8080 weight=1;
#server 119.254.82.237:8080 weight=1;
}
#是否开启gzip模块
#gzip on;
#gzip_min_length 1100;
#gzip_buffers 4 8k;
#gzip_types text/plain;
#设定虚拟主机
server {
listen 80;
server_name localhost;
#charset koi8-r;
#设定本虚拟主机的访问日志
#access_log logs/host.access.log main;
#location / {
# root html;
# index index.html index.htm;
# }
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
#对 "/" 启用负载均衡
location / {
proxy_pass http://mysvr;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#客户端body中最大数据量
client_max_body_size 10m;
client_body_buffer_size 128k;
# 链接到主机超时时间
proxy_connect_timeout 90;
# 向主机发送数据超时时间
proxy_send_timeout 90;
# 从主机读取数据超时时间
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
分享到:
相关推荐
haproxy配置详解,含ACL部分。 HAProxy提供高可用性、负载均衡以及基于TCP和HTTP应用的代理,支持虚拟主机,它是免费、快速并且可靠的一种解决方案。根据官方数据,其最高极限支持10G的并发。 HAProxy特别适用于...
如果你安装了 Apache ,并且此时 Apache 在运行,那么请先修改一下配置文件(没有的同学直接跳过): #打开配置文件 sudo vim /etc/nginx/sites-available/default 然后按以下两处修改(为了不和 Apache 冲突...
* 所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经安排在了/etc/nginx/sites-available下 www.jb51.net *程序文件在/usr/sbin/nginx * 日志放在了/var/log/nginx中 *并已经在/etc/init.d/下创建了启动...
传统的web项目,一般都将静态资源存放在 webroot的目录下...进入nginx安装目录的conf目录下,修改nginx.conf文件,在一个server{}中添加 一个location 部分配置代码如下 root@ubuntu:/usr/local/nginx/conf# vi nginx
三:在 ubuntu server 14 安装流程 1.先下载安装 nginx 和 nginx-rtmp 编译依赖工具 sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev 2. 创建一个工作目录,并切换到工作目录 mkdir ~/...
这篇教程说明你应该怎样配置 nginx、设置 HTTP ...我想你需要一个正常工作的 nginx 软件,就像这篇教程里展示的:在Ubuntu 16.04 LTS 上安装 Nginx,PHP 7 和 MySQL 5.7 (LEMP) 。 2 配置 nginx 可以参考 expires 指令
ppa安装php-fpm安装工具包复制代码 代码如下:$ sudo ...get install php5-fpm其它必要的软件安装接复制代码 代码如下:sudo apt-get install nginx配置php-fpmphp-fpm的解析器是C/S结构,它的配置文件位于:(1)/et
不使用在协议中易受攻击的SSLv3以及以下版本并且我们会设置一个更强的密码套件为了在可能的情况下能够实现Forward Secrecy,同时我们还启用HSTS和HPKP。这样我们就有了一个更强、不过时的SSL配置并且我们在Qually ...
在自学游戏开发的路上,最有成就感的时刻就是将自己的小游戏做出来分享给朋友试玩,原生的游戏开可以打包分享,小游戏上线流程又长...nginx:nginx/1.4.6 (Ubuntu) WinSCP:5.15.3 步骤详解: 1.下载、配置 nginx 开始
服务器系统:ubuntu16.04LTS 服务器IP地址:47.89.12.99 域名:bjubi.com 二,域名解析到服务器 在阿里云控制台-产品与服务-云解析DNS-找到需要解析的域名点“解析”,进入解析页面后选择【添加解析】按钮会弹出如下...
抵不住朋友的诱惑,今天终于入手了一台阿里云服务器,是Ubuntu 1.4 32位版本,最初考虑是用来尝尝鲜只是买了个最低配的,价格算起来与在国外买个空间的价格相当吧(可能一年才贵100多),但用起来感觉就很不错,速度...
最近在ubuntu上捣腾nginx,安装成功了,就只有rewrite没有试验,因为服务器上有多个网站,还不敢在服务器上尝试,慢慢来。网上查了一些文章,下了一篇留下来做试验。 nginx上虚拟主机的配置其实跟apache上的基本上...
服务器上的Nginx和PHP都是源码编译安装的,不像ubuntu一样有自带service启动脚本,所以不支持类似以前的nginx (start|restart|stop|reload)了。自己动手丰衣足食。以下脚本应该在RHEL, Fedora, CentOS下都适用。 一...
3 Odoo 的安装和配置 9 3.1 PostgreSQL 数据库 10 3.2 Ubuntu14.04 下可能缺失的软件包 11 3.3 网页显示 node.js 方面 11 3.4 其他问题 12 3.5 通过命令行运行时的配置 12 3.5.1 –xmlrpc-port=8888 12 3.5.2 –...
本文介绍了docker 手动构建新镜像的方法,分享给大家,具体如下: 查看本地现有镜像: ...nginx latest c59f17fe53b0 4 days ago 108MB ubuntu latest 747cb2d60bbe 3 weeks ago 122MB centos latest 196e0ce0c9