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

CentOS7 installs LNMP+Mongodb environment

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

Share

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

CentOS 7 MySQL 5.7.10 Mongo 3.2.1 Nginx 1.8.0 PHP 5.5.31 Redis 3.0.6

= = CentOS config

Systemctl stop firewalld.service # stop firewall

Systemctl disable firewalld.service # prevents firewall from booting

Yum install-y iptables-services

Vi / etc/sysconfig/iptables

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 80-j ACCEPT

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 3306-j ACCEPT

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 27017-j ACCEPT

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 6379-j ACCEPT

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 9312-j ACCEPT

: wq! # Save exit

Systemctl restart iptables.service

Systemctl enable iptables.service

Vi / etc/selinux/config # turn off SELINUX

# SELINUX=enforcing # comment out

# SELINUXTYPE=targeted # comment out

SELINUX=disabled # increased

: wq! # Save exit

Setenforce 0 # makes the configuration effective immediately

# modify time, skip if the time zone is changed during installation

Date

Timedatectl

Timedatectl set-timezone Asia/Shanghai

Date

Hwclock-show

Hwclock-- set-- date '2016-01-27 00Rose 24purl 10'

Hwclock-hctosys

Clock-w

Shutdown-r now

# Note: at each step below, the wget installation package is stored in / usr/local/src; because some of the used installation packages need to be downloaded, and those that cannot be downloaded can be downloaded from the network disk address [http://pan.baidu.com/s/1boBJxd9].

= cmake

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

Yum-y install imake mysql-devel

Yum-y install net-tools

Yum-y install wget

Cd / usr/local/src

Wget http://www.cmake.org/files/v2.8/cmake-2.8.11.2.tar.gz

Tar-zxvf cmake-2.8.11.2.tar.gz

Cd cmake-2.8.11.2

. / configure

Make

Make install

= mysql

Cd / usr/local/src

Wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.10.tar.gz

Groupadd mysql # add mysql Group

Useradd-g mysql mysql-s / bin/false # create a user mysql and join the mysql group, and do not allow mysql users to log in directly to the system

Mkdir-p / home/mysql/data # create MySQL database storage directory

Chown-R mysql:mysql / home/mysql/data

Mkdir-p / usr/local/mysql

Tar-zxvf mysql-5.7.10.tar.gz

Cd mysql-5.7.10

# configure to resolve CMake Error. If you have downloaded boost, do the following, otherwise change the-DDOWNLOAD_BOOST=0 of the following cmake to 1.

Mkdir / usr/local/boost

Cp / usr/local/src/boost_1_59_0.tar.gz / usr/local/boost/boost_1_59_0.tar.gz

Cd / usr/local/boost

Tar-zxvf boost_1_59_0.tar.gz

Cd / usr/local/src/mysql-5.7.10

Cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/home/mysql/data-DSYSCONFDIR=/etc-DWITH_INNOBASE_STORAGE_ENGINE=1-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DDOWNLOAD_BOOST=0-DWITH_BOOST=/usr/local/boost

Make

Make install

Cd / usr/local/mysql

# make sure there are no files and directories under / home/mysql/data before executing the following initialization command!

Bin/mysqld-initialize-insecure-user=mysql-basedir=/usr/local/mysql-datadir=/home/mysql/data

Mkdir-p / home/mysql/data/undolog # undo storage space, innodb_undo_directory and innodb_undo_tablespaces must be set during installation, non-essential use

Chown-R mysql:mysql / home/mysql/data/undolog

# create a configuration file. If you need master-slave replication or clustering, see mysql deployment in another blog post

Cp support-files/my-default.cnf / etc/my.cnf

Vi / etc/my.cnf

[mysqld]

Character_set_server=utf8

Init_connect='SET NAMES utf8'

Net_buffer_length=4M

Max_allowed_packet=300M

Expire_logs_days=15

Default_password_lifetime=0 # is set to never expire. By default, it expires after 360 days without prompting for installation. It is too lame.

# undo (ibdata) para set on

Innodb_undo_log_truncate=ON

Innodb_undo_directory=/home/mysql/data/undolog

Innodb_undo_tablespaces=4

Innodb_max_undo_log_size=10G

[client]

# default-character-set=utf8 # it is best not to add this item

: wq! # Save exit

Cp support-files/mysql.server / etc/rc.d/init.d/mysqld # copy startup script to init.d, and / etc/init.d and / etc/rc.d/init.d have established a link

Chmod 755 / etc/init.d/mysqld

Chkconfig mysqld on

Vi / etc/rc.d/init.d/mysqld

Basedir=/usr/local/mysql # MySQL Program installation path

Datadir=/home/mysql/data # MySQl database storage directory

: wq! # Save exit

Systemctl start mysqld.service # launch service mysqld start

Vi / etc/profile # adds the mysql service to the system environment variable: add the following line at the end

Export PATH=$PATH:/usr/local/mysql/bin

: wq! # Save exit

Source / etc/profile

The following two lines link the library files of myslq to the default location of the system, so that you do not have to specify the library file address of mysql when compiling software such as PHP.

Ln-s / usr/local/mysql/lib / usr/lib/mysql

Ln-s / usr/local/mysql/include/mysql / usr/include/mysql

Mkdir / var/lib/mysql # create directory

Ln-s / tmp/mysql.sock / var/lib/mysql/mysql.sock # add soft links

Mysql_secure_installation # (! Trick people, do not recommend implementation! ) set the Mysql password, press Y enter to enter the password twice according to the prompt, do not use the default way to generate the password, can not remember

Alter user 'root'@'localhost' identified by' sa'; # or press this to change the default password

GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' sa' WITH GRANT OPTION; # allows root to log in remotely and change the password to 'sa'

Flush privileges

# if you modify the data storage after installation, you need to--

Service mysqld stop

Create a data directory data in the directory of the mkdir / home/mysql/data # mysql user

Cd / data/mysql # original data directory

Cp-R * / home/mysql/data

Chown-R mysql:mysql / home/mysql/data

Vi / etc/rc.d/init.d/mysqld

Datadir=/home/mysql/data

: wq!

Service mysqld start

= nginx

Cd / usr/local/src

Wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz

Wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz

Wget http://zlib.net/zlib-1.2.8.tar.gz

Wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.8.31.4-beta.tar.gz

Wget https://dl.google.com/dl/page-speed/psol/1.8.31.4.tar.gz

Wget http://nginx.org/download/nginx-1.8.0.tar.gz

Tar-zxvf pcre-8.35.tar.gz

Mkdir / usr/local/pcre

Cd pcre-8.35

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

Make

Make install

Tar-zxvf openssl-1.0.1h.tar.gz

Mkdir / usr/local/openssl

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

Tar-zxvf zlib-1.2.8.tar.gz

Mkdir / usr/local/zlib

Cd zlib-1.2.8

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

Make

Make install

Tar-zxvf v1.8.31.4-beta.tar.gz

Cp 1.8.31.4.tar.gz. / ngx_pagespeed-1.8.31.4-beta

Cd ngx_pagespeed-1.8.31.4-beta

Tar-xzvf 1.8.31.4.tar.gz

Groupadd www

Useradd-g www www-s / bin/false

Tar-zxvf nginx-1.8.0.tar.gz

Mkdir / usr/local/nginx

Chown-R www:www / usr/local/nginx

Cd nginx-1.8.0

/ configure-- prefix=/usr/local/nginx-- without-mail_pop3_module-- without-mail_imap_module-- without-mail_smtp_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-add-module=/usr/local/src/ngx_pagespeed-1.8.31.4-beta

# Note:-- with-openssl-- with-zlib-- with-pcre-- add-module points to the path of decompression of the source package, not the path of installation, otherwise an error will be reported.

Make

Make install

/ usr/local/nginx/sbin/nginx

Vi / etc/rc.d/init.d/nginx

# # start the script and add the following

#! / bin/sh

#

# nginx-this script starts and stops the nginx daemon

#

# chkconfig:-85 15

# description: Nginx is an HTTP (S) server, HTTP (S) reverse\

# proxy and IMAP/POP3 proxy server

# processname: nginx

# config: / etc/nginx/nginx.conf

# config: / usr/local/nginx/conf/nginx.conf

# pidfile: / usr/local/nginx/logs/nginx.pid

# Source function library.

. / etc/rc.d/init.d/functions

# Source networking configuration.

. / etc/sysconfig/network

# Check that networking is up.

["$NETWORKING" = "no"] & & exit 0

Nginx= "/ usr/local/nginx/sbin/nginx"

Prog=$ (basename $nginx)

NGINX_CONF_FILE= "/ usr/local/nginx/conf/nginx.conf"

[- f / etc/sysconfig/nginx] & &. / etc/sysconfig/nginx

Lockfile=/var/lock/subsys/nginx

Make_dirs () {

# make required directories

User= `$ nginx-V 2 > & 1 | grep "configure arguments:" | sed's / [^ *] *-- user=\ ([^] *\). * /\ 1Uniple g'- `

If [- z "`grep $user / etc/ passwd`]; then

Useradd-M-s / bin/nologin $user

Fi

Options= `$ nginx-V 2 > & 1 | grep 'configure arguments:' `

For opt in $options; do

If [`echo $opt | grep'. *-temp-path' `]; then

Value= `echo $opt | cut-d "="-f 2`

If [!-d "$value"]; then

# echo "creating" $value

Mkdir-p $value & & chown-R $user $value

Fi

Fi

Done

}

Start () {

[- x $nginx] | | exit 5

[- f $NGINX_CONF_FILE] | | exit 6

Make_dirs

Echo-n $"Starting $prog:"

Daemon $nginx-c $NGINX_CONF_FILE

Retval=$?

Echo

[$retval-eq 0] & & touch $lockfile

Return $retval

}

Stop () {

Echo-n $"Stopping $prog:"

Killproc $prog-QUIT

Retval=$?

Echo

[$retval-eq 0] & & rm-f $lockfile

Return $retval

}

Restart () {

# configtest | | return $?

Stop

Sleep 1

Start

}

Reload () {

# configtest | | return $?

Echo-n $"Reloading $prog:"

Killproc $nginx-HUP

RETVAL=$?

Echo

}

Force_reload () {

Restart

}

Configtest () {

$nginx-t-c $NGINX_CONF_FILE

}

Rh_status () {

Status $prog

}

Rh_status_q () {

Rh_status > / dev/null 2 > & 1

}

Case "$1" in

Start)

Rh_status_q & & exit 0

, 1

Stop)

Rh_status_q | | exit 0

, 1

Restart | configtest)

, 1

Reload)

Rh_status_q | | exit 7

, 1

Force-reload)

Force_reload

Status)

Rh_status

Condrestart | try-restart)

Rh_status_q | | exit 0

*)

Echo $"Usage: $0 {start | stop | status | restart | condrestart | try-restart | reload | force-reload | configtest}"

Exit 2

Esac

: wq!

Chmod 755 / etc/rc.d/init.d/nginx

Chkconfig nginx on # systemctl enable nginx, chkconfig-- add nginx

Vi / usr/local/nginx/conf/nginx.conf

Worker_processes 1 # adjusts the number of worker processes according to the number of cpu cores (more / proc/cpuinfo | grep "model name"). One kernel corresponds to one worker process.

Gzip on; # remove comments

Client_max_body_size 50m; # added this item to remove the upload limit is too small.

Fastcgi_ignore_client_abort on; # is put in the http section to solve the problem of invalid php fsockopen function.

Client_header_buffer_size 16k; # is placed in the http section to solve the problem of invalid php fsockopen function

Large_client_header_buffers 4 64k; # put it in the http segment to solve the problem of invalid php fsockopen function

: wq!

/ etc/rc.d/init.d/nginx restart

= = php

Cd / usr/local/src

Wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz

Wget http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

Wget ftp://sunsite.unc.edu/pub/Linux/libs/graphics/t1lib-5.1.2.tar.gz

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

Wget https://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2

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

Wget ftp://ftp.simplesystems.org/pub/png/src/libpng16/libpng-1.6.12.tar.gz

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

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

Wget http://cn2.php.net/distributions/php-5.5.31.tar.gz

Wget http://pecl.php.net/get/redis-2.2.4.tgz

Wget http://pecl.php.net/get/mongo-1.6.12.tgz

Wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz # memcached service dependency

Wget http://www.memcached.org/files/memcached-1.4.25.tar.gz

Wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz # memcached extension dependency

Wget http://pecl.php.net/get/memcached-2.2.0.tgz

Tar-zxvf yasm-1.2.0.tar.gz

Cd yasm-1.2.0

. / configure

Make

Make install

Tar-zxvf libmcrypt-2.5.8.tar.gz

Cd libmcrypt-2.5.8

. / configure

Make

Make install

Tar xvf libvpx-v1.3.0.tar.bz2

Mkdir / usr/local/libvpx

Cd libvpx-v1.3.0

. / configure-- prefix=/usr/local/libvpx-- enable-shared-- enable-vp9

Make

Make install

Tar-zxvf tiff-4.0.3.tar.gz

Mkdir / usr/local/tiff

Cd tiff-4.0.3

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

Make

Make install

Tar-zxvf libpng-1.6.12.tar.gz

Mkdir / usr/local/libpng

Cd libpng-1.6.12

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

Make

Make install

Tar-zxvf freetype-2.5.3.tar.gz

Mkdir / usr/local/freetype

Cd freetype-2.5.3

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

Make

Make install

Tar-zxvf jpegsrc.v9a.tar.gz

Mkdir / usr/local/jpeg

Cd jpeg-9a

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

Make

Make install

Tar-zxvf libgd-2.1.0.tar.gz

Mkdir / usr/local/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-- with-vpx=/usr/local/libvpx

Make

Make install

Tar-zxvf t1lib-5.1.2.tar.gz

Mkdir / usr/local/t1lib

Cd t1lib-5.1.2

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

Make without_doc # if you want to use make, you need to install latex:yum-y install tetex-latex first

Make install

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

\ cp-frp / usr/lib64/libXpm.so* / usr/lib/

Tar-zxvf php-5.5.31.tar.gz

Cd php-5.5.31

Export LD_LIBRARY_PATH=/usr/local/libgd/lib

/ configure-- prefix=/usr/local/php-- with-config-file-path=/usr/local/php/etc-- with-mysql=/usr/local/mysql-- with-mysqli=/usr/local/mysql/bin/mysql_config-- with-mysql-sock=/tmp/mysql.sock-- with-pdo-mysql=/usr/local/mysql-- with-gd-- with-png-dir=/usr/local/libpng-- with-jpeg-dir=/usr/local/jpeg-- with-freetype- Dir=/usr/local/freetype-with-xpm-dir=/usr/-with-vpx-dir=/usr/local/libvpx/-with-zlib-dir=/usr/local/zlib-with-t1lib=/usr/local/t1lib-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-mcrypt with-curl enable-ctype

Make # if out of undefined reference to libiconv_open, use make ZEND_EXTRA_LIBS='-liconv'

Make install

Cp php.ini-production / usr/local/php/etc/php.ini # copy the php configuration file to the installation directory

Rm-rf / etc/php.ini # Delete the configuration file that comes with the system

Ln-s / usr/local/php/etc/php.ini / etc/php.ini # add soft link to / etc directory

Cp / usr/local/php/etc/php-fpm.conf.default / usr/local/php/etc/php-fpm.conf # copy template file as php-fpm configuration file

Ln-s / usr/local/php/etc/php-fpm.conf / etc/php-fpm.conf # add a soft connection to the / etc directory

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

Pid = run/php-fpm.pid # cancel the previous semicolon

User = www # set the php-fpm running account to www

Group = www # set the php-fpm running group to www

: wq! # Save exit

Cp / usr/local/src/php-5.5.31/sapi/fpm/init.d.php-fpm / etc/rc.d/init.d/php-fpm # copy php-fpm to the startup directory

Chmod + x / etc/rc.d/init.d/php-fpm

Chkconfig php-fpm on

Vi / usr/local/php/etc/php.ini

# Edit the configuration file and list the functions that can be disabled by PHP. If some programs need to use this function, you can delete it and undisable it.

Find: disable_functions =

Modified to: disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups Posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname

Find:; date.timezone = modify to: date.timezone = PRC # set time zone

Found: expose_php = On modified to: expose_php = Off # suppress the display of php version information

Found: short_open_tag = Off modified to: short_open_tag = On # support php short tags

Found: opcache.enable=0 modified to: opcache.enable=1 # php supports opcode cache

Found: opcache.enable_cli=1 modified to: opcache.enable_cli=0 # php supports opcode cache

Add: zend_extension=opcache.so # to [opcache] to enable opcode caching

: wq!

Vi / usr/local/nginx/conf/nginx.conf # configure nginx to support php, with the following modifications

The first line of user www www; # user is uncommented, and the Nginx running group is changed to www www;. It must be the same as the user,group configuration in / usr/local/php/etc/php-fpm.conf, otherwise there will be errors in php operation.

Index index.html index.htm index.php; # add index.php

Uncomment part of the location in FastCGI server and note that the parameter on the fastcgi_param line is changed to $document_root$fastcgi_script_name, or use the absolute path

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

Location ~\ .php$ {

Root html

Fastcgi_pass 127.0.0.1:9000

Fastcgi_index index.php

Fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name

Include fastcgi_params

}

: wq!

Vi / etc/php-fpm.conf # adjusts the number of concurrent request processing according to memory (grep MemTotal / proc/meminfo | cut-f2-d:). Each php-fpm process takes up about 20m of physical memory. It is useless to increase it alone, so you need to adjust the configuration of spare_server accordingly.

Pm.max_children = 20

Pm.start_servers = 8 # start_servers = min_spare_servers + (max_spare_servers-min_spare_servers) / 2

Pm.min_spare_servers = 4

Pm.max_spare_servers = 12

# * install extension php-openssl

Cd / usr/local/src/php-5.5.31/ext/openssl/

Mv config0.m4 config.m4

/ usr/local/php/bin/phpize

. / configure-with-openssl-with-php-config=/usr/local/php/bin/php-config

Make

Make install

Vi / usr/local/php/etc/php.ini

Join extension= "openssl.so"

# * install extension php-redis

Tar-zxvf redis-2.2.4.tgz

Cd redis-2.2.4

/ usr/local/php/bin/phpize

Configuring for:

PHP Api Version: 20041225

Zend Module Api No: 20060613

Zend Extension Api No: 220060519

If it appears:

Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable is set correctly and then rerun this script.

Solve it in the following ways:

# wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz

# tar-zvxf M4-1.4.9.tar.gz

# cd M4-1.4.9 /

#. / configure & & make & & make install

# cd.. /

# wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz

# tar-zvxf autoconf-2.62.tar.gz

# cd autoconf-2.62/

#. / configure & & make & & make install

. / configure-- with-php-config=/usr/local/php/bin/php-config

Make

Make install

Vi / usr/local/php/etc/php.ini

Join extension= "redis.so"

# all so compiled in this way should appear in this path / usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/

# * install extension mongodb database driver

Tar-zxvf mongo-1.6.12.tgz

Cd mongo-1.6.12

/ usr/local/php/bin/phpize

. / configure-- with-php-config=/usr/local/php/bin/php-config

Make

Make install

Vi / usr/local/php/etc/php.ini

Join extension= "mongo.so"

# * install memcache service and memcached extension

Tar-zxvf libevent-2.0.22-stable.tar.gz

Cd libevent-2.0.22-stable

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

Make

Make install

Tar-zxvf memcached-1.4.25.tar.gz

Mv memcached-1.4.25 memcached-svr-1.4.25

Cd memcached-svr-1.4.25

. / configure-prefix=/usr/local/memcached-with-libevent=/usr/local/libevent

Make

Make install

Vi / etc/init.d/memcached

# # start the script and add the following

#! / bin/bash

#

# memcached start/stop the memcached daemon

#

# chkconfig: 35 80 70

# description: memcached is a memory cache server.

#

Prog= "memcached"

Exec=/usr/local/memcached/bin/memcached

Lockfile=/var/lock/subsys/memcached

# source function library.

. / etc/rc.d/init.d/functions

Start () {

If [$UID-ne 0]; then

Echo "User has insufficient privilege."

Exit 4

Fi

[- x $exec] | | exit 5

Echo-n $"starting $prog:"

Daemon $exec-u root-d-P / var/run/memcached.pid

Retval=$?

Echo

[$retval-eq 0] & & touch $lockfile

}

Stop () {

If [$UID-ne 0]; then

Echo "User has insufficient privilege."

Exit 4

Fi

Echo-n $"Stopping $prog:"

If [- n "``pidfileofproc $exec`"]; then

Killproc $exec

Else

Failure $"stopping $prog"

Fi

Retval=$?

Echo

[$retval-eq 0] & & rm-f $lockfile

}

Restart () {

Stop

Start

}

Rh_status () {

# run checks to determine if the service is running or use generic status

Status $prog

}

Rh_status_q () {

Rh_status > / dev/null 2 > & 1

}

Case "$1" in

"start")

Rh_status_q & & exit 0

, 1

"stop")

Rh_status_q | | exit 0

, 1

"restart")

Rh_status_q | | exit 7

, 1

"status")

Rh_status

*)

Echo $"Usage: $0 {start | stop | status | restart}"

Exit 2

Esac

Exit $?

: wq!

Chmod 755 / etc/init.d/memcached

Chkconfig memcached on

Tar-zxvf libmemcached-1.0.18.tar.gz

Cd libmemcached-1.0.18

. / configure-prefix=/usr/local/libmemcached-with-memcached=/usr/local/memcached/bin/memcached

Make

Make install

Tar-zxvf memcached-2.2.0.tgz

Mv memcached-2.2.0 memcached-so-2.2.0

Cd memcached-so-2.2.0

/ usr/local/php/bin/phpize

. / configure-- with-php-config=/usr/local/php/bin/php-config-- with-libmemcached-dir=/usr/local/libmemcached-- disable-memcached-sasl

Make

Make install

Vi / usr/local/php/etc/php.ini

Join extension= "memcached.so"

/ etc/init.d/nginx restart # restart nginx

Service php-fpm start # launch php-fpm

# * Test nginx+php

Cd / usr/local/nginx/html/ # enter the nginx default website root directory

Rm-rf / usr/local/nginx/html/* # Delete the default test page

Vi index.php

: wq!

Chown-R www.www / usr/local/nginx/html/

Chmod 700 / usr/local/nginx/html/-R

# Open the server IP address in the browser and you will see the interface of php

= MongoDB

Cd / usr/local/src

Wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.1.tgz

Tar-zxvf mongodb-linux-x86_64-rhel70-3.2.1.tgz

Mv / usr/local/src/mongodb-linux-x86_64-rhel70-3.2.1 / usr/local/mongodb # running directory

Groupadd mongodb

Useradd-g mongodb mongodb-s / bin/false

Mkdir-p / home/mongodb/db # data directory

Mkdir-p / home/mongodb/log # log directory

Chown-R mongodb:mongodb / usr/local/mongodb

Chown-R mongodb:mongodb / home/mongodb

Vi / usr/local/mongodb/mongodb.conf

Port=27017

Pidfilepath=/usr/local/mongodb/mongo.pid

Fork=true

Directoryperdb=true

Dbpath=/home/mongodb/db

Logpath=/home/mongodb/log/mongodb.log

Logappend=true

Shardsvr=true

# auth=true # enable authentication

# bind_ip=192.168.1.18 # Listen to local interface only. Comment out to listen on all interfaces.

: wq!

Vi / etc/rc.d/init.d/mongod

# # start the script and add the following

#! / bin/sh

# chkconfig:-64 36

# description:mongodb 3.2.1

Case $1 in

Start)

/ usr/local/mongodb/bin/mongod-maxConns 20000-config / usr/local/mongodb/mongodb.conf

Stop)

/ usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin-- eval "db.shutdownServer ()"

Status)

/ usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin-- eval "db.stats ()"

Esac

: wq!

Chmod 755 / etc/rc.d/init.d/mongod

Chkconfig mongod on

Service mongod start

Vi / etc/profile # add the environment variable and add the following code on the last line

Export PATH=$PATH:/usr/local/mongodb/bin

: wq!

Source / etc/profile # makes the configuration effective immediately

# start MongoDB mode 1

/ usr/local/mongodb/bin/mongod-port 27017-fork-dbpath=/home/mongodb/db/-logpath=/home/mongodb/log/mongodb.log-logappend

Netstat-lanp | grep "27017" # check whether MongoDB is started

Cd / usr/local/mongodb/bin/

. / mongo # enter the MongoDB database console

Use admin # access to admin database

Db.shutdownServer () # shut down the MongoDB database

Exit # exit

# start MongoDB mode 2

Mongo # enter the MongoDB console

Show dbs # View default database

Use admin # switch to admin database

Exit # exit the MongoDB console

# start MongoDB mode 3

Cd / usr/local/mongodb/bin/

. / mongod-- config / usr/local/mongodb/mongodb.conf # launch MongoDB

. / mongo 127.0.0.1:27017/admin-- eval "db.shutdownServer ()" # close MongoDB

# indexing

> mongo db.table01.ensureIndex ({"myid": 1})

= sphinx

Cd / usr/local/src

Wget http://sphinxsearch.com/files/sphinx-2.2.8-release.tar.gz

Tar-zxvf sphinx-2.2.8-release.tar.gz

Mv / usr/local/src/sphinx-2.2.8-release / usr/local/sphinx

Cd / usr/local/sphinx

. / configure-prefix=/usr/local/sphinx-with-mysql

# if the following appears, you can proceed to the next step:

Configuration done

-

You can now run 'make install' to...

The installation of make & & make install # is over. Go to the / usr/local directory to see if there is the Sphinx directory you just specified. The installation is successful.

# if an error occurs in undefined reference to libiconv during make:

/ usr/local/sphinx/src/sphinx.cpp:20060:undefined reference to `libiconv_open'

/ usr/local/sphinx/src/sphinx.cpp:20078: undefined reference to `libiconv'

/ usr/local/sphinx/src/sphinx.cpp:20084: undefined reference to `libiconv_close'

Collect2: ld returned 1exit status

Make [2]: * * [indexer] Error1

Make [2]: Leaving directory `/ home/sphinx/src'

Make [1]: * * [all] Error 2

Make [1]: Leaving directory `/ home/sphinx/src'

Make: * * [all-recursive] Error 1

Solution: open the configure file, find "# define USE_LIBICONV 1", remove the comment, and change 1 to 0.

Execute:

# make clean

# make & & make install

# create index files and storage directories

Mkdir / home/sphinx

Mkdir / home/sphinx/indexdelta # create incremental index storage directory

Useradd sphxrun # does not run using root

Chown sphxrun:sphxrun-R / home/sphinx

Chown sphxrun:sphxrun-R / usr/local/sphinx/var

Vi / usr/local/sphinx/etc/sphinx.conf # modifies the data storage directory of the corresponding index

: wq!

Vi / etc/rc.d/init.d/sphinx

# start the script and add the following, [!! Attention! Start the account as the newly created user "sphxrun"]

#! / bin/sh

# sphinx: Startup script for Sphinx search

#

# chkconfig: 345 86 14

# description: This is a daemon for high performance full text\

# search of MySQL and PostgreSQL databases. \

# See http://www.sphinxsearch.com/ for more info.

#

# processname: searchd

# pidfile: $sphinxlocation/var/log/searchd.pid

# Source function library.

. / etc/rc.d/init.d/functions

Processname=searchd

Servicename=sphinx

Sphinxlocation=/usr/local/sphinx

Pidfile=$sphinxlocation/var/log/searchd.pid

Searchd=$sphinxlocation/bin/searchd

Indexer=$sphinxlocation/bin/indexer

Cfgfile=$sphinxlocation/etc/sphinx.conf

RETVAL=0

PATH=$PATH:$sphinxlocation/bin

Start () {

Su-sphxrun-c "$searchd-c $cfgfile > / dev/null 2 > & 1"

Ret=$?

If [$ret-eq 0]; then

Action $"Starting Sphinx:" / bin/true

Else

Action $"Starting Sphinx:" / bin/false

Fi

Return $ret

}

Stop () {

Echo-n $"Stopping Sphinx daemon:"

Su-sphxrun-c "$searchd-config $cfgfile-stop"

# killproc-p $pidfile $servicename-TERM

RETVAL=$?

Echo

If [$RETVAL-eq 0]; then

Rm-f / var/lock/subsys/$servicename

Rm-f $pidfile

Fi

}

Indexer () {

Su-sphxrun-c "$indexer-- config $cfgfile-- all-- rotate > / dev/null 2 > & 1"

Ret=$?

If [$ret-eq 0]; then

Action $"sphinx making index:" / bin/true

Else

Action $"sphinx making index:" / bin/false

Fi

Return $ret

}

# See how we were called.

Case "$1" in

Start)

Start

Stop)

Stop

Status)

Status $processname

RETVAL=$?

Restart)

Stop

Sleep 3

Start

Sleep 3

Indexer)

Indexer

Condrestart)

If [- f / var/lock/subsys/$servicename]; then

Stop

Sleep 3

Start

Sleep 3

Fi

*)

Echo $"Usage: $0 {start | stop | status | restart | indexer | condrestart}"

Esac

Exit $RETVAL

: wq!

Chmod 755 / etc/rc.d/init.d/sphinx

Chkconfig sphinx on

# if the sphinx file is too large, delete the corresponding storage directory file

Cd / home/sphinx/

Rm *-fr

Mkdir indexdelta

# if a searchd.pid error is prompted, perform the next two steps

Vi / usr/local/sphinx/var/log/searchd.pid

Write 11770

= jvm

Yum search java # find the appropriate version and execute install

Yum install-y java-1.8.0-openjdk-devel

Java-version

Vi / etc/profile

Export JAVA_HOME=/usr/lib/jvm/java-1.8.0

Export JRE_HOME=$ {JAVA_HOME} / jre

Export CLASSPATH=.:$ {JAVA_HOME} / lib:$ {JRE_HOME} / lib

Export PATH=$ {JAVA_HOME} / bin:$PATH

Source / etc/profile

= redis server

Cd / usr/local/src

Wget http://download.redis.io/releases/redis-3.0.6.tar.gz

Tar-zxvf redis-3.0.6.tar.gz

Cd redis-3.0.6

If make MALLOC=libc # does not add parameters, an error will be reported under linux. It has not been tried. Anyway, it is compiled with parameters.

Make test

Make install # copy the executable to the / usr/local/bin directory

Mkdir / home/redis # data data and log log directory

. / utils/install_server.sh # question-and-answer configuration is as follows. Execute the script to make Redis start with the system.

# # #

Selected config:

Port: 6379

Config file: / etc/redis/6379.conf

Log file: / home/redis/log/redis_6379.log

Data dir: / home/redis/6379

Executable: / usr/local/bin/redis-server

Cli Executable: / usr/local/bin/redis-cli

# # #

Chkconfig-- list # check whether the boot is started or not

# Test

Redis-cli

127.0.0.1 purl 6379 > set foo bar

OK

127.0.0.1 purl 6379 > get foo

"bar"

Src/redis-server & # start redis (start the server in the background)

Src/redis-cli shutdown # turn off redis

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