1、 安装编译工具和库文件
[[email protected] opt]# yum -y install
make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
2、 安装PCRE
(1) 下载 PCRE 安装包,下载地址:http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
(2) 解压。[[email protected] opt]# tar
-zxf software/pcre-8.35.tar.gz -C modules/
(3) 进入pcre目录 [[email protected]dh opt]# cd
modules/pcre-8.35/
(4) 编译安装
[[email protected]
pcre-8.35]# ./configure
[[email protected]
pcre-8.35]# make && make install
(5) 查看版本,确认安装成功
[[email protected]
pcre-8.35]# pcre-config --version
8.35
3、 安装Nginx
(1) 下载Nginx ,地址为: http://nginx.org/download/nginx-1.6.2.tar.gz
(2) 解压Nginx
[[email protected]
opt]# tar -zxf software/nginx-1.6.2.tar.gz -C modules/
(3) 配置
[[email protected]
nginx-1.6.2]# ./configure --prefix=/opt/modules/www
--with-http_stub_status_module --with-http_ssl_module
--with-pcre=/opt/modules/pcre-8.35
(4) make
(5) make install
(6) 查看nginx 版本,确认安装成功
[[email protected]
nginx-1.6.2]# /opt/modules/www/sbin/nginx -v
4、 Nginx配置
(1)
添加用户,用户名为www
(2)
配置nginx.conf文件
[[email protected] nginx-1.6.2]# vim
/opt/modules/www/conf/nginx.conf
user www www; worker_processes 1; error_log pid worker_rlimit_nofile events { use epoll; worker_connections 65535; } http { include default_type log_format ‘$status $body_bytes_sent "$http_referer" ‘ ‘"$http_user_agent" $http_x_forwarded_for‘; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; sendfile on; tcp_nopush keepalive_timeout 60; tcp_nodelay fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; gzip on; gzip_min_length 1k; gzip_buffers gzip_http_version 1.0; gzip_comp_level 2; gzip_types gzip_vary on; server { listen 80; server_name localhost; index index.html index.htm index.php; root /opt/modules/www/html; location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 15d; } access_log off; } } |
(3)
检查配置是否正确
[[email protected] www]#
/opt/modules/www/sbin/nginx -t
5、 启动Nginx
[[email protected] www]# /opt/modules/www/sbin/nginx
[[email protected] www]# ps -ef|grep nginx
6、 访问Nginx站点