Nginx WEB 安装
来源:互联网 发布:迅龙数据恢复下载安装 编辑:程序博客网 时间:2024/06/06 08:26
首先要安装pcre库
yum -y install pcre-devel pcre
下载源码包
http://nginx.org/download/nginx-1.4.2.tar.gz
解压源码包
tar -xzvf nginx-1.4.2.tar.gz
进入Nginx的目录修改其版本
cd nginx-1.4.2 ; sed -i -e ‘s/1.4.2//g’ -e ‘s/nginx\//WS/g’ -e
‘s/”NGINX”/”WS”/g’ src/core/nginx.h
./configure 出错
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using –with-openssl= option.
解决
yum install openssl openssl-devel -y
make &&make install
编译完成
/usr/local/nginx/sbin/nginx -t 检查 nginx 配置文件是否正
确,返回 OK 即正确。
[root@localhost nginx-1.4.2]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
启动Nginx
/usr/local/nginx/sbin/nginx
浏览器输入IP地址 出现Nginx的欢迎页面,表示源码编译Nginx成功。
Nginx配置虚拟主机
进入要配置的目录
cd /usr/local/nginx/conf
添加网站信息
vim nginx.conf
server { listen 80; server_name www.a.com; location / { root html/a; index index.html index.htm; } } server { listen 80; server_name www.b.com; location / { root html/b; index index.html index.htm; } }
,有些网站,你得需要用户和密码才能访问的,那么这样的网址需要怎么配置呢,其实也很简单,
第一步
在nginx.conf配置文件里添加相关配置如下
server { listen 80; server_name www.b.com; location / { root html/b; index index.html index.htm; auth_basic "oldboy tranning"; auth_basic_user_file /usr/local/nginx/conf/htpasswd; } }
在当前网站的目录下执行
yum -y install httpd
which htpasswd
htpasswd -bc /usr/local/nginx/conf/htpasswd oldboy 123456
chmod 400 /usr/local/nginx/conf/htpasswd
chown nginx /usr/local/nginx/conf/htpasswd
若是有报错
[root@www html]# /etc/init.d/nginx -s reload
nginx: [error] invalid PID number “” in “/usr/local/nginx/logs/nginx.pid”
解决办法是:/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
- Nginx WEB 安装
- nginx web容器 安装与配置
- Openwrt web服务器:PHP+Nginx安装
- Nginx的安装实现web功能
- nginx编译安装 及 配置WEB服务
- 源码安装nginx——web服务器
- nginx高性能web服务器详解(1)--安装nginx
- nginx(二) nginx编译安装 及 配置WEB服务
- web自动安装脚本(apache/nginx+php+mysql)
- Ubuntu 11.04 安装nginx+php5+mysql 的web服务器
- ubuntu 下安装nginx 及web服务配置
- ubuntu 12.04 安装 nginx+php+mysql web服务器
- Ubuntu下Nginx的安装及WEB服务配置
- Ubuntu 11.04 安装nginx+php5+mysql 的web服务器
- ubuntu 12.04 安装 nginx+php+mysql web服务器
- ubuntu 12.04 安装 nginx+php+mysql web服务器
- ubuntu 12.04 安装 nginx+php+mysql web服务器
- ubuntu 12.04 安装 nginx+php+mysql web服务器
- 最小费用最大流模版
- 用python爬取百科糗事的小项目
- Lua 数学库
- codeforces 2016-2017 NTUWFTSC J Zero Game
- Hibernate中对象的三种状态及相互转化
- Nginx WEB 安装
- Intellij IDEA 快捷键整理
- jvm-2-gc
- MAVEN的安装和Myeclipse+maven的配置和使用
- 【es6】函数
- 类加载器
- Banner
- ftp上传文件显示553错误,以及linux服务器文件修改777权限
- 安装teamviewer 远程桌面