Lnmp with MONGO

Source: Internet
Author: User
Tags install mongodb pear snmp install perl

This operation is for installation Services with centos7.2, and environment configuration, LNMP installation with MongoDB instead of MySQL


---------------------------------------------------------------------------------------

Php

----------------------------------------------------------------------------------------


Add user

Useradd-m-s/sbin/nologin PHP


Installing the compilation tools and library files

Yum install-y zlib-devel fontconfig fontconfig-devel libxpm* libtool* libxml2 libxml2-devel Curl Curl-devel

Yum install-y openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel libmcrypt

Yum install-y libmcrypt-devel yasm yasm-devel

Yum install-y gcc+ gcc-c++


Download individual installation Packages

LibpngHttp://downloads.sourceforge.net/libpng/libpng-1.6.16.tar.xz

GDhttps://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz

TIFFhttp://download.osgeo.org/libtiff/tiff-4.0.3.tar.gz

FreeTypehttp://ring.u-toyama.ac.jp/archives/graphics/freetype/freetype2/freetype-2.5.4.tar.gz

JPEGSRChttp://www.ijg.org/files/jpegsrc.v9a.tar.gz


Installing TIFF

./configure--prefix=/usr/local/tiff--enable-shared

Make && make install


Installing libpng

CD libpng-1.6.16

./configure--prefix=/usr/local/libpng--enable-shared

Make && make install


Installing FreeType

CD freetype-2.4.0

./configure--prefix=/usr/local/freetype

Make && make install


Install JPEG

CD jpeg-v9a

./configure--prefix=/usr/local/jpeg--enable-shared

Make && make install


Installing LIBGD

CD libgd-2.1.0

./configure \

--PREFIX=/USR/LOCAL/LIBGD \

--enable-shared \

--with-jpeg=/usr/local/jpeg \

--with-png=/usr/local/libpng \

--with-freetype=/usr/local/freetype \

--with-fontconfig=/usr/local/freetype \

--with-xpm=/usr/\

--with-tiff=/usr/local/tiff

Make && make install


Ready to install PHP (only 64-bit machines are available)

cp-frp/usr/lib64/libltdl.so*/usr/lib/

cp-frp/usr/lib64/libxpm.so*/usr/lib/


Install PHP

Export Ld_library_path=/usr/local/libgd/lib

CD php-5.6.16

./configure \

--prefix=/usr/local/php \

--WITH-CONFIG-FILE-PATH=/USR/LOCAL/PHP/ETC \

--with-mysql-sock=/tmp/mysqld.sock \

--WITH-PDO-MYSQL=MYSQLND \

--with-png-dir=/usr/local/libpng \

--WITH-GD \

--with-jpeg-dir=/usr/local/jpeg \

--with-freetype-dir=/usr/local/freetype \

--with-xpm-dir=/usr/\

--with-mcrypt \

--with-zlib \

--with-iconv \

--enable-libxml \

--enable-xml \

--enable-bcmath \

--ENABLE-SHMOP \

--enable-sysvsem \

--enable-inline-optimization \

--enable-opcache \

--enable-mbregex \

--ENABLE-FPM \

--enable-mbstring \

--ENABLE-FTP \

--ENABLE-GD-NATIVE-TTF \

--WITH-OPENSSL \

--ENABLE-PCNTL \

--enable-sockets \

--WITH-XMLRPC \

--enable-zip \

--ENABLE-SOAP \

--without-pear \

--with-gettext \

--enable-session \

--with-curl \

--enable-ctype \

--disable-ipv6 \

--disable-short-tags

Make && make install


Subsequent processing

CP Php.ini-production/usr/local/php/etc/php.ini

Cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf

Vi/usr/local/php/etc/php-fpm.conf

PID = run/php-fpm.pid//Remove left semicolon

Make the following settings:

This default is in/usr/loccal/php/etc/php-fpm.d/www.php-fpm.conf

user = PHP

Group = PHP


PID = run/php-fpm.pid//Remove left semicolon

wq!


Add Boot Boot

CP sapi/fpm/init.d.php-fpm/etc/rc.d/init.d/php

chmod +x/etc/rc.d/init.d/php

Chkconfig PHP on


---------------------------------------------------------------------

Yum install Nginx or compile and install Nginx

---------------------------------------------------------------------


Http://www.nginx.org at the bottom of the downloads there is a file that can be written into the. Repo.

Immediately after the installation of Yum,


Nginx if it is compiled and installed, the page where you downloaded the network source has the./configure parameter, or find your own document


PHP and Nginx link good








sudo yum install-y mongodb-enterprise This will probably install 10 packages, 5 are previously Yun source designation, here I have not written,

The remaining 5 should be packages that support some of the Mongod features

These 5 packages are: Mongodb-enterprise,

Mongodb-enterprise-server,

Mongodb-enterprise-shell,

Mongodb-enterprise-mongos,

Mongodb-enterprise-tools

11 Packages are:

(1/11): cyrus-sasl-gssapi-2.1.26-19.2.el7.x86_64.rpm | KB 00:00:00

(2/11): lm_sensors-libs-3.3.4-11.el7.x86_64.rpm | KB 00:00:00

(3/11): cyrus-sasl-plain-2.1.26-19.2.el7.x86_64.rpm | KB 00:00:00

(4/11): mongodb-enterprise-3.2.1-1.el7.x86_64.rpm | 5.9 KB 00:00:02

(5/11): mongodb-enterprise-mongos-3.2.1-1.el7.x86_64.rpm | 5.4 MB 00:01:06

(6/11): mongodb-enterprise-shell-3.2.1-1.el7.x86_64.rpm | 7.0 MB 00:01:14

(7/11): net-snmp-5.7.2-24.el7.x86_64.rpm | 321 KB 00:00:00

(8/11): net-snmp-agent-libs-5.7.2-24.el7.x86_64.rpm | 702 KB 00:00:00

(9/11): net-snmp-libs-5.7.2-24.el7.x86_64.rpm | 747 KB 00:00:00

(10/11): mongodb-enterprise-server-3.2.1-1.el7.x86_64.rpm | MB 00:02:19

(11/11): mongodb-enterprise-tools-3.2.1-1.el7.x86_64.rpm


-------------------------------

mongodb3.2

--------------------------------


First to see if there is a MySQL installation this, RPM-QA | grep MySQL

Yum Remove mysql-libs*


Yum Install Perl cyrus-sasl cyrus-sasl-plain Cyrus-sasl-gssapi krb5-libs \

Lm_sensors net-snmp OpenSSL popt rpm-libs tcp_wrappers zlib

Yum install CYRUS-SASL cyrus-sasl-plain cyrus-sasl-gssapi krb5-libs \

Net-snmp OpenSSL

Yum install CYRUS-SASL cyrus-sasl-plain cyrus-sasl-gssapi krb5-libs \

Lm_sensors-libs net-snmp-agent-libs net-snmp OpenSSL rpm-libs \

Tcp_wrappers-libs




Mongd32.repo (this will be better) Enterprise Edition, charge for

[Mongodb-enterprise]

Name=mongodb Enterprise Repository

baseurl=https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/stable/$basearch/

Gpgcheck=0

Enabled=1



The other one will install 5 Packages Community Edition

[mongodb-org-3.2]

Name=mongodb Repository

baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/

Gpgcheck=0

Enabled=1



(((((((() If you delete MongoDB sudo yum erase $ (rpm-qa | grep mongodb-enterprise)

sudo rm-r/var/log/mongodb

sudo rm-r/var/lib/mongo

)))))))




Plays, here, requires PHP to connect with Mongod, need to have driver http://www.cnblogs.com/chengmo/archive/2010/06/28/1766959.html


cd/usr/local/php/

wget Http://pear.php.net/go-pear.phar

bin/php Go-pear.phar Follow the guide to choose the installation location, here to keep the default, so that after the pecl command, in the PHP bin

Bin/pecl Install MongoDB

Vim Etc/php.ini Write extension=mongodb.so

I'm going to restart PHP-FPM.












This is a test of whether PHP is connected to Mongod (one connected, one inserting data)


<?php


$manager = new Mongodb\driver\manager ("mongodb://localhost:27017");

Var_dump ($manager);


?>




<?php


$bulk = new Mongodb\driver\bulkwrite ();


$bulk->insert ([' _id ' = 1, ' x ' = + 1]);

$bulk->insert ([' _id ' = 2, ' x ' = + 2]);


$bulk->update ([' X ' = 2], [' $set ' = = [' x ' = 1]], [' multi ' = False, ' Upsert ' and false]);

$bulk->update ([' X ' = 3], [' $set ' = = [' x ' = 3]], [' multi ' = False, ' upsert ' = true]);

$bulk->update ([' _id ' + 3], [' $set ' = = [' x ' = + 3]], [' multi ' = False, ' upsert ' = true]);


$bulk->insert ([' _id ' = 4, ' x ' = + 2]);


$bulk->delete ([' x ' = 1], [' limit ' = + 1]);


$manager = new Mongodb\driver\manager (' mongodb://localhost:27017 ');

$writeConcern = new Mongodb\driver\writeconcern (mongodb\driver\writeconcern::majority, 100);

$result = $manager->executebulkwrite (' db.collection ', $bulk, $writeConcern);


printf ("Inserted%d document (s) \ n", $result->getinsertedcount ());

printf ("Matched%d document (s) \ n", $result->getmatchedcount ());

printf ("Updated%d document (s) \ n", $result->getmodifiedcount ());

printf ("upserted%d document (s) \ n", $result->getupsertedcount ());

printf ("Deleted%d document (s) \ n", $result->getdeletedcount ());


foreach ($result->getupsertedids () as $index = = $id) {

printf (' upsertedid[%d]: ', $index);

Var_dump ($id);

}


/* If The Writeconcern could not being fulfilled */

if ($writeConcernError = $result->getwriteconcernerror ()) {

printf ("%s (%d):%s\n", $writeConcernError->getmessage (), $writeConcernError->getcode (), Var_export ($ Writeconcernerror->getinfo (), true));

}


/* If A write could not happen @ all */

foreach ($result->getwriteerrors () as $writeError) {

printf ("operation#%d:%s (%d) \ n", $writeError->getindex (), $writeError->getmessage (), $writeError->getcode ());

}


?>







[Email protected] ~]# Cat/lib/systemd/system/php-fpm.service

[Install]

Wantedby=multi-user.target

[Unit]

Description=the PHP FastCGI Process Manager

After=syslog.target Network.target


[Service]

Type=forking

Pidfile=/usr/local/php/var/run/php-fpm.pid

EXECSTART=/USR/LOCAL/PHP/SBIN/PHP-FPM--fpm-config/usr/local/php/etc/php-fpm.conf

EXECRELOAD=/BIN/KILL-USR2 $MAINPID




[Email protected]/]# echo never >/sys/kernel/mm/transparent_hugepage/enabled

[Email protected]/]# echo never >/sys/kernel/mm/transparent_hugepage/defrag



Vi/usr/lib/systemd/system/nginx.service

[Unit]

Desciption=nginx


[Service]

Type=forking

Pidfile=/usr/local/nginx/logs/nginx.pid

Execstart=/usr/local/nginx/sbin/nginx

Execstop=/usr/local/nginx/sbin/nginx-s stop

Execreload=/usr/local/nginx/sbin/nginx-s Reload


[Install]

Wantedby=multi-user.target


Boot up

Systemctl Enable Nginx




Next is the Mongod boot, which is the stable version with 11 packages installed.

[Email protected] web]# Cat/lib/systemd/system/mongod.service

# automatically generated by systemd-sysv-generator


[Unit]

Documentation=man:systemd-sysv-generator (8)

Sourcepath=/etc/rc.d/init.d/mongod

Description=sysv:mongo is a scalable, document-oriented database.

Before=runlevel3.target Runlevel5.target Shutdown.target

After=network-online.target Network.service

Conflicts=shutdown.target


[Service]

Type=forking

Restart=no

Timeoutsec=5min

Ignoresigpipe=no

Killmode=process

Guessmainpid=no

Remainafterexit=no

Pidfile=/var/run/mongodb/mongod.pid

Execstart=/etc/rc.d/init.d/mongod start

Execstop=/etc/rc.d/init.d/mongod stop

Execreload=/etc/rc.d/init.d/mongod Reload


This article is from the "Arctic Linux" blog, be sure to keep this source http://941012521.blog.51cto.com/9253690/1745157

Lnmp with MONGO

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.