centos上普通用户安装nginx过程

落爺英雄遲暮 提交于 2020-01-13 14:10:47

[dongzw@localhost nginx-1.4.7]$ ./configure --prefix=/home/dongzw/nginx
checking for OS
 + Linux 2.6.32-754.el6.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found

root用户安装:
yum -y install gcc gcc-c++ autoconf automake make

./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.

root用户安装:
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using builtin md5 code
  + sha1 library is not found
  + using system zlib library

  nginx path prefix: "/home/dongzw/nginx"
  nginx binary file: "/home/dongzw/nginx/sbin/nginx"
  nginx configuration prefix: "/home/dongzw/nginx/conf"
  nginx configuration file: "/home/dongzw/nginx/conf/nginx.conf"
  nginx pid file: "/home/dongzw/nginx/logs/nginx.pid"
  nginx error log file: "/home/dongzw/nginx/logs/error.log"
  nginx http access log file: "/home/dongzw/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"
 

[dongzw@localhost nginx-1.4.7]$ make
[dongzw@localhost nginx-1.4.7]$ echo $?
0
[dongzw@localhost nginx-1.4.7]$ make install

[dongzw@localhost nginx]$ sbin/nginx -V
nginx version: nginx/1.4.7
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)
configure arguments: --prefix=/home/dongzw/nginx
[dongzw@localhost nginx]$ ./sbin/nginx -c conf/nginx.conf
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

原因:Linux只有root用户可以使用1024一下的端口
解决办法:把 nginx.conf 配置文件中的监听端口改为1024以上
server {
   listen 8088
……
}

停止:
[dongzw@localhost ~]$ nginx/sbin/nginx -s stop
 

 

如果遇到:pcre_byte_order.c:317: fatal error: opening dependency file .deps/libpcre_la-pcre_byte_order.Tpo: Permission denied
可以使用root执行./configure  、make 、 make install 完成后修改权限,再用普通用户启动。

[fdfs@localhost nginx-1.17.7]$ ./configure --prefix=.....
make[2]: Entering directory `/fdfs/soft/pcre-8.35'
  CC       libpcre_la-pcre_byte_order.lo
pcre_byte_order.c:317: fatal error: opening dependency file .deps/libpcre_la-pcre_byte_order.Tpo: Permission denied
compilation terminated.
make[2]: *** [libpcre_la-pcre_byte_order.lo] Error 1
make[2]: Leaving directory `/fdfs/soft/pcre-8.35'
make[1]: *** [/fdfs/soft/pcre-8.35/.libs/libpcre.a] Error 2
make[1]: Leaving directory `/fdfs/soft/nginx-1.17.7'
make: *** [build] Error 2

[root@localhost fdfs]# chown fdfs:fdfs -R nginx
[root@localhost nginx]# chmod u+s sbin/nginx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!