在raspberry Pi上编译安装Nginx服务器

本文介绍了Nginx 1.2.2版本的编译安装过程及注意事项,包括如何设置文件路径、选择事件处理模块、启用SSL支持等。并记录了一次实际编译过程中遇到的问题及其原因。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考地址:

Nginx 1.2.2 stable 源码下载地址

http://wiki.nginx.org/Install#Stable

编译安装注意事项:

http://wiki.nginx.org/InstallOptions


Installation and compile-time options

The build is configured using the configure command. It defines various aspects of the system, including the methods nginx is allowed to use for connection processing. At the end it creates a Makefile.

The configure command supports the following parameters:

Files and permissions

--prefix=path - defines a directory that will keep server files. This same directory will also be used for all relative paths set by configure (except for paths to libraries sources) and in the nginx.conf configuration file. It is set to the /usr/local/nginx directory by default.

--sbin-path=path - sets the name of an nginx executable file. This name is used only during installation. By default the file is named prefix/sbin/nginx.

--conf-path=path — sets the name of an nginx.conf configuration file. If needs be, nginx can always be started with a different configuration file, by specifying it in the command-line parameter -c file. By default the file is named prefix/conf/nginx.conf.

--pid-path=path — sets the name of an nginx.pid file that will store the process ID of the main process. After installation, the file name can always be changed in the nginx.conf configuration file using the pid directive. By default the file is named prefix/logs/nginx.pid.

--error-log-path=path — sets the name of the primary error, warnings, and diagnostic file. After installation, the file name can always be changed in the nginx.conf configuration file using the error_log directive. By default the file is named prefix/logs/error.log.

--http-log-path=path — sets the name of the primary request log file of the HTTP server. After installation, the file name can always be changed in the nginx.conf configuration file using the access_log directive. By default the file is named prefix/logs/access.log.

--user=name — sets the name of an unprivileged user whose credentials will be used by worker processes. After installation, the name can always be changed in the nginx.conf configuration file using the user directive. The default user name is nobody.

--group=name — sets the name of a group whose credentials will be used by worker processes. After installation, the name can always be changed in the nginx.conf configuration file using the user directive. By default, a group name is set to the name of an unprivileged user.

Event loop

--with-select_module
--without-select_module
— enables or disables building a module that allows the server to work with the select() method. This module is built automatically if the platform does not appear to support more appropriate methods such as kqueue, epoll, rtsig, or /dev/poll.--with-poll_module
--without-poll_module
— enables or disables building a module that allows the server to work with the poll() method. This module is built automatically if the platform does not appear to support more appropriate methods such as kqueue, epoll, rtsig, or /dev/poll.

Optional modules

--without-http_gzip_module — disables building a module that compresses responses of an HTTP server. The zlib library is required to build and run this module.

--without-http_rewrite_module — disables building a module that allows an HTTP server to redirect requests and change URI of requests. The PCRE library is required to build and run this module. The module is experimental — its directives may change in the future.

--without-http_proxy_module — disables building an HTTP server proxying module.

--with-http_ssl_module — enables building a module that adds the HTTPS protocol support to an HTTP server. This module is not built by default. The OpenSSL library is required to build and run this module.

--with-pcre=path — sets the path to the sources of the PCRE library. The library distribution (version 4.4 — 8.21) needs to be downloaded from the PCRE site and extracted. The rest is done by nginx's ./configure and make. The library is required for regular expressions support in the location directive and for the ngx_http_rewrite_module module. See notes below for using system PCRE on FreeBSD systems.

--with-pcre-jit — builds the PCRE library with "just-in-time compilation" support.

--with-zlib=path — sets the path to the sources of the zlib library. The library distribution (version 1.1.3 — 1.2.5) needs to be downloaded from the zlib site and extracted. The rest is done by nginx's ./configure and make. The library is required for the ngx_http_gzip_module module.

Compilation controls

--with-cc-opt=parameters — sets additional parameters that will be added to the CFLAGS variable.

--with-ld-opt=parameters — sets additional parameters that will be used during linking.

Example

Example of parameters usage (all of this needs to be typed in one line):

   ./configure
       --sbin-path=/usr/local/nginx/nginx
       --conf-path=/usr/local/nginx/nginx.conf
       --pid-path=/usr/local/nginx/nginx.pid
       --with-http_ssl_module
       --with-pcre=../pcre-4.4
       --with-zlib=../zlib-1.1.3

Notes

When using the system PCRE library under FreeBSD, the following options should be specified:

   --with-ld-opt="-L /usr/local/lib" \
   --with-cc-opt="-I /usr/local/include"


If the number of files supported by select() needs to be increased it can also be specified like this:

   --with-cc-opt="-D FD_SETSIZE=2048"

References

Official documentation








PCRE库下载地址

http://www.pcre.org/

zlib下载地址

http://nginx.org/download/nginx-1.2.2.tar.gz


以上两个下载完后进行编译。编译完成后,填入:

   ./configure
       --sbin-path=/usr/local/nginx/nginx
       --conf-path=/usr/local/nginx/nginx.conf
       --pid-path=/usr/local/nginx/nginx.pid
       --with-http_ssl_module
       --with-pcre=../pcre-4.4
       --with-zlib=../zlib-1.1.3

本人自己的raspberry pi上的版本是


./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=../pcre-8.21 --with-zlib=../zlib-1.2.5 --with-openssl=/usr/bin/openssl

pcre库(8.21)与zlib库(1.2.5)都是下载的源码,并没有编译,这些编译工作,都交给Nginx(1.2.2)自己编译了。

Raspberry 装的是raspbian 2012-12-16-wheezy-raspbian.zip.torrent

PCRE是做网页静态化处理用的,zlib有助于网页传输的时候压缩处理打包,有助于提高访问速度。

./configure 

完成后的输出:

Configuration summary
  + using PCRE library: ../pcre-8.21
  + using OpenSSL library: /usr/bin/openssl
  + md5: using OpenSSL library
  + sha1: using OpenSSL library
  + using zlib library: ../zlib-1.2.5

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/nginx"
  nginx configuration prefix: "/usr/local/nginx"
  nginx configuration file: "/usr/local/nginx/nginx.conf"
  nginx pid file: "/usr/local/nginx/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"

 ./make

pi@raspberrypi ~/Downloads/nginx-1.2.2 $ sudo make
make -f objs/Makefile
make[1]: Entering directory `/home/pi/Downloads/nginx-1.2.2'
cd /usr/bin/openssl \
	&& make clean \
	&& ./config --prefix=/usr/bin/openssl/.openssl no-shared  no-threads \
	&& make \
	&& make install LIBDIR=lib
/bin/sh: 1: cd: can't cd to /usr/bin/openssl
make[1]: *** [/usr/bin/openssl/.openssl/include/openssl/ssl.h] Error 2
make[1]: Leaving directory `/home/pi/Downloads/nginx-1.2.2'
make: *** [build] Error 2
pi@raspberrypi ~/Downloads/nginx-1.2.2 $ whereis openssl
openssl: /usr/bin/openssl /usr/bin/X11/openssl /usr/share/man/man1/openssl.1ssl.gz

没有能编译成功。原因是openssl出现问题。

以后继续。困了。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值