Download source file
wget http://nginx.org/download/nginx-1.0.15.tar.gz
[root@test src]# tar -zxvf nginx-1.0.15.tar.gz
[root@test src]# ./configure --prefix=/usr/local/ --with-http_ssl_module
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
./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@test nginx-1.0.15]# yum install pcre*
[root@test nginx-1.0.15]# ./configure --prefix=/usr/local/ --with-http_ssl_module
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/"
nginx binary file: "/usr/local//sbin/nginx"
nginx configuration prefix: "/usr/local//conf"
nginx configuration file: "/usr/local//conf/nginx.conf"
nginx pid file: "/usr/local//logs/nginx.pid"
nginx error log file: "/usr/local//logs/error.log"
nginx http access log file: "/usr/local//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
make install
cp conf/nginx.conf '/usr/local/nginx//conf/nginx.conf.default'
test -d '/usr/local/nginx//logs' || mkdir -p '/usr/local/nginx//logs'
test -d '/usr/local/nginx//logs' || mkdir -p '/usr/local/nginx//logs'
test -d '/usr/local/nginx//html' || cp -R html '/usr/local/nginx/'
test -d '/usr/local/nginx//logs' || mkdir -p '/usr/local/nginx//logs'
make[1]: Leaving directory `/usr/local/src/nginx-1.0.15'
[root@test nginx-1.0.15]# cd /usr/local/nginx/
[root@test nginx]# ls
conf html logs sbin
[root@test nginx]# cd conf
[root@test conf]# vi nginx.conf
server {
listen 8081;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /var/ww/html;
index index.html index.htm;
}
listen: Specifies the port on which this virtual host listens.
server: Lists the host headers for the site.
location /: Specifies how to handle requests under the location '/', the site root.
root: The document root for the site.
index: An ordered priority list of default documents.
to test the configuration file
[root@test conf]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx//conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx//conf/nginx.conf test is successful
[root@test conf]# cd /usr/local/nginx/sbin/
[root@test sbin]# ./nginx
When you start up your nginx (just go to sbin and type ./nginx in order to start your web server!) you get few more directories:
[root@test sbin]# ps -ef | grep nginx
1222 9940 2436 0 05:05 ? 00:00:01 /usr/bin/kwrite /home/test/Desktop/nginx
root 18195 1 0 05:54 ? 00:00:00 nginx: master process ./nginx
nobody 18196 18195 0 05:54 ? 00:00:00 nginx: worker process
root 18202 3430 0 05:54 pts/1 00:00:00 grep nginx
[root@test nginx]# ls
client_body_temp conf fastcgi_temp html logs proxy_temp sbin scgi_temp uwsgi_temp
In config file
TCP nopush setting means that HTTP response hearders are all sent in one packet. Sendfile setting means that Nginx ignores the details of the file it is sending and uses kernel sendfile support instead. Keepalive setting defines how long server waits for users packets. This should be changed only to few seconds on busy sites. Gzip compression saves bandwith on site, depending what kind of packets server is sending.
/usr/local/nginx/html is the doc root.
http://localhost:8081
Welcome to nginx!
Note: If your server currently is configured with another web server, you'll likely need to have Nginx listen on a port other than 80. This is done simply by editing the 'listen' setting in the default server block, as well as any additional server blocks that are created.
No comments:
Post a Comment