How to Install and Configure Nginx from Source on centos--转
1.CentOS - Installing Nginx from source
http://articles.slicehost.com/2009/2/2/centos-installing-nginx-from-source
Versions
At the time of writing, the latest stable version of Nginx is 0.6.34. You can check the latest versions and change logs at the main nginx site.
Building from source will allow you to have the latest available versions of Nginx. However, keep in mind that security updates will not be applied automatically.
Please see this article if you want to install Nginx with the package manager which ensures that any dependencies as well as security updates are installed as needed.
Dependencies
As we are not using the package manager to install nginx, we need to take care of some dependencies.
Not many are needed and include pcre-devel zlib-devel and openssl-devel packages.
sudo yum install pcre-devel zlib-devel openssl-devel
Download
Now we can download the source code.
Create a 'sources' directory (you can download it anywhere you want to):
mkdir ~/sources
Now move into the folder:
cd ~/sources/
And then download the source code:
wget http://sysoev.ru/nginx/nginx-0.6.34.tar.gz
Unpack
Unpack the downloaded tar file and move into the newly created directory:
tar -zxvf nginx-0.6.34.tar.gz
...
cd nginx-0.6.34/
Options
There are quite a few compile time options that are available to use.
Have a look at the Install Options page of the Nginx wiki for full details.
We're going to use just two options to customize the install. The first of which is:
--sbin-path=/usr/local/sbin
By default, nginx will be installed in /usr/local/nginx which, although a good place, does mean the main Nginx binary will be found in /usr/local/nginx/sbin/nginx.
Not a location we are likely to find in our default search paths. So instead of adding new directories to our path (which may cause errors later on) we simply define where to put the binary.
The second option is:
--with-http_ssl_module
Probably self explanatory, but this will enable the SSL module to be compiled so we can parse https requests.
Compile
Let's go ahead and compile Nginx using those two options:
./configure --sbin-path=/usr/local/sbin --with-http_ssl_module
There will be a nice summary at the end of the compile which includes such items as:
...
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/sbin"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
...
Keep a note of the output as it does contain some useful paths and locations for various files.
Make
Ok, let's go ahead and 'make' and then 'make install':
make
...
sudo make install
Defaults
Done. We can test the install by starting Nginx:
sudo /usr/local/sbin/nginx
and navigating to our Slice IP address (assuming you have no other server running):
http://123.45.67.890
You will be greeted with the standard welcome page:

Stop
If you have used Apache or some other web server (or even installing Nginx via a package manager), you may be used to using a script to start and stop it such as you might find in '/etc/init.d/'.
Unfortunately, compiling from source does not create a script like that (we will create an init script in the next article or two).
You may have noticed that one of the paths noted in the compile summary was:
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
Let's make use of that to stop Nginx:
sudo kill `cat /usr/local/nginx/logs/nginx.pid`
That will use the output of the pid file to kill the Nginx process - note the use of backticks (`) and not single quotes (') in the command.
Summary
Although quite detailed, we have installed the latest stable version of Nginx from source and compiled it with some custom options to make life slightly easier.
We also know how to start and stop Nginx by hand.
As mentioned, the next couple of articles will deal with learning how to create an init script so we have more control over Nginx.
Once done, we will then look at configuring Nginx, setting up vhosts and proxying to a backend (such as a cluster of mongrels).
2. How to Install and Configure Nginx from Source on Linux
http://www.thegeekstuff.com/2011/07/install-nginx-from-source/
Before we understand what is nginx, we should know how to pronounce nginx.
Its not N G I N X. nginx is pronounced as “Engine X”.
nginx is short form after you remove both the e’s from “Engine X”.
nginx is an open source web server that is similar to Apache, but very light weight. nginx is both web server and reverse proxy server.
The following are some of the features of nginx:
- It serves static and index files
- Reverse proxy with caching
- Supports SSL
- Simple load balancing with fault tolerance
- Both name-based and ip-based virtual server can be configured
- HTTP basic authentication
- Supports rewrite module
- Supports gzip, XSLT, SSI and image resizing filters
- All the main mail proxy server features are supported
- and lot more..
This is part of an ongoing series of articles on nginx.
Let us get started by installing nginx and get it up and running, which takes only 5 minutes.
1. Download nginx
Download nginx from here, or use wget as shown below. The current stable version is nginx 1.0.5
cd
wget http://nginx.org/download/nginx-1.0.5.tar.gz
tar xvfz nginx-1.0.5.tar.gz
cd nginx-1.0.5
2. Install nginx
There are lot of options that you can pass to ./configure. To identify list of all the configuration options do the following.
./configure --help
The following are some of the http modules that are automatically enabled. If you need to disable them, yo should pass “–without-http_[module_name]” to the ./configure option. For example, to disable “proxy_module”, you should do ./configure –without-http_proxy_module.
- charset_module – HTTP Character set module
- gzip_module – HTTP gzip module for compression
- ssi_module – Server side include modules
- auth_basic_module – HTTP Basic authentication modules.
- autoindex_module – Auto index
- rewrite_module – HTTP rewrite that supports rewrite rules
- proxy_module – HTTP reverse proxy module
- fastcgi_module – Support for fastcgi
- memcached_module – Memcached module for nginx
- ..
Following are some of the httpd modules that are not automatically enabled. If you need to enable them, you should pass “–with-http_[module_name]” to the ./configure option. For example, to enable SSL in nginx, you should do “./configure –with-http_ssl_module”.
- ssl_module – Support for Secure Socket Layer (SSL) module
- xslt_module – Support for Extensible Stylesheet Language Transformations (XSLT) module
- perl_module – Support for Perl
- ..
To begin with, install nginx with the default configuration options by doing ./configure as shown below.
./configure
make
make install
During ./configure, you might get the “./configure: error: the HTTP rewrite module requires the PCRE library.” error message about missing PCRE library that is required by nginx http rewrite module.
To solve the problem, either install “pcre” and “pcre-devel” packages on your Linux, or disable the rewrite module by doing “./configure –without-http_rewrite_module”
nginx will be installed under /usr/local/nginx as shown by the ./configure output.
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ md5: using system crypto library
+ sha1: using system crypto library
+ using system zlib library nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/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"
3. Change the Default nginx Listen Port
Nginx is configured to listen by default on port 80. If you are installing this on a machine for testing purpose, that already has an apache server running, you should change the nginx listen port.
Similar to apache’s httpd.conf file, nginx has nginx.conf file located under /usr/local/nginx/conf.
In the server section of nginx.conf, change the port 80 to 8081.
# vi /usr/local/nginx/conf/nginx.conf
server {
listen 8081;
server_name localhost;
4. Start Nginx Server
nginx executable is located under /usr/local/nginx/sbin directory. Just call this executable to start the nginx server.
cd /usr/local/nginx/sbin
./nginx
Once you start this, you’ll see the nginx “master process” and “worker process” if you do ps.
# ps -ef | grep -i nginx
root 18596 13:16 nginx: master process ./nginx
nobody 18597 13:16 nginx: worker process
After you start the nginx server, go to http://your-ip-address/ (or http://your-ip-address:8081, if you changed the listen directive in nginx.conf), you should see the default nginx index.html, which should say “Welcome to nginx!”
5. Stop Nginx Server
To stop the nginx server, do the following.
cd /usr/local/nginx/sbin
./nginx -s stop
To view the current version of nginx, do the following:
# ./nginx -v
nginx: nginx version: nginx/1.0.5
To debug issues, view the error.log and access.log files located under /usr/local/nginx/logs
# ls /usr/local/nginx/logs/
access.log
error.log
nginx.pid
How to Install and Configure Nginx from Source on centos--转的更多相关文章
- How to Configure Nginx for Optimized Performance
Features Pricing Add-ons Resources | Log in Sign up Guides & Tutorials Web Server Guides Nginx ...
- How to install cacti With Nginx
转载于:https://github.com/blackyboy/Ubuntu-Linux-Stuffs/blob/master/How-to-install-Cacti-Monitoring-Ser ...
- Install and Configure Apache Kafka on Ubuntu 16.04
https://devops.profitbricks.com/tutorials/install-and-configure-apache-kafka-on-ubuntu-1604-1/ by hi ...
- ubuntu 16.04源码编译和配置caffe详细教程 | Install and Configure Caffe on ubuntu 16.04
本文首发于个人博客https://kezunlin.me/post/b90033a9/,欢迎阅读! Install and Configure Caffe on ubuntu 16.04 Series ...
- windows 10安装和配置caffe教程 | Install and Configure Caffe on windows 10
本文首发于个人博客https://kezunlin.me/post/1739694c/,欢迎阅读! Install and Configure Caffe on windows 10 Part 1: ...
- [Part 1] Ubuntu 16.04安装和配置QT5 | Part-1: Install and Configure Qt5 on Ubuntu 16.04
本文首发于个人博客https://kezunlin.me/post/91842b71/,欢迎阅读! Part-1: Install and Configure Qt5 on Ubuntu 16.04 ...
- Ubuntu 16.04安装ROS Kinetic详细教程 | Tutorial to Install and Configure ROS Kinetic on Ubuntu 16.04
本文首发于个人博客https://kezunlin.me/post/e2780b93/,欢迎阅读! Tutorial to Install and Configure ROS Kinetic on U ...
- Install and Configure SharePoint 2013 Workflow
这篇文章主要briefly introduce the Install and configure SharePoint 2013 Workflow. Microsoft 推出了新的Workflow ...
- You must use the Role Management Tool to install or configure Microsoft .NET Framework 3.5 SP1
今天在Windows Server 2008 下安装SQL SERVER 2008时,碰到如下错误: You must use the Role Management Tool to install ...
随机推荐
- 构造数组的MaxTree
题目 一个数组的MaxTree定义: 数组必须没有重复元素 MaxTree是一棵二叉树,数组的每一个值对应一个二叉树节点 包括MaxTree树在内且在其中的每一棵子树上,值最大的节点都是树的头 给定一 ...
- svn's diff command
[svn's diff command] svn diff 比较的是版本快照, 跟merge的应用diff完全不一样. 缺省情况下,svn diff忽略文件的祖先,只会比较两个文件的内容.如果你使用- ...
- 有关ListBox
如何拿到Source:从SQL,从XML file SQL:一个是ObjectDataProvider //用linq方法拿到SQL data,wrap到一个IEnumerable<Custom ...
- dojo grid 分页
dojo很强大,也很方便,但是缺少文档,只能看源代码,也挺好的,就是费时间... 网上找了一段代码(找不到原出处了,不好意思),也看了dojo自带的demo,放一段可以执行的页面代码这里.把ip换成自 ...
- <创建和销毁对象>经验法则——考虑用静态工厂方法代替公有构造方法
一.引出静态工厂方法 对于java类而言,为了让使用者获取它自身的一个实例化对象,会有以下方法: 1.该类提供一个公有的构造方法.在这种情况下,程序可以通过多个“new 构造方法”语句来创建类的任意多 ...
- MFC非模态对话框中屏蔽ESC键
个人的编程经验认为:对于非模态对话框,按下ESC键和点击红叉都会响应OnCancel()函数,而不会去响应OnClose()函数. 我们都知道,如果想屏蔽Enter键,只须重写OnOK()函数即可(重 ...
- Hadoop ecosystem
How did it all start- huge data on the web! Nutch built to crawl this web data Huge data had to save ...
- EXTJS AJAX解析XML数据
public String getAllAreaInfos() { try { List<Areainfo> list = null; if(areaName!=null&& ...
- Thread Pool Engine, and Work-Stealing scheduling algorithm
http://pages.videotron.com/aminer/threadpool.htm http://pages.videotron.com/aminer/zip/threadpool.zi ...
- boost 线程、互斥体、条件变量
1.任何技术都是针对特定场景设计的,也就是说,为了解决某个问题而设计的. 2.考虑下面一种场景:一个小旅馆,只有一个卫生间,有清洁人员,店主人,和旅客.卫生间用完之后,就会自动锁闭,必须取钥匙,才能进 ...