CentOS之:nginx安装

前言:安装centos平台编译环境

安装make:

安装g++:


正式开始:
---------------------------------------------------------------------------
一般我们都需要先装pcre,zlib,前者为了重写rewrite,后者为了gzip压缩。
1.选定源码目录
可以是任何目录,本文选定的是/usr/local/src

2.安装PCRE库
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/下载最新的 PCRE 源码包,使用下面命令下载编译和安装 PCRE 包:

/usr/localwebserverNginxsbinNginx -v

到这里Nginx就安装完成了,如果只是处理静态HTML就不用继续安装了


Nginx 配置

创建 Nginx 运行使用的用户 www:(进入/usr/local/src/Nginx/conf目录)

1、创建www组(可以去了解一下linux的组策略)

2、创建www用户,并加入到www组

[root@bogonconf]# groupadd www
useradd g www www

配置Nginx.conf ,将/usr/local/webserver/Nginx/conf/Nginx.conf替换为以下内容

[root@bogonconf]# cat /usr/localwebserverNginxconf.conf user www www; worker_processes 1 #设置值和cpu核心数一致 error_log logsNginx_errorlog crit#日志位置和日志级别 pid pid #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 65535 events { use epoll worker_connections } http include mimetypes default_type applicationoctet-stream log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ''"$http_user_agent" $http_x_forwarded_for' #charset gb2312; server_names_hash_bucket_size 128 client_header_buffer_size 32k large_client_header_buffers 4 client_max_body_size 8m sendfile on tcp_nopush on keepalive_timeout 60 tcp_nodelay on fastcgi_connect_timeout 300 fastcgi_send_timeout fastcgi_read_timeout fastcgi_buffer_size 64k fastcgi_buffers fastcgi_busy_buffers_size 128k fastcgi_temp_file_write_size gzip on gzip_min_length 1k gzip_buffers 16k gzip_http_version 1.0 gzip_comp_level 2 gzip_types textplain applicationxjavascript textcss applicationxml gzip_vary on #limit_zone crawler $binary_remote_addr 10m;#下面是server虚拟主机的配置 server listen 80;#监听端口 server_name localhost;#域名 index indexhtml indexhtm indexPHP root html;#站点目录 location ~ .*\.(|PHP5)?$ #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000 fastcgi_index index include fastcgi location gifjpgjpegpngbmpswfico) expires 30d # access_log off;jscss15d access_log off }

检查配置文件ngnix.conf的正确性命令:

t


启动 Nginx

Nginx 启动命令如下:

Nginx

访问站点

从浏览器访问我们配置的站点ip:

Nginx 其他命令

以下包含了 Nginx 常用的几个命令:

/usr/s reload            # 重新载入配置文件
s reopen            # 重启 Nginxs stop              # 停止 Nginx

重要参考链接

http://www.runoob.com/linux/Nginx-install-setup.html

http://www.Nginx.cn/install

http://blog.csdn.net/mxxlevel/article/details/45537341

http://www.runoob.com/w3cnote/Nginx-install-and-config.html

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native