Linux系统下Nginx服务器部署
2016-02-04 00:00
639 查看
Nginx安装步骤:
一、相关组件
(1) Nginx本身
下载地址:http://nginx.org/en/download.html;提供的安装包是Nginx-1.9.7版本。
(2) Rewrite模块的正则表达式依赖库pcre
下载地址:http://www.pcre.org;提供的安装包是pcre-8.38版本。
二、安装步骤
(1) 安装pcre
tar -zxvf pcre-8.38.tar.gz
cd pcre-8.38
./configure
make
make install
默认安装到/usr/local/lib下即可;安装完成后可以#ls -l /usr/local/lib/libpcre.so
(2) 安装nginx
tar –zxvf nginx-1.9.7.tar.gz
cd nginx-1.9.7
./configure
make
make install
三、nginx配置
配置文件默认在/usr/local/nginx目录下,主要的配置文件为conf目录下的nginx.conf。
启动程序文件在/usr/sbin/nginx中。
日志在/var/log/nginx中,分别是access.log和error.log。
默认的虚拟主机的目录设置在了/usr/share/nginx/html中。
常见配置如下:
(1) 侦听80端口 (nginx默认监听80端口)
listen 80;
(2) 服务器名称
Server_name localhost;
(3) 默认主页目录在nginx安装目录的html子目录。
root html;
index index.html index.html;
四、管理nginx
(1) 启动
/usr/local/nginx/sbin/nginx (/usr/nginx/sbin/nginx -t 查看配置信息是否正确)
(2) 停止
/usr/local/nginx/sbin/nginx -s stop
(3) 重启
/usr/local/nginx/sbin/nginx -s reload
(4) 查看状态
netstat -autlp| grep nginx
(5) 检查部署正确性
访问http://localhost/,查看是否正常启动。
五、常见问题
(1) 缺少pcre库:./configure: error: the HTTP rewrite module requires the PCRE library.
解决方法:安装pcre。
(2) 缺少openssl:./configure: error: the HTTP cache module requires md5 functions from OpenSSL library.
解决方法:安装openssl-devel。
(3) 缺少gcc-c++和libtool:The program 'libtool' is currently not installed. You can install it by typing:sudo apt-get install libtool
解决方法:安装libtool和gcc-c++。
(4) 缺少zlib:./configure: error: the HTTP gzip module requires the zlib library.
解决方法:安装zlib。
一、相关组件
(1) Nginx本身
下载地址:http://nginx.org/en/download.html;提供的安装包是Nginx-1.9.7版本。
(2) Rewrite模块的正则表达式依赖库pcre
下载地址:http://www.pcre.org;提供的安装包是pcre-8.38版本。
二、安装步骤
(1) 安装pcre
tar -zxvf pcre-8.38.tar.gz
cd pcre-8.38
./configure
make
make install
默认安装到/usr/local/lib下即可;安装完成后可以#ls -l /usr/local/lib/libpcre.so
(2) 安装nginx
tar –zxvf nginx-1.9.7.tar.gz
cd nginx-1.9.7
./configure
make
make install
三、nginx配置
配置文件默认在/usr/local/nginx目录下,主要的配置文件为conf目录下的nginx.conf。
启动程序文件在/usr/sbin/nginx中。
日志在/var/log/nginx中,分别是access.log和error.log。
默认的虚拟主机的目录设置在了/usr/share/nginx/html中。
常见配置如下:
(1) 侦听80端口 (nginx默认监听80端口)
listen 80;
(2) 服务器名称
Server_name localhost;
(3) 默认主页目录在nginx安装目录的html子目录。
root html;
index index.html index.html;
四、管理nginx
(1) 启动
/usr/local/nginx/sbin/nginx (/usr/nginx/sbin/nginx -t 查看配置信息是否正确)
(2) 停止
/usr/local/nginx/sbin/nginx -s stop
(3) 重启
/usr/local/nginx/sbin/nginx -s reload
(4) 查看状态
netstat -autlp| grep nginx
(5) 检查部署正确性
访问http://localhost/,查看是否正常启动。
五、常见问题
(1) 缺少pcre库:./configure: error: the HTTP rewrite module requires the PCRE library.
解决方法:安装pcre。
(2) 缺少openssl:./configure: error: the HTTP cache module requires md5 functions from OpenSSL library.
解决方法:安装openssl-devel。
(3) 缺少gcc-c++和libtool:The program 'libtool' is currently not installed. You can install it by typing:sudo apt-get install libtool
解决方法:安装libtool和gcc-c++。
(4) 缺少zlib:./configure: error: the HTTP gzip module requires the zlib library.
解决方法:安装zlib。
相关文章推荐
- Linux socket 初步
- Linux Kernel 4.0 RC5 发布!
- nginx代理指定目录
- linux lsof详解
- linux 文件权限
- Linux 执行数学运算
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 访问Nginx发生SSL connection error的一种情况
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- Ubuntu Linux使用体验
- c语言实现hashmap(转载)
- Linux 信号signal处理机制
- linux下mysql添加用户