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 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!