press the escape key to exit from the edit mode
type :x! to save and exit
or type :q! to quit without saving
now we can use yum to install the mongodb server:
# yum install mongo-10gen mongo-10gen-server
the default location on centos6 is:
/etc/mongod.conf
configure mongodb conf:
# vi /etc/mongod.conf
# mongo.conf
#where to log
logpath=/var/log/mongo/mongod.log
logappend=true
# fork and run in background
fork = true
#port = 27017
dbpath=/var/lib/mongo
# location of pidfile
pidfilepath = /var/run/mongodb/mongod.pid
# Disables write-ahead journaling
# nojournal = true
# Enables periodic logging of CPU utilization and I/O wait
#cpu = true
# Turn on/off security. Off is currently the default
#noauth = true
auth = true
# Verbose logging output.
#verbose = true
# Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck = true
# Enable db quota management
#quota = true
# Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
#diaglog = 0
# Ignore query hints
#nohints = true
# Disable the HTTP interface (Defaults to localhost:27018).
#nohttpinterface = true
# Turns off server-side scripting. This will result in greatly limited
# functionality
#noscripting = true
# Turns off table scans. Any query that would do a table scan fails.
#notablescan = true
# Disable data file preallocation.
#noprealloc = true
# Specify .ns file size for new databases.
# nssize =
# Accout token for Mongo monitoring server.
#mms-token =
# Server name for Mongo monitoring server.
#mms-name =
# Ping interval for Mongo monitoring server.
#mms-interval =
# Replication Options
# in replicated mongo databases, specify here whether this is a slave or master
#slave = true
#source = master.example.com
# Slave only: specify a single database to replicate
#only = master.example.com
# or
#master = true
#source = slave.example.com
the first option i did modify was the "port" option which i commented, because i have a dedicated server an will use the mongodb socket instead of the port, i don't need access from outside to that port either
#port = 27017
then next option that i changed is the "auth" option, i have set the authentification to true
auth = true
if you need more information about configuration options i recommend to read the mongodb configuration page
add chkconfig rule:
chkconfig --levels 235 mongod on
when you start mongo it creates a socket
/tmp/mongodb-27017.sock
if you get this error: "Error: couldn't connect to server" probably mongod is not started:
# service mongod start
now we have to install the php mongo (pecl) extension, this package contains the MongoDB database drivers used by php to communicate with MongoDB
# yum install php-pecl-mongo
no need to edit your php.ini and to add something like mongo.so to it, every package installed through yum will put an dot so file to a directory like /usr/lib64/php/modules/, php will look at that directory on startup and automatically load all the extensions so files that reside inside