从源代码编译应用程序时通常有三个步骤:配置,编译和安装。 配置步骤允许您选择一些在程序编译后无法编辑的选项,因为它对程序二进制文件有直接影响。 因此,这是一个非常重要的阶段,你需要仔细选择,如果你想避免后面的麻烦,如缺乏一个特定的模块或配置文件位于一个随机文件夹等。
如果由于某种原因,您不想使安装这么麻烦(例如用于测试目的或仅仅因为您以后会重新编译程序),则可以直接使用不带参数的configure命令。 执行以下三个命令来编译和安装Nginx的工作版本,从configure命令开始:
[alex@example.com nginx-1.8.0]# ./configure
运行此命令需要比较长的时间来进行验证过程,以确保您的系统包含所有必需的组件。 如果配置过程失败,请再次检查安装依赖部分,因为它是错误的最常见原因。 有关命令失败原因的信息,您还可以参考objs/autoconf.err文件,其中提供了更详细的报告。 make命令将编译应用程序。 只要配置正确,此步骤不应出现任何错误。
[alex@example.com nginx-1.8.0]# make [root@example.com nginx-1.8.0]# make install
这最后一步将编译文件以及其他资源复制到安装目录,默认是/usr/local/nginx。
依赖以库和二进制文件的形式出现。 现在,它们应该已经全部安装在您的系统上了。 但是,即使它们存在于您的系统上,也有可能出现配置脚本无法找到它们的情况。 原因可能有所不同,例如,如果它们安装在非标准目录中。
为了解决这些问题,您可以使用以下选项来指定依赖的路径(其他依赖相关选项已组合在一起):
在编译程序之前,需要指定要安装的模块。 有些是默认启用的,有些需要手动启用,如下表所示。
以下参数允许您禁用默认情况下启用的模块:
–without-http_charset_module
–without-http_gzip_module
–without-http_ssi_module
–without-http_userid_module
–without-http_access_module
–without-http_access_module
–without-http_autoindex_module
–without-http_geo_module
–without-http_map_module
–without-http_referer_module
–without-http_rewrite_module
–without-http_proxy_module
–without-http_fastcgi_module
–without-http_uwsgi_module
–without-http_scgi_module
–without-http_memcached_module
–without-http_limit_conn_module
–without-http_limit_req_module
–without-http_empty_gif_module
–without-http_browser_module
–without-http_upstream_ip_hash_module
–without-http_upstream_least_conn_module
–without-http_split_clients_module
以下参数允许您启用默认禁用的模块:
–with-http_ssl_module
–with-http_realip_module
–with-http_addition_module
–with-http_xslt_module
–with-http_image_filter_module
–with-http_geoip_module
–with-http_sub_module
–with-http_dav_module
–with-http_flv_module
–with-http_mp4_module
–with-http_gzip_static_module
–with-http_random_index_module
–with-http_secure_link_module
–with-http_stub_status_module
–with-google_perftools_module
–with-http_degradation_module
–with-http_perl_module
–with-http_spdy_module
–with-http_gunzip_module
–with-http_auth_request_module