Centos6.5 installation configuration Nginx and MongoDB environment tutorial

Source: Internet
Author: User
Tags chmod install mongodb install openssl mkdir mongodb mongodb server openssl prepare

Installation Configuration Nginx

Method One: Install the latest version of the Nginx

1, download nginx1.7.4

Note: Download address: http://nginx.org/download/nginx-1.7.4.tar.gz
Wget-c http://nginx.org/download/nginx-1.7.4.tar.gz
2, installation

Note: The default installation to/usr/local/nginx
TAR-ZXVF nginx-1.7.4.tar.gz
CD nginx-1.7.4
./configure
Made && make install #注: a bunch of stuff.
3, Operation

/usr/local/nginx/sbin/nginx

See if Nginx is normal
[Root@aaa nginx-1.2.4]#/usr/local/nginx/sbin/nginx-t
The following code appears: Nginx:the configuration file/usr/local/nginx/conf/nginx.conf syntax is OK nginx:configuration file/usr/local/n Ginx/conf/nginx.conf test is successful installed successfully!

Method Two:

Compile installation Nginx (refer to my colleague's installation method) to install OpenSSL (method self Search, or yum install OpenSSL) to prepare Pcre Library Pere to allow Nginx to support regular expressions. Just prepare, not installed, to avoid errors in the 64-bit system.

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
Unzip in the/usr/local directory
TAR-ZXF pcre-8.30
Preparing the Zlib library is just as well prepared and not installed to avoid errors in the 64-bit system.

wget http://sourceforge.net/projects/libpng/files/zlib/1.2.6/zlib-1.2.6.tar.gz/download
Unzip in the/usr/local directory
TAR-ZXF zlib-1.2.6.tar.gz
Compiling the installation
1, download, create a temporary directory

wget http://nginx.org/download/nginx-1.1.9.tar.gz
TAR-ZXF nginx-1.1.9.tar.gz
CD nginx-1.1.9
Mkdir-p/var/tmp/nginx
2. Compiling and installing

./configure--prefix=/usr/local/nginx\
--pid-path=/var/run/nginx.pid\
--lock-path=/var/lock/nginx.lock\
--with-http_ssl_module\
--with-http_dav_module\
--with-http_flv_module\
--with-http_realip_module\
--with-http_gzip_static_module\
--with-http_stub_status_module\
--with-mail--with-mail_ssl_module\
--with-pcre=.. /pcre-8.30\
--with-zlib=.. /zlib-1.2.6\
--with-debug\
--http-client-body-temp-path=/var/tmp/nginx/client\
--http-proxy-temp-path=/var/tmp/nginx/proxy\
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi\
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi\
--http-scgi-temp-path=/var/tmp/nginx/scgi

Make && make install
Ln-s/usr/local/nginx/sbin/nginx/usr/sbin/
Reference to: Nginx compilation parameter parsing

–prefix #nginx安装目录, default in/usr/local/nginx
–pid-path #pid问件位置, default in Logs directory
–lock-path #lock问件位置, default in Logs directory
–with-http_ssl_module #开启HTTP SSL module to support HTTPS requests.
–with-http_dav_module #开启WebDAV扩展动作模块, you can specify permissions for files and directories
–with-http_flv_module #支持对FLV文件的拖动播放
–with-http_realip_module #支持显示真实来源IP地址
–with-http_gzip_static_module #预压缩文件传前检查 to prevent files from being repeatedly compressed
–with-http_stub_status_module #取得一些nginx的运行状态
–with-mail #允许POP3/IMAP4/SMTP Agent Module
–with-mail_ssl_module #允许POP3/IMAP/SMTP can use Ssl/tls
–with-pcre=.. /pcre-8.11 #注意是未安装的pcre路径
–with-zlib=.. /zlib-1.2.5 #注意是未安装的zlib路径
–with-debug #允许调试日志
–http-client-body-temp-path #客户端请求临时文件路径
–http-proxy-temp-path #设置http Proxy Temp file path
–http-fastcgi-temp-path #设置http fastcgi Temporary file path
–http-uwsgi-temp-path=/var/tmp/nginx/uwsgi #设置uwsgi Temporary file path
–http-scgi-temp-path=/var/tmp/nginx/scgi #设置scgi Temporary file path
3, boot from start Nginx script

Vim/etc/init.d/nginx
Enter edit mode and type the following script content:

#!/bin/bash
#
#chkconfig:-85 15
#description: Nginx is a world Wide Web server.
#processname: Nginx

Nginx=/usr/local/nginx/sbin/nginx
Conf=/usr/local/nginx/conf/nginx.conf

Case is in
Start
Echo-n "Starting Nginx"
$nginx-C $conf
echo "Done"
;;

Stop
Echo-n "Stopping Nginx"
Killall-9 Nginx
echo "Done"
;;

Test
$nginx-T-c $conf
;;

Reload
Echo-n "Reloading Nginx"
PS AUXWW | grep Nginx | grep Master | awk ' {print $} ' | Xargs Kill-hup
echo "Done"
;;

Restart)
$ stop
$ start
;;

Show
Ps-aux|grep Nginx
;;

*)
Echo-n "Usage: $ {start|restart|reload|stop|test|show}"
;;

Esac

After you save the above script, do the following

chmod +x/etc/init.d/nginx
Chkconfig--add Nginx
Chkconfig Nginx on

You can use NGINX-T to verify that the syntax is problematic

Installation Configuration MongoDB


MongoDB official online Download the latest version of the MongoDB, according to the official online instructions to install:

Run the following command first:

Curl-o http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.6.3.tgz
Second, using tar for decompression, follow the instructions below

TAR-ZXVF mongodb-linux-x86_64-2.6.3.tgz
Third, create a new MongoDB folder and copy the extracted mongodb-linux-x86_64-2.6.3 to MongoDB below.

Follow the instructions below

Mkdir-p MongoDB
Cp-r-N Mongodb-linux-x86_64-2.6.3/mongodb
Four, change the environment variable, under the path/etc/, find the BASHRC file

Export Path=<mongodb-install-directory>: $PATH
You can replace it with your MongoDB path.

Five, create the path of the MongoDB dbdata

Mkdir-p/usr/local/mongo/data
Mongod--dbpath/usr/local/mongo/data
VI, enter the MONGO folder, run the MONGO command, start MONGO on it.

The above installation method is relatively simple, but there is a problem, that is MONGO start must also make data, that is to run Mongod--dbpath/usr/local/mongo/data, more cumbersome, the following describes a permanent installation method, Add the MONGO startup to the service. However, the installation of the version must be developed, this example to mongodb-src-r1.8.1.tar.gz specific reference blog: Http://www.9958.pw/post/centos_mongodb Note: Each version must be consistent with the blog, The following to Rin blog This article to do a reprint!

Download the required software (download to/usr/local/src directory)

#wget http://downloads.mongodb.org/src/mongodb-src-r1.8.1.tar.gz
#wget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz
#wget http://sourceforge.net/projects/pcre/files/pcre/8.12/pcre-8.12.tar.bz2
Install Python

(Note: The scons must be 2.0.1, the specific download address is http://prdownloads.sourceforge.net/scons/scons-2.0.1.tar.gz):

#yum install-y Python-devel
Install scons: Download scons (http://www.scons.org/download.php)
Tar zxf scons-2.0.1.tar.gz
CD scons-2.0.1
Python setup.py Install
Install the SpiderMonkey library,

Download support for C JS API library js-1.7.0.tar.gz (http://ftp.mozilla.org/pub/mozilla.org/js/)

Yum install-y boost Boost-devel

Tar zxvf js-1.7.0.tar.gz
CD js/src/
Export cflags= "-djs_c_strings_are_utf8"
Make-f Makefile.ref
JS_DIST=/USR gmake-f Makefile.ref Export
Cd.. /..
Install Pcre

Tar zxf pcre-8.12.tar.gz
CD pcre-8.12
./configure--enable-utf8--enable-unicode-properties
Make && make install
Cd..
Install MongoDB

Tar zxf mongodb-src-r1.8.1.tar.gz
CD mongodb-src-r1.8.1
SCons All//scons may be unable to find the Pcre library (modify/etc/ld.so.conf is also useless, is scons its own problem), then need to open mongodb-src-r1.8.0 under the sconstruct, find " Linux2 "= = Os.sys.platform:" In libpath after adding the installation path to the Pcrecpp library, add libs after Pcrecpp library name, and then scons all can be (operation: Vim sconstruct; Original: env . Append (libpath=["/usr/lib64", "/lib64"), modified env.  Append (libpath=["/usr/lib64", "/lib64", "/usr/local/pcre/lib"]); Next in Env. Append (libs=["pthread") adds Env after. Append (libs=["Libpcrecpp"))
SCons--prefix=/usr/local/mongo Install
If you need to install Lib and head, install with the following
SCons--prefix=/usr/local/mongo--full Install
Creating a configuration file

Mkdir-p/usr/local/mongo/etc/usr/local/mongo/data/usr/local/mongo/log//usr/local/mongo/repair
Vim/usr/local/mongo/etc/mongo.conf
Add the following content to the mongo.conf
DBPath =/usr/local/mongo/data
LogPath =/usr/local/mongo/mongodb.log
Repairpath =/usr/local/mongo/repair
Pidfilepath =/usr/local/mongo/mongodb.pid
Directoryperdb = True
Logappend = True
Noauth = True
Port = 27017
Maxconns = 1024
Fork = True
Rest = True
Quota = True
Quotafiles = 1024
Nssize = 16
Start MongoDB

Ln-s/usr/local/mongo/bin/mongod/usr/bin/mongod
Mongod-f/usr/local/mongo/etc/mongo.conf
See if it's starting up, but it's unwise to manage the MongoDB server in this way:

Mkdir-p/usr/local/mongo/srv
Vim/usr/local/mongo/srv/mongodb-start
Add the following content

#!/bin/sh
Mongod-f/usr/local/mongo/etc/mongo.conf

Vim/usr/local/mongo/srv/mongodb-stop
Add the following content

#!/bin/bash
Pid= ' ps-o Pid,command ax | grep Mongod | awk '!/awk/&&!/grep/{print $} ';
if ["${pid}"!= "]; Then
Kill-2 ${pid};
Fi
Add Execute permission

chmod A+x/usr/local/mongo/srv/mongodb-start
chmod a+x/usr/local/mongo/srv/mongodb-stop
Vim/etc/rc.d/init.d/mongodb
Add the following content

#! /bin/sh
#
# Mongodb–this script starts and stops the MongoDB daemon
#
# Chkconfig:-85 15
# Description:mongodb is a non-relational database storage system.
# Processname:mongodb
# config:/usr/local/mongo/etc/mongo.conf
# Pidfile:/usr/local/mongo/mongodb.pid
Path=/usr/local/mongo/bin:/sbin:/bin:/usr/sbin:/usr/bin
Name=mongodb
Test-x $DAEMON | | Exit 0
Set-e
Case "$" in
Start
Echo-n "Starting MongoDB ... "
/usr/local/mongo/srv/mongodb-start
;;
Stop
Echo-n "Stopping MongoDB ... "
/usr/local/mongo/srv/mongodb-stop
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop}" >&2
Exit 1
;;
Esac
Exit 0

Add a service

chmod A+x/etc/rc.d/init.d/mongodb
Chkconfig--add MongoDB
Chkconfig--level 345 MongoDB on
/etc/rc.d/init.d/mongodb start

Okay, here we go. About Nginx and MongoDB database installation is introduced here, interested in the article process is very careful.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.