部署Nginx
1#下载nginx
wget http://nginx.org/download/nginx-1.12.2.tar.gz
#安装依赖
yum install pcre-devel openssl-devel -y
#编译安装三部曲 : ./configure make make install
#解压
tar xf nginx-1.12.2.tar.gz
#进入
cd nginx-1.12.2
#查看路径
pwd #应该是在这个路径下/application/nginx-1.12.2
#安装
./configure --prefix=/application/nginx-1.12.2 --with-http_stub_status_module --with-http_ssl_module
#查看上次命令结果是否正确
# echo $?
make #根据一些配置进行编译
make install
故障1:
error: the HTTP rewrite module requires the PCRE library.
yum install pcre-devel -y
[root@oldboyedu-s8 nginx-1.12.2]# ll /application/nginx-1.12.2/
total 4
drwxr-xr-x. 2 root root 4096 Apr 26 15:55 conf #configure nginx配置文件
drwxr-xr-x. 2 root root 40 Apr 26 15:55 html #站点目录 网站根目录
drwxr-xr-x. 2 root root 6 Apr 26 15:55 logs #日志
drwxr-xr-x. 2 root root 19 Apr 26 15:55 sbin #nginx管理命令
#检查语法
/application/nginx-1.12.2/sbin/nginx -t
#启动nginx
/application/nginx-1.12.2/sbin/nginx -s reload
#nginx配置说明
nginx.conf #nginx配置文件
nginx.conf.default #
#对比两个文件区别
diff conf/nginx.conf conf/nginx.conf.default
#将
egrep -v "#|^$" /application/nginx-1.12.2/conf/nginx.conf.default >/application/nginx-1.12.2/conf/nginx.conf
1 worker_processes 1;
2 events {
3 worker_connections 1024;
4 }
5 http {
6 include mime.types; #媒体类型
7 default_type application/octet-stream;
8 sendfile on; #开启高效的传输模式
9 keepalive_timeout 65; #超时时间
10 server { #一个server相当于是一个网站 虚拟主机
11 listen 80; #监听的端口
12 server_name www.etiantian.org; #网站名字 域名
13 location / {
14 root html; #根 站点的根目录
15 index index.html index.htm; #首页文件
16 }
21 }
22 }