nginx for ubuntu

1.创建文件夹 :mkdir nginx

2.解压nginx: tar zxvf nginx.gz.tar

3.nginx 初始化:在nginx的路径下执行:./configure  

有可能会报错:

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

解决办法:yum -y install pcre-devel ,如果报

执行 sudo apt install yum 还是报错,查找资料后发现在ubuntu中要用apt-get 的方法安装PCRE 依赖包

  sudo apt-get install openssl libssl-dev

  sudo apt-get install libpcre3 libpcre3-dev

sudo make 命令进行编译

sudo make install 安装nginx软件

这是默认安装到user文件夹下 

4.nginx的启动与关闭

1.找到默认nginx的安装文件夹 usr/local/sbin 是nginx脚本所在的位置

  nginx -h :查看nginx所有相关命令  nginx 的操作时通过发送信号给进程进行操作

nginx -q  测试配置时只显示错误

nginx -s  SINGLE(信号类型)  向主机进程发送信号   :nginx -s quit 关闭nginx  nginx -s reload 启动nginx

nginx -p :设置nginx服务器路径前缀

nginx -t :检查nginx服务器配置文件是否有语法错误

nginx -c :指定nginx的配置文件

原文地址:https://www.cnblogs.com/blogxiao/p/9887582.html