CentOs + Nginx + Node.js + Mongodb配置
添加非root用户
under root permision
adduser wedate passwd wedate—> input the new password chmod u+w /etc/sudoers vim /etc/sudoers 添加 wedate All=(ALL) ALL 在root之后(首先搜索到root) :wq chmod u-w /etc/sudoers
安装必要的包依赖
更新系统所需的包
yum update
下载nginx(目前稳定版)
/* 系统约定 软件源代码包存放位置:/usr/local/src 源码包编译安装位置:/usr/local/软件名字 */ wget http://nginx.org/download/nginx-1.6.0.tar.gz
下载pcre (支持nginx伪静态)
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz
下载openssl(nginx扩展)
wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz
下载zlib(nginx扩展)
wget http://zlib.net/zlib-1.2.8.tar.gz
下载nodejs
wget http://nodejs.org/dist/v0.9.0/node-v0.9.0.tar.gz
下载rabbitmq
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.3.1/rabbitmq-server-3.3.1-1.noarch.rpm
安装编译工具及库文件(使用yum命令安装)
yum install -y apr* autoconf automake bison bzip2 bzip2* cloog-ppl compat* cpp curl curl-devel fontconfig fontconfig-devel freetype freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libtiff libtiff* make mpfr ncurses* ntp openssl openssl-devel patch pcre-devel perl php-common php-gd policycoreutils telnet t1lib t1lib* nasm nasm* wget zlib-devel
安装Nginx
安装pcre
cd /usr/local/src mkdir /usr/local/pcre tar zxvf pcre-8.35.tar.gz cd pcre-8.35 ./configure --prefix=/usr/local/pcre make make install
安装openssl
cd /usr/local/src mkdir /usr/local/openssl tar zxvf openssl-1.0.1h.tar.gz cd openssl-1.0.1h ./config --prefix=/usr/local/openssl make make install vi /etc/profile export PATH=$PATH:/usr/local/openssl/bin :wq! source /etc/profile
安装zlib
cd /usr/local/src mkdir /usr/local/zlib tar zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8 ./configure --prefix=/usr/local/zlib make make install
安装Nginx
groupadd www //暂时不用 useradd -g www www -s /bin/false //暂时不用 cd /usr/local/src tar zxvf nginx-1.6.0.tar.gz cd nginx-1.6.0 ./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35 注意:--with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35指向的是源码包解压的路径,而不是安装的路径,否则会报错
安装nodejs
cd /usr/local/src mkdir /usr/local/node tar zxvf node-v0.9.0.tar.gz cd node-v0.9.0 ./configure --prefix=/usr/local/node make make install vi /etc/profile 在export PATH USER 。。。一行的上面添加如下内容,并将NODE_HOME/bin设置到系统path中 #set for nodejs export NODE_HOME=/usr/local/node export PATH=$NODE_HOME/bin:$PATH :wq! //保存退出后执行如下命令,使刚才的配置生效 source /etc/profile
安装rabbitmq
cd /usr/local/src wget -O /etc/yum.repos.d/epel-erlang.repo http://repos.fedorapeople.org/repos/peter/erlang/epel-erlang.repo yum install erlang rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc yum install rabbitmq-server-3.3.1-1.noarch.rpm
安装mongodb
vi /etc/yum.repos.d/mongodb.repo 将以下代码粘入其中 [mongodb] name=MongoDB Repository baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/ gpgcheck=0 enabled=1 sudo yum install mongodb-org 在‘/’添加data/db文件 sudo service mongod start
取得所有服务器端代码
su wedate cd ~ git clone https://github.com/mainliner/APNS-rabbitMQ-nodejs git clone https://github.com/mainliner/EmailQueue 将所用的文件clone到wedate的文件夹下 安装守护进程 npm install forever -g
调试nginx
配置nginx vi /usr/local/nginx/conf/nginx.conf 在HTTP里加入如下代码 proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m; proxy_temp_path /var/tmp; include mime.types; default_type application/octet-stream; gzip on; gzip_comp_level 6; gzip_vary on; gzip_min_length 1000; gzip_proxied any; gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; gzip_buffers 16 8k; server { listen 80; server_name xxxxxx.com; location /wedate { proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_set_header Connection ""; proxy_http_version 1.1; proxy_cache one; proxy_cache_key sfs$request_uri$scheme; proxy_pass http://127.0.0.1:3000; } }
启动所有服务
cd /home/wedate/APNS-rabbitMQ-nodejs/ forever start APNS.js cd /home/wedate/EmailQueue/ forever start email.js cd /home/wedate/WeDateServer/ forever start cluster.js service mongod start chkconfig rabbitmq-server on
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!