部署Nginx

时间:2023-02-01 05:28:22

部署Nginx

#下载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..tar.gz
#进入
cd nginx-1.12.2
#查看路径
pwd #应该是在这个路径下/application/nginx-1.12.2
#安装
./configure --prefix=/application/nginx-1.12. --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.]# ll /application/nginx-1.12./
total
drwxr-xr-x. root root Apr : conf #configure nginx配置文件
drwxr-xr-x. root root Apr : html #站点目录 网站根目录
drwxr-xr-x. root root Apr : logs #日志
drwxr-xr-x. root root Apr : sbin #nginx管理命令 #检查语法
/application/nginx-1.12./sbin/nginx -t #启动nginx
/application/nginx-1.12./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./conf/nginx.conf.default >/application/nginx-1.12./conf/nginx.conf worker_processes ;
events {
worker_connections ;
}
http {
include mime.types; #媒体类型
default_type application/octet-stream;
sendfile on; #开启高效的传输模式
keepalive_timeout ; #超时时间
server { #一个server相当于是一个网站 虚拟主机
listen ; #监听的端口
server_name www.etiantian.org; #网站名字 域名
location / {
root html; #根 站点的根目录
index index.html index.htm; #首页文件
}
}
}