centos7安装nginx

发布时间 2023-12-24 11:52:50作者: PHP123net

首先安装nginx所需要的第三方库和编译工具

# yum install -y gcc gcc-c++ autoconf automake make

# yum install zlib zlib-devel openssl openssl-devel pcre pcre-devel wget httpd-tools vim -y

nginx官网:https://nginx.org/

进入download页面下载稳定版本Stable version:

下载源码包

# wget https://nginx.org/download/nginx-1.24.0.tar.gz

解压

# tar -xzvf  nginx-1.24.0.tar.gz

进入解压后的文件夹

# cd nginx-1.24

编译安装

# ./configure --prefix=/usr/local/nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-threads \
--with-file-aio

 

# make && make install

出现如下信息提示就说明安装成功

Configuration summary
+ using threads
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library

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"

  建立软连接,可以通过软链接到/usr/local/sbin/ 目录下

# ln -s /usr/local/nginx/sbin/nginx  /usr/local/sbin

首次直接输入nginx,表示启动该进程
# nginx

查看nginx版本信息

# nginx -v

 

查看nginx起否启动

# ps -ef | grep nginx

root       3195      1  0 11:27 ?        00:00:00 nginx: master process nginx
nobody     3236   3195  0 11:30 ?        00:00:00 nginx: worker process
root       3239   3176  0 11:30 pts/3    00:00:00 grep --color=auto nginxt 

提示表明已经启动成功