首页 > 系统 > CentOS > 正文

CentOS7安装LNMP+Mongodb环境

2024-06-28 16:03:00
字体:
来源:转载
供稿:网友

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

====================================== CentOS configsystemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall开机启动yum install -y iptables-servicesvi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 27017 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 9312 -j ACCEPT:wq! #保存退出systemctl restart iptables.service systemctl enable iptables.service vi /etc/selinux/config  #关闭SELINUX#SELINUX=enforcing #注释掉#SELINUXTYPE=targeted #注释掉SELINUX=disabled #增加:wq! #保存退出setenforce 0 #使配置立即生效# 修改时间,如果安装时改了时区则略过datetimedatectltimedatectl set-timezone Asia/Shanghaidatehwclock --showhwclock --set --date '2016-01-27 00:24:10' hwclock --hctosysclock -wshutdown -r now# 注意,以下每步wget的安装包都存放到/usr/local/src;因为部分用到的安装包需要翻出去下载,不能翻的可在网盘地址【http://pan.baidu.com/s/1boBJxd9】中下载。============================================= cmakeyum 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-develyum -y install imake mysql-develyum -y install net-toolsyum -y install wgetcd /usr/local/srcwget http://www.cmake.org/files/v2.8/cmake-2.8.11.2.tar.gztar -zxvf cmake-2.8.11.2.tar.gzcd cmake-2.8.11.2./configuremakemake install============================================= mysql cd /usr/local/srcwget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.10.tar.gzgroupadd mysql #添加mysql组useradd -g mysql mysql -s /bin/false #创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统mkdir -p /home/mysql/data #创建MySQL数据库存放目录chown -R mysql:mysql /home/mysql/datamkdir -p /usr/local/mysqltar -zxvf mysql-5.7.10.tar.gzcd mysql-5.7.10# 配置,解决CMake Error,如果已经下载boost则执行以下操作,否则将以下cmake的-DDOWNLOAD_BOOST=0变为1mkdir /usr/local/boostcp /usr/local/src/boost_1_59_0.tar.gz /usr/local/boost/boost_1_59_0.tar.gzcd /usr/local/boosttar -zxvf boost_1_59_0.tar.gzcd /usr/local/src/mysql-5.7.10cmake . -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/boostmakemake installcd /usr/local/mysql # 执行以下初始化命令前保证 /home/mysql/data 下无任何文件和目录!bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/home/mysql/datamkdir -p /home/mysql/data/undolog  # undo存放空间,必须安装时设置innodb_undo_directory、innodb_undo_tablespaces,非必要用途chown -R mysql:mysql /home/mysql/data/undolog# 建立配置文件,如果需要主从复制或者集群,参见另篇博文的mysql部署cp support-files/my-default.cnf /etc/my.cnfvi /etc/my.cnf[mysqld]character_set_server=utf8init_connect='SET NAMES utf8'net_buffer_length=4Mmax_allowed_packet=300Mexpire_logs_days=15#undo(ibdata) para set oninnodb_undo_log_truncate=ONinnodb_undo_directory=/home/mysql/data/undologinnodb_undo_tablespaces=4innodb_max_undo_log_size=10G[client]#default-character-set=utf8    #此项最好不添加:wq! #保存退出cp support-files/mysql.server /etc/rc.d/init.d/mysqld  #复制启动脚本到init.d下,而且/etc/init.d与/etc/rc.d/init.d已经建立链接chmod 755 /etc/init.d/mysqld chkconfig mysqld on vi /etc/rc.d/init.d/mysqldbasedir=/usr/local/mysql #MySQL程序安装路径datadir=/home/mysql/data #MySQl数据库存放目录:wq! #保存退出systemctl start mysqld.service #启动 service mysqld startvi /etc/profile #把mysql服务加入系统环境变量:在最后添加下面这一行export PATH=$PATH:/usr/local/mysql/bin:wq! #保存退出source /etc/profile# 下面这两行把myslq的库文件链接到系统默认的位置,这样你在编译类似PHP等软件时可以不用指定mysql的库文件地址。ln -s /usr/local/mysql/lib /usr/lib/mysqlln -s /usr/local/mysql/include/mysql /usr/include/mysqlmkdir /var/lib/mysql #创建目录ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock #添加软链接mysql_secure_installation #(!坑人,不建议执行!)设置Mysql密码,根据提示按Y 回车输入2次密码,不要使用默认生成密码的方式,记不住alter user 'root'@'localhost' identified by 'sa'; #或者按这个改默认密码GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'sa' WITH GRANT OPTION; #允许root远程登录,改密码为'sa'flush privileges;# 如果安装后修改data存放,则需——service mysqld stopmkdir /home/mysql/data  #mysql用户的目录中建立数据目录datacd /data/mysql #原数据目录cp -R * /home/mysql/datachown -R mysql:mysql /home/mysql/datavi /etc/rc.d/init.d/mysqlddatadir=/home/mysql/data:wq!service mysqld start============================================= nginxcd /usr/local/srcwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gzwget http://www.openssl.org/source/openssl-1.0.1h.tar.gzwget http://zlib.net/zlib-1.2.8.tar.gzwget https://github.com/pagespeed/ngx_pagespeed/archive/v1.8.31.4-beta.tar.gzwget https://dl.google.com/dl/page-speed/psol/1.8.31.4.tar.gzwget http://nginx.org/download/nginx-1.8.0.tar.gztar -zxvf pcre-8.35.tar.gzmkdir /usr/local/pcrecd pcre-8.35./configure --prefix=/usr/local/pcremakemake installtar -zxvf openssl-1.0.1h.tar.gzmkdir /usr/local/opensslcd openssl-1.0.1h./config --prefix=/usr/local/opensslmakemake installvi /etc/profileexport PATH=$PATH:/usr/local/openssl/bin:wq!source /etc/profiletar -zxvf zlib-1.2.8.tar.gzmkdir /usr/local/zlibcd zlib-1.2.8./configure --prefix=/usr/local/zlibmakemake installtar -zxvf v1.8.31.4-beta.tar.gzcp 1.8.31.4.tar.gz ./ngx_pagespeed-1.8.31.4-betacd ngx_pagespeed-1.8.31.4-betatar -xzvf 1.8.31.4.tar.gzgroupadd wwwuseradd -g www www -s /bin/falsetar -zxvf nginx-1.8.0.tar.gzmkdir /usr/local/nginxchown -R www:www /usr/local/nginxcd 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#注意:--with-openssl --with-zlib --with-pcre --add-module 指向的是源码包解压的路径,而不是安装的路径,否则会报错makemake install/usr/local/nginx/sbin/nginxvi /etc/rc.d/init.d/nginx   ###################### 启动脚本,添加以下内容#!/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 0nginx="/usr/local/nginx/sbin/nginx"prog=$(basename $nginx)NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginxlockfile=/var/lock/subsys/nginxmake_dirs() {# make required directoriesuser=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=/([^ ]*/).*//1/g' -`if [ -z "`grep $user /etc/passwd`" ]; thenuseradd -M -s /bin/nologin $userfioptions=`$nginx -V 2>&1 | grep 'configure arguments:'`for opt in $options; doif [ `echo $opt | grep '.*-temp-path'` ]; thenvalue=`echo $opt | cut -d "=" -f 2`if [ ! -d "$value" ]; then# echo "creating" $valuemkdir -p $value && chown -R $user $valuefifidone}start() {[ -x $nginx ] || exit 5[ -f $NGINX_CONF_FILE ] || exit 6make_dirsecho -n $"Starting $prog: "daemon $nginx -c $NGINX_CONF_FILEretval=$?echo[ $retval -eq 0 ] && touch $lockfilereturn $retval}stop() {echo -n $"Stopping $prog: "killproc $prog -QUITretval=$?echo[ $retval -eq 0 ] && rm -f $lockfilereturn $retval}restart() {#configtest || return $?stopsleep 1start}reload() {#configtest || return $?echo -n $"Reloading $prog: "killproc $nginx -HUPRETVAL=$?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" instart)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 2esac:wq! chmod 755 /etc/rc.d/init.d/nginx chkconfig nginx on  #systemctl enable nginx , chkconfig --add nginxvi /usr/local/nginx/conf/nginx.confworker_processes  1             #根据cpu内核数(more /proc/cpuinfo|grep "model name")调整worker进程数,1个内核对应1个worker进程gzip  on;  #去掉注释  client_max_body_size 50M;    #增加该项解除上传限制过小的问题fastcgi_ignore_client_abort on; #放http段内,解决php fsockopen函数无效问题client_header_buffer_size 16k;  #放http段内,解决php fsockopen函数无效问题large_client_header_buffers 4 64k; #放http段内,解决php fsockopen函数无效问题:wq! /etc/rc.d/init.d/nginx restart========================================== php cd /usr/local/srcwget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gzwget http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gzwget ftp://sunsite.unc.edu/pub/Linux/libs/graphics/t1lib-5.1.2.tar.gzwget https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gzwget https://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2wget http://download.osgeo.org/libtiff/tiff-4.0.3.tar.gzwget ftp://ftp.simplesystems.org/pub/png/src/libpng16/libpng-1.6.12.tar.gzwget http://ring.u-toyama.ac.jp/archives/graphics/freetype/freetype2/freetype-2.5.3.tar.gzwget http://www.ijg.org/files/jpegsrc.v9a.tar.gzwget http://cn2.php.net/distributions/php-5.5.31.tar.gzwget http://pecl.php.net/get/redis-2.2.4.tgzwget http://pecl.php.net/get/mongo-1.6.12.tgzwget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz    #memcached服务依赖wget http://www.memcached.org/files/memcached-1.4.25.tar.gzwget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz     #memcached扩展依赖wget http://pecl.php.net/get/memcached-2.2.0.tgztar -zxvf yasm-1.2.0.tar.gzcd yasm-1.2.0./configuremakemake installtar -zxvf libmcrypt-2.5.8.tar.gzcd libmcrypt-2.5.8./configuremakemake installtar xvf libvpx-v1.3.0.tar.bz2mkdir /usr/local/libvpxcd libvpx-v1.3.0./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9makemake installtar -zxvf tiff-4.0.3.tar.gzmkdir /usr/local/tiffcd tiff-4.0.3./configure --prefix=/usr/local/tiff --enable-sharedmakemake installtar -zxvf libpng-1.6.12.tar.gzmkdir /usr/local/libpngcd libpng-1.6.12./configure --prefix=/usr/local/libpng --enable-sharedmakemake installtar -zxvf freetype-2.5.3.tar.gzmkdir /usr/local/freetypecd freetype-2.5.3./configure --prefix=/usr/local/freetype --enable-sharedmakemake installtar -zxvf jpegsrc.v9a.tar.gzmkdir /usr/local/jpegcd jpeg-9a./configure --prefix=/usr/local/jpeg --enable-sharedmakemake installtar -zxvf libgd-2.1.0.tar.gzmkdir /usr/local/libgdcd 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/libvpxmakemake install tar -zxvf t1lib-5.1.2.tar.gzmkdir /usr/local/t1libcd t1lib-5.1.2./configure --prefix=/usr/local/t1lib --enable-sharedmake without_doc  #如果想用make则需先装latex:yum -y install tetex-latexmake install/cp -frp /usr/lib64/libltdl.so*  /usr/lib//cp -frp /usr/lib64/libXpm.so* /usr/lib/tar -zxvf php-5.5.31.tar.gzcd php-5.5.31export 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-ctypemake  #如果出undefined reference to libiconv_open ,使用make ZEND_EXTRA_LIBS='-liconv'make install cp php.ini-production /usr/local/php/etc/php.ini  #复制php配置文件到安装目录rm -rf /etc/php.ini  #删除系统自带配置文件ln -s /usr/local/php/etc/php.ini /etc/php.ini   #添加软链接到 /etc目录cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf  #拷贝模板文件为php-fpm配置文件ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf  #添加软连接到 /etc目录vi /usr/local/php/etc/php-fpm.confpid = run/php-fpm.pid #取消前面的分号user = www #设置php-fpm运行账号为wwwgroup = www #设置php-fpm运行组为www:wq! #保存退出cp /usr/local/src/php-5.5.31/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm   #拷贝php-fpm到启动目录chmod +x /etc/rc.d/init.d/php-fpmchkconfig php-fpm onvi /usr/local/php/etc/php.ini#编辑配置文件,列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。找到:disable_functions =修改为: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找到:;date.timezone = 修改为:date.timezone = PRC #设置时区找到:expose_php = On 修改为:expose_php = Off #禁止显示php版本的信息找到:short_open_tag = Off 修改为:short_open_tag = On #支持php短标签找到:opcache.enable=0 修改为:opcache.enable=1 #php支持opcode缓存找到:opcache.enable_cli=1 修改为:opcache.enable_cli=0 #php支持opcode缓存在[opcache]添加:zend_extension=opcache.so #开启opcode缓存功能:wq! vi /usr/local/nginx/conf/nginx.conf    #配置nginx支持php, 做如下修改user www www; #首行user去掉注释,修改Nginx运行组为www www;必须与/usr/local/php/etc/php-fpm.conf中的user,group配置相同,否则php运行出错index index.html index.htm index.php; #添加index.php取消FastCGI server部分location的注释,注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径# 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       # 根据内存(grep MemTotal /proc/meminfo | cut -f2 -d:)调整并发请求处理数,每个php-fpm进程占用20m左右物理内存;单独调高无用,需要对应调整spare_server的配置。pm.max_children = 20pm.start_servers = 8       # start_servers = min_spare_servers + (max_spare_servers - min_spare_servers) / 2pm.min_spare_servers = 4pm.max_spare_servers = 12#******* 安装扩展php-opensslcd /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-configmakemake installvi /usr/local/php/etc/php.ini加入 extension="openssl.so"#******* 安装扩展php-redistar -zxvf redis-2.2.4.tgzcd redis-2.2.4/usr/local/php/bin/phpizeConfiguring for:PHP Api Version:         20041225Zend Module Api No:      20060613Zend Extension Api No:   220060519 如果出现:Cannot find autoconf. Please check your autoconf installation and the  $PHP_AUTOCONF  environment variable is set correctly and then rerun this script.用下面的方法解决:# 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 makemake installvi /usr/local/php/etc/php.ini加入 extension="redis.so"# 所有此般编译后的so都应出现在该路径/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/#******* 安装扩展mongodb database drivertar -zxvf mongo-1.6.12.tgzcd mongo-1.6.12/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmakemake installvi /usr/local/php/etc/php.ini加入 extension="mongo.so"#******* 安装memcache服务与memcached扩展tar -zxvf libevent-2.0.22-stable.tar.gzcd libevent-2.0.22-stable./configure --prefix=/usr/local/libeventmakemake installtar -zxvf memcached-1.4.25.tar.gzmv memcached-1.4.25 memcached-svr-1.4.25cd memcached-svr-1.4.25./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libeventmakemake installvi /etc/init.d/memcached###################### 启动脚本,添加以下内容#! /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/memcachedlockfile=/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/memcachedchkconfig memcached ontar -zxvf libmemcached-1.0.18.tar.gzcd libmemcached-1.0.18./configure --prefix=/usr/local/libmemcached --with-memcached=/usr/local/memcached/bin/memcachedmakemake installtar -zxvf memcached-2.2.0.tgzmv memcached-2.2.0 memcached-so-2.2.0cd 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-saslmakemake installvi /usr/local/php/etc/php.ini加入 extension="memcached.so"/etc/init.d/nginx restart #重启nginxservice php-fpm start #启动php-fpm#******* 测试nginx+phpcd /usr/local/nginx/html/  #进入nginx默认网站根目录rm -rf /usr/local/nginx/html/*  #删除默认测试页vi index.php <?phpphpinfo();?>:wq! chown -R www.www /usr/local/nginx/html/chmod 700 /usr/local/nginx/html/ -R# 在浏览器中打开服务器IP地址,会看到php的界面============================================== MongoDBcd /usr/local/srcwget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.1.tgztar -zxvf mongodb-linux-x86_64-rhel70-3.2.1.tgzmv /usr/local/src/mongodb-linux-x86_64-rhel70-3.2.1 /usr/local/mongodb  #运行目录groupadd mongodbuseradd -g mongodb mongodb -s /bin/falsemkdir -p /home/mongodb/db  #数据目录mkdir -p /home/mongodb/log  #日志目录chown -R mongodb:mongodb /usr/local/mongodbchown -R mongodb:mongodb /home/mongodbvi /usr/local/mongodb/mongodb.confport=27017pidfilepath=/usr/local/mongodb/mongo.pidfork=truedirectoryperdb=truedbpath=/home/mongodb/dblogpath=/home/mongodb/log/mongodb.loglogappend=trueshardsvr=true#auth=true  #开启认证#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   ############################# 启动脚本,添加以下内容#!/bin/sh# chkconfig: - 64 36# description:mongodb 3.2.1case $1 instart)/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 onservice  mongod  startvi /etc/profile  #添加环境变量,在最后一行添加下面的代码export PATH=$PATH:/usr/local/mongodb/bin:wq! source /etc/profile  #使配置立即生效#启动MongoDB方式 1/usr/local/mongodb/bin/mongod --port 27017 --fork --dbpath=/home/mongodb/db/ --logpath=/home/mongodb/log/mongodb.log --logappendnetstat -lanp | grep "27017"  #查看MongoDB是否启动cd /usr/local/mongodb/bin/./mongo  #进入MongoDB数据库控制台use admin  #进入admin数据库db.shutdownServer()  #关闭MongoDB数据库exit #退出#启动MongoDB方式 2mongo  #进入MongoDB控制台show dbs #查看默认数据库use admin  #切换到admin数据库exit #退出MongoDB控制台#启动MongoDB方式 3cd /usr/local/mongodb/bin/./mongod --config /usr/local/mongodb/mongodb.conf  #启动MongoDB./mongo 127.0.0.1:27017/admin --eval "db.shutdownServer()"  #关闭MongoDB#建立索引>mongo db.table01.ensureIndex({"myid":1});============================================== sphinxcd /usr/local/srcwget http://sphinxsearch.com/files/sphinx-2.2.8-release.tar.gztar -zxvf sphinx-2.2.8-release.tar.gzmv /usr/local/src/sphinx-2.2.8-release /usr/local/sphinxcd /usr/local/sphinx./configure --prefix=/usr/local/sphinx  –-with-mysql# 出现下面的就可以进行下一步:configuration done-------------------You can now run 'make install' to ...make && make install    #安装结束,到/usr/local 目录看是否有刚才指定的Sphinx目录,有安装成功# 在make时如果出现undefined reference to libiconv的错误:/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 statusmake[2]:***[indexer]Error1make[2]:Leaving directory `/home/sphinx/src'make[1]: *** [all] Error 2make[1]: Leaving directory `/home/sphinx/src'make: *** [all-recursive] Error 1解决办法:打开configure文件,找到“#define USE_LIBICONV 1”,将注释去掉,并将1改成0。执行:#make clean#make && make install# 创建索引文件和存放目录mkdir /home/sphinxmkdir /home/sphinx/indexdelta   #创建增量索引存放目录useradd sphxrun  #不使用root运行chown sphxrun:sphxrun -R /home/sphinxchown sphxrun:sphxrun -R /usr/local/sphinx/varvi /usr/local/sphinx/etc/sphinx.conf   #修改对应索引的数据存放目录:wq!vi /etc/rc.d/init.d/sphinx #################### 启动脚本,添加以下内容,【!!!注意!!!启动账户为新建的用户“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/searchdindexer=$sphinxlocation/bin/indexercfgfile=$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# 如果sphinx文件太大,删除对应存放目录文件cd /home/sphinx/rm * -frmkdir indexdelta#如果提示searchd.pid错误,则执行下两步vi /usr/local/sphinx/var/log/searchd.pid写入11770============================================== jvmyum search java #找到合适的版本,然后执行installyum install -y java-1.8.0-openjdk-develjava -versionvi    /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 servercd /usr/local/srcwget http://download.redis.io/releases/redis-3.0.6.tar.gztar -zxvf redis-3.0.6.tar.gzcd redis-3.0.6make MALLOC=libc  #如果不加参数,linux下会报错,没试过,反正是加上了参数编译的make testmake install   #将可执行文件拷贝到/usr/local/bin目录mkdir /home/redis   #数据data和日志log目录./utils/install_server.sh   #问答式的配置如下,执行脚本使得Redis随系统启动###################################################Selected config:Port           : 6379Config file    : /etc/redis/6379.confLog file       : /home/redis/log/redis_6379.logData dir       : /home/redis/6379Executable     : /usr/local/bin/redis-serverCli Executable : /usr/local/bin/redis-cli###################################################chkconfig --list   #检查是否开机启动# 测试redis-cli127.0.0.1:6379> set foo barOK127.0.0.1:6379> get foo"bar"src/redis-server &   #启动redis (后台开启服务器)src/redis-cli shutdown   #关闭redis
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表