Linux安装Nginx

前言:老规矩,linux安装软件的目录都是data目录

 

1.进入data目录,创建nginx目录并进入该目录

cd /data
mkdir nginx
cd nginx

 

2.yum 在线安装一些基础环境

 yum install pcre
 yum install pcre-devel
 yum install zlib
 yum install zlib-devel
 yum install openssl
 yum install openssl-devel

 

3.上传 "nginx-1.15.5.tar.gz" 文件  到当前目录(/data/nginx)

  "nginx-1.15.5.tar.gz" 文件路径:https://shaun.lanzoum.com/ix5GD0u5u9oj

 

4.解压文件,进入目录

tar -zvxf nginx-1.15.5.tar.gz
cd nginx-1.15.5

 

5.配置检查

./configure --user=nginx  --group=nginx --prefix=/usr/local/nginx --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy --http-fastcgi-temp-path=/var/temp/nginx/fastcgi --http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/temp/nginx/scgi --add-module=/data/fastdfs-nginx-module/fastdfs-nginx-module_v1.20/src

 

6.安装

make
make install

 

7.添加用户组

groupadd nginx
useradd nginx -g nginx -s /sbin/nologin -M
chown nginx:nginx /data/fastdfs/logs/mod_fastdfs.log

 

8.修改配置文件

vi /usr/local/nginx/conf/nginx.conf
i

修改:

user nginx nginx;

 

pid   /usr/local/nginx/logs/nginx.pid;

 

#不能都listen 80

server {

            listen       80;

            server_name  192.168.47.131;

            location ~/group([0-9])/M00 {

                #root   html;

                #index  index.html index.htm;

                root /data/fastdfs/data/data;

                ngx_fastdfs_module;

            }

}

 

esc
:wq

 

9.准备启动nginx

mkdir /var/log/nginx
mkdir /var/run/nginx
mkdir /var/temp
mkdir /var/temp/nginx
mkdir /usr/local/nginx/logs
cp objs/nginx /usr/local/nginx/sbin/nginx
y

 

10.启动nginx

/usr/local/nginx/sbin/nginx

 

 

11.检查一下nginx进程

ps -ef | grep nginx

 

posted on 2023-04-28 17:31  shaun88  阅读(341)  评论(0编辑  收藏  举报

导航