yesn 发表于 2018-11-13 13:28:20

Linux WEB服务器搭建-Nginx篇

  nginx使用的三个方面
  1.轻量级的web服务器
  2.反向代理或负载均衡
  3.缓存服务器
  nginx使用epoll模型,apache使用传统的select模型,所以nginx在处理静态小文件时能够处理的并发数更多。
  源代码安装。
  检查系统是否有安装pcre(让nginx支持http的rewrite模块),pcre-devel openssl------》基础依赖包
  openssl-devel 使用https时用到
  安装过程
  cd /tuwei/tools/
  wget http://nginx.org/download/nginx-1.6.3.tar.gz------》下载nginx
  tar xf nginx-1.6.3.tar.gz
  cd nginx-1.6.3
  useradd nginx -s /sbin/nologin-M ----------->创建nginx服务用户
  ./configure --user=nginx --group=nginx --prefix=/application/nginx-1.6.3/ \
  --with-http_stub_status_module --with-http_ssl_module
  make&&make install
  安装完后创建软连接,方便后续使用
  ln -s /application/nginx-1.6.3/   /application/nginx
  启动nginx服务前检查语法,养成好习惯。
  /application/nginx/sbin/nginx -t
  出现如下信息
  # /application/nginx/sbin/nginx -t
  nginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is ok
  nginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful
  如果提示相关相关模块不存在,将模块路径放到模块配置文件中
  cat /etc/ld.so.conf
  执行ldconfig 使配置修改生效
  启动nginx服务
  /application/nginx/sbin/nginx
  检查服务是否启动

[*]ps -ef |grep nginx  2.netstat -tnlp|grep 80
  3.wget 127.0.0.1
  4.curl -I 127.0.0.1
  检查nginx启动效果,浏览器访问
  如果无法访问
  1.关闭selinux
  2.关闭防火墙,在生产环境中,如有外网IP,请允许80端口访问
  iptables -I INPUT -p tcp --dport 80 -j ACCEPT
  客户端访问网站异常排查的三部曲
  1.客户端 ping IP------》物理线路

[*]telnet IP 80-------》服务端防火墙  3.服务端 wget IP或者curl -I IP    ------》模拟用户访问,排除http服务自身问题,根据输出再排除
  4.服务端查看服务错误日志
  403错误
  1.没有首页文件
  2.首页文件权限不够
  kill HUP cat nginx.pid相当于重启nginx服务

  创建简单站点
  自己创建index.html
  放到/application/nginx/html目录然后进行访问,nginx默认站点文件为index.html。

页: [1]
查看完整版本: Linux WEB服务器搭建-Nginx篇