nginx source code installation
Release: 2016-07-30 13:30:38
Original
1199 people have browsed it
nginx can be installed using the default packages of each platform. This article introduces the use of source code compilation and installation, including specific compilation parameter information. Before the official start, the compilation environment gcc g++ development library and the like need to be installed in advance. By default, you have already installed it. Ububtu platform compilation environment can use the following instructionsapt-get install build-essential
apt-get install libtoolcentos platform compilation environment use the following instructionsInstall make:yum -y install gcc automake autoconf libtool makeInstall g++:yum install gcc gcc-c++The following officially starts
------------ -------------------------------------------------- -------------
Generally we need to install pcre and zlib first, the former for rewrite and the latter for gzip compression.
1. Select the source code directory
It can be any directory. The one selected in this article is /usr/local/src cd /usr/local/src 2. Install the PCRE library
ftp://ftp.csx.cam.ac.uk/pub/software /programming/pcre/ Download the latest PCRE source code package. Use the following command to download, compile and install the PCRE package: cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gz
tar -zxvf pcre-8.34.tar.gz
cd pcre-8.34./configure
make
make install3. Install the zlib library
http://zlib.net/zlib-1.2.8.tar.gz Download the latest zlib source code package, use the following command to download, compile and install the zlib package: cd /usr/local/src
wget http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8./configure
make
make install4. Install ssl (some vps do not have ssl installed by default) cd /usr/local/src
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz5. Install nginx Nginx generally has two versions, namely stable version and development version, you can choose one of these two versions according to your purpose. The following are the detailed steps to install Nginx to the /usr/local/nginx directory: cd /usr/local/src
wget http://nginx.org/download/nginx-1.4.2.tar.gz
tar -zxvf nginx-1.4.2.tar.gz
cd nginx-1.4.2./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=/usr/local/src/pcre-8.34 \
--with-zlib=/usr/local/src/zlib-1.2.8 \
--with-openssl=/usr/local/src/openssl-1.0.1cmake
make install--with-pcre=/usr /src/pcre-8.34 refers to the source code path of pcre-8.34.
--with-zlib=/usr/src/zlib-1.2.7 refers to the source code path of zlib-1.2.7. After successful installation, the /usr/local/nginx directory is as follows fastcgi.conf koi-win nginx.conf.default
fastcgi.conf.default logs scgi_params
fastcgi_params mime.types scgi_params.default
fastcgi_params.default mime.types.default uwsgi_params
html nginx uwsgi_params.default
koi-utf nginx.conf win-utf6. Start
Make sure that port 80 of the system is not occupied by other programs, run the /usr/local/nginx/nginx command to start Nginx, netstat -ano|grep 80If Execute if no results are found. If there are results, ignore this step (ubuntu must be started with sudo, otherwise it can only run in the foreground) sudo /usr/local/nginx/nginxOpen the browser to access the IP of this machine. If the browser displays Welcome to nginx!, it means Nginx has been installed and running successfully. ------------------------------------------------ --------
The nginx installation is complete here. If you only process static html, you don’t need to continue the installation. If you need to process php scripts, you also need to install php-fpm. Installation troubleshooting belowAttachment: possible errors and some help information1.1 compile pcre errorlibtool: compile: unrecognized option `-DHAVE_CONFIG_H'
libtool: compile: Try `libtool --help' for more information.
make[1]: *** [pcrecpp.lo] Error 1
make[1]: Leaving directory `/usr/local/src/pcre-8.34'
make:***[all]Error2Solution: install g++, don’t forget to reconfigureapt-get install g++
apt-get install build-essential
make clean
./configure
make1.2 make errormake: *** No rule to make target `build', needed by `default'. Stop.
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl= option. Follow the installation method in step 4 or
apt-get install openssl
apt-get install libssl-dev under ubuntucentosyum -y install openssl openssl-devel2.nginx compilation optionmake is used to compile. It reads instructions from the Makefile and then compiles. make install is used for installation. It also reads instructions from the Makefile and installs it to the specified location. The configure command is used to detect the target characteristics of your installation platform. It defines all aspects of the system, including the connection processing methods that nginx is allowed to use. For example, it will detect whether you have CC or GCC. It does not require CC or GCC. It is a shell script. When execution ends, it will Create a Makefile. nginx’s configure command supports the following parameters:
--prefix=<code><em>path</em>
定义一个目录,存放服务器上的文件 ,也就是nginx的安装目录。默认使用 /usr/local/nginx。
--sbin-path=<code><em>path</em>
设置nginx的可执行文件的路径,默认为 <code><em>prefix</em>
/sbin/nginx.
--conf-path=<code><em>path</em>
设置在nginx.conf配置文件的路径。nginx允许使用不同的配置文件启动,通过命令行中的-c选项。默认为<code><em>prefix</em>
/conf/nginx.conf.
--pid-path=<code><em>path</em> 设置nginx.pid文件,将存储的主进程的进程号。安装完成后,可以随时改变的文件名 , 在nginx.conf配置文件中使用 PID指令。默认情况下,文件名 为
<code><em>prefix</em>
/logs/nginx.pid.
--error-log-path=<code><em>path</em>
设置主错误,警告,和诊断文件的名称。安装完成后,可以随时改变的文件名 ,在nginx.conf配置文件中 使用 的error_log指令。默认情况下,文件名 为<code><em>prefix</em>
/logs/error.log.
--http-log-path=<code><em>path</em>
设置主请求的HTTP服务器的日志文件的名称。安装完成后,可以随时改变的文件名 ,在nginx.conf配置文件中 使用 的access_log指令。默认情况下,文件名 为<code><em>prefix</em>
/logs/access.log.
--user=<code><em>name</em>
设置nginx工作进程的用户。安装完成后,可以随时更改的名称在nginx.conf配置文件中 使用的 user指令。默认的用户名是nobody。
--group=<code><em>name</em>
设置nginx工作进程的用户组。安装完成后,可以随时更改的名称在nginx.conf配置文件中 使用的 user指令。默认的为非特权用户。
--with-select_module
--without-select_module 启用或禁用构建一个模块来允许服务器使用select()方法。该模块将自动建立,如果平台不支持的kqueue,epoll,rtsig或/dev/poll。
--with-poll_module
--without-poll_module
启用或禁用构建一个模块来允许服务器使用poll()方法。该模块将自动建立,如果平台不支持的kqueue,epoll,rtsig或/dev/poll。
--without-http_gzip_module
— 不编译压缩的HTTP服务器的响应模块。编译并运行此模块需要zlib库。
--without-http_rewrite_module
不编译重写模块。编译并运行此模块需要PCRE库支持。
--without-http_proxy_module
— 不编译http_proxy模块。
--with-http_ssl_module
— 使用https协议模块。默认情况下,该模块没有被构建。建立并运行此模块的OpenSSL库是必需的。
--with-pcre=<code><em>path</em>
— 设置PCRE库的源码路径。PCRE库的源码(版本4.4 - 8.30)需要从PCRE网站下载并解压。其余的工作是Nginx的./ configure和make来完成。正则表达式使用在location指令和 ngx_http_rewrite_module
模块中。
--with-pcre-jit
—编译PCRE包含“just-in-time compilation”(1.1.12中, pcre_jit指令)。
--with-zlib=<code><em>path</em>
—设置的zlib库的源码路径。要下载从 zlib(版本1.1.3 - 1.2.5)的并解压。其余的工作是Nginx的./ configure和make完成。ngx_http_gzip_module模块需要使用zlib 。
--with-cc-opt=<code><em>parameters</em>
— 设置额外的参数将被添加到CFLAGS变量。例如,当你在FreeBSD上使用PCRE库时需要使用:--with-cc-opt="-I /usr/local/include。
.如需要需要增加 select()支持的文件数量
:--with-cc-opt="-D
FD_SETSIZE=2048".
--with-ld-opt=<code><em>parameters</em>
—设置附加的参数,将用于在链接期间。例如,当在FreeBSD下使用该系统的PCRE库,应指定:--with-ld-opt="-L /usr/local/lib".
典型实例(下面为了展示需要写在多行,执行时内容需要在同一行)./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
以上就介绍了nginx源码安装,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31