1. 下载解压
  • 官网地址:  nginx: download
  • 下载稳定版中的,Linux版本
  • centos7安装nginx_nginx

  • 解压缩
    tar -zxvf nginx-1.22.1.tar.gz
  1. 安装依赖
    yum install -y openssl* & yum -y install ncurses-devel
  2. 打开解压缩的nginx目录,配置编译
    cd /nginx-1.22.1
    ./configure
    make
    make install
    ./configure配置的过程中会输出的信息,里面包含配置文件启动文件等信息
nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  1. 检查nginx 默认安装路径,如下图安装在 /usr/local/nginx 路径下
    whereis nginx
  2. centos7安装nginx_nginx_02

  3. cd /usr/local/nginx 这里面可以配置和启动 ngxin
    配置文件位于:config/nginx.conf
    启动: sbin/nginx
  4. 建立开机启动文件
    vi /etc/systemd/system/nginxd.service
[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
PrivateTmp=true

[Install]
WantedBy=multi-user.target
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  1. 加入开机启动
    systemctl enable nginxd