Linux下nginx安装配置

下载 官网源码包
  wget http://nginx.org/download/nginx-1.15.5.tar.gz -P /usr/src

进入对应文件
  cd /usr/src

解压
  tar xf nginx-1.15.5.tar.gz

进入文件夹
  cd nginx-1.15.5

安装依赖库
  yum -y install gcc pcre-devel zlib-devel

配置
  ./configure --prefix=/usr/local/nginx // 安装路径


编译
  make

安装
  make install

启动服务
  /usr/local/nginx/sbin/nginx

测试
  lsof -i :80 // 看服务是否起来
  yum install elinks // 安装无界面浏览器
  elinks http:ip -dump

killall -9 nginx // 杀死nginx进程


  netstat -ntpl (查看已起来的服务) 80端口是否被占用

删除源码包
  rm -rf nginx-1.15.5


相关文件
  /usr/local/nginx // 安装路径
  /usr/local/nginx/sbin/nginx // 启动文件
  /usr/local/nginx/modules // 自身所用模块
  /usr/local/nginx/conf // 配置文件目录
  /usr/local/nginx/conf/nginx.conf // 配置文件
  /usr/local/nginx/logs/nginx.pid // 进程号文件
  /usr/local/nginx/logs/error.log // 错误日志
  /usr/local/nginx/logs/access.log // 访问日志


卸载nginx

rm -rf /etc/nginx/
  rm -rf /usr/sbin/nginx
  rm /usr/share/man/man1/nginx.1.gz
  apt-get remove nginx*

Nginx发布网站
vim /usr/local/nginx/conf/nginx.conf


server {
listen 80;
server_name localhost;
#access_log logs/abc.log main;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9090;
uwsgi_param UWSGI_SCRIPT baism_web.wsgi; # baism_web:项目名称
uwsgi_param UWSGI_CHDIR /usr/local/nginx/html/baism_web; # baism_web:项目名称。将项目复制到/usr/local/nginx/html/路径下
index index.html index.htm;
client_max_body_size 35m;
#uwsgi_cache_valid 1m;
#uwsgi_temp_file_write_size 64k;
#uwsgi_busy_buffers_size 64k;
#uwsgi_buffers 8 64k;
#uwsgi_buffer_size 64k;
#uwsgi_read_timeout 300;
#uwsgi_send_timeout 300;
#uwsgi_connect_timeout 300;
}
}