一、准备工作
安装nginx前先安装 pcre pcre-devle openssl openssl-devel
二、安装nginx
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx1.18 --with-http_stub_status_module --with-http_ssl_module
Make
Make install
三、检查启动
/usr/local/nginx/Sbin/Nginx -t 检查语法
/usr/local/nginx/Sbin/Nginx 启动nginx
sudo fuser -n tcp 80 –k 解除80端口占用
四、配置
根目录 root
站点目录 html
/usr/local/nginx/conf/fastcgi.conf 动态配置文件
/usr/local/nginx/conf/nginx.conf 静态配置文件
配置nginx.conf
每个server 一个站点
Server{
Listen 80;
Server_name localhost; 域名
Location / {
Root html ;
Index index.html index.html; 首页文件
}
Error_page 500 502 503 504 /50x.html;遇到500 等错误,跳的50x.html
Location = /50x.html {
Root html;
}
}