Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mongo for lnmp

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The purpose of this operation is to install lnmp with mongodb instead of mysql for installation services with centos7.2 and environment configuration.

-

Php

-

/ / add users

Useradd-M-s / sbin/nologin php

/ / install 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 each installation package

Libpng http://downloads.sourceforge.net/libpng/libpng-1.6.16.tar.xz

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

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

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

Jpegsrc http://www.ijg.org/files/jpegsrc.v9a.tar.gz

/ / install tiff

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

Make & & make install

/ / install libpng

Cd libpng-1.6.16

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

Make & & make install

/ / install 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

/ / install 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

/ / prepare to install php (only available on 64-bit machines)

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 the left semicolon

Make the following settings:

This defaults to / usr/loccal/php/etc/php-fpm.d/www.php-fpm.conf

User = php

Group = php

Pid = run/php-fpm.pid / / remove the 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 has a file at the bottom of downloads that can be written into .repo.

Install yum directly after it is finished.

If nginx is compiled and installed, there are parameters after. / configure on the page where you download the network source, or find your own documentation.

Php and nginx are well linked.

Sudo yum install-y mongodb-enterprise will install about 10 software packages, 5 of which are specified by previous yun sources, which I haven't written here.

The remaining five should be packages that support some of the features of mongod

These five bags are: mongodb-enterprise

Mongodb-enterprise-server

Mongodb-enterprise-shell

Mongodb-enterprise-mongos

Mongodb-enterprise-tools

The 11 packages are:

(1go 11): cyrus-sasl-gssapi-2.1.26-19.2.el7.x86_64.rpm | 41 kB 00:00:00

(2go 11): lm_sensors-libs-3.3.4-11.el7.x86_64.rpm | 40 kB 00:00:00

(3go 11): cyrus-sasl-plain-2.1.26-19.2.el7.x86_64.rpm | 38 kB 00:00:00

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

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

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

(7x11): net-snmp-5.7.2-24.el7.x86_64.rpm | 321 kB 00:00:00

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

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

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

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

-

* mongodb3.2

-

First of all, check to see if there is any mysql installed here, 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, for a fee

[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 of community version.

[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 want to delete mongodb sudo yum erase $(rpm-qa | grep mongodb-enterprise)

Sudo rm-r / var/log/mongodb

Sudo rm-r / var/lib/mongo

)

* important. Here, when you need to connect php to mongod, you need to have a 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 chooses the installation location according to the guide. Keep the default here, and then you have the pecl command, which is under bin of php.

Bin/pecl install mongodb

Vim etc/php.ini writes to extension=mongodb.so

Just restart php-fpm.

This is to test whether php is connected to mongod (one to connect, one to insert data).

[root@test001 ~] # 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

[root@test002 /] # echo never > / sys/kernel/mm/transparent_hugepage/enabled

[root@test002 /] # 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 start

Systemctl enable nginx

Next is the boot self-boot of mongod, which is the stable version of the 11 packages installed.

[root@test001 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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report