linux非root用户启动nginx,linux非root用户安装nginx

02cb44d3c550292400e743e9b3b5ce41.png

下完后通过rz上传至wlf用户soft目录下,退回上一级目录解压:

$ cd soft

$ rz-y

rz waitingtoreceive.

开始 zmodem 传输。 按 Ctrl+C 取消。100% 1008 KB 1008 KB/s 00:00:01 0Errors

$ cd ..

$ tar xzvf soft/nginx-1.16.1.tar.gz

在开始nginx检查前,我们还需要装两个依赖:pcre和zlib。

同上面流程,分别到ftp://ftp.pcre.org/pub/pcre/和http://www.zlib.net/下载pcre-8.43.zip(注意别下pcre2)和zlib-1.2.11.zip:

767e0ced1a3e88e01f82763ef70980cd.png

5ee9ccd650f771167c71dba624c32caf.png

退出当前soft目录,分别解压安装:

$ cd ..

$ unzip soft/pcre-8.43

$ cd pcre-8.43$ ./configure --prefix=/home/wlf/pcre

$ make&& make install

$ cd ..

$ unzip soft/zlib-1.2.11$ cd zlib-1.2.11$ ./configure --prefix=/home/wlf/zlib

$ make&& make install

两个依赖都装好后,可以开始正式的nginx编译前检查:

$ cd nginx-1.16.1/$ ./configure --prefix=/home/wlf/nginx --with-http_stub_status_module --with-pcre=/home/wlf/pcre-8.43 --with-zlib=/home/wlf/zlib-1.2.11

其中参数http_stub_status_module是开启stub_status模块,它主要用于查看Nginx的一些状态信息。后面两个用来指定两个依赖的源码目录。检查结果:

Configuration summary+ using PCRE library: /home/mgwh/pcre-8.43

+ OpenSSL library is notused+ using zlib library: /home/mgwh/zlib-1.2.11nginx path prefix:"/home/mgwh/nginx"nginx binary file:"/home/mgwh/nginx/sbin/nginx"nginx modules path:"/home/mgwh/nginx/modules"nginx configuration prefix:"/home/mgwh/nginx/conf"nginx configuration file:"/home/mgwh/nginx/conf/nginx.conf"nginx pid file:"/home/mgwh/nginx/logs/nginx.pid"nginxerror log file: "/home/mgwh/nginx/logs/error.log"nginx http accesslog file: "/home/mgwh/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"

检查ok,编译和安装一般没问题:

$ make && make install

启动nginx:

$ cd ~

$ cd nginx

$ sbin/nginx

nginx: [emerg] bind()to 0.0.0.0:80 failed (13: Permission denied)

报错原因:在linux下,普通用户只能用1024以上的端口,而1024以内的端口只能由root用户才可以使用,所以这里80端口只能由root才能使用。

我们通过vi修改下配置文件conf/nginx.conf,将端口改成8787:

#gzip on;

server {

listen8787;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location/{

root html;

index index.html index.htm;

}

重新启动后发现nginx已经起好了:

$ netstat -nlp | grep 8787(Not all processes could be identified, non-owned process info

willnot be shown, you would have to be root tosee it all.)

tcp0 0 0.0.0.0:8787 0.0.0.0:* LISTEN 29950/nginx: master

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值