失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > Linux+Nginx+Apache+Atlas+Mysql+Php+Redis 分部式部署详细版

Linux+Nginx+Apache+Atlas+Mysql+Php+Redis 分部式部署详细版

时间:2022-05-10 14:59:25

相关推荐

Linux+Nginx+Apache+Atlas+Mysql+Php+Redis 分部式部署详细版

环境描述:

192.168.30.131 Nginx-

192.168.30.132

192.168.30.133

192.168.30.134

192.168.30.135

首先在Apache1和Apache2上部署Apache+Php:

1>【卸载系统自带的apache】

[html]view plaincopy

#查看apache是否己安装

rpm-qahttpd

#卸载

rpm-ehttpd--nodeps

2>【安装gcc, gcc-c++】

[html]view plaincopy

yuminstallgcc

yuminstallgcc-c++

3>【开放80、3306、22端口】

[html]view plaincopy

#关闭防火墙

serviceiptablesstop

vi/etc/sysconfig/iptables

#添加

-AINPUT-mstate--stateNEW-mtcp-ptcp--dport80-jACCEPT

-AINPUT-mstate--stateNEW-mtcp-ptcp--dport3306-jACCEPT

-AINPUT-mstate--stateNEW-mtcp-ptcp--dport22-jACCEPT

#重启防火墙

serviceiptablesrestart

4>【建立lamp/src目录, 将源码包上传】5>【安装libxml2】

[html]view plaincopy

tar-zxvflibxml2-2.6.30.tar.gz

cdlibxml2-2.6.30

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

make

makeinstall

6>【安装libmcrypt】

[html]view plaincopy

tar-zxvflibmcrypt-2.5.8.tar.gz

cdlibmcrypt-2.5.8

./configure--enable-ltdl-install

make

makeinstall

7>【安装zlib】

[html]view plaincopy

tar-zxvfzlib-1.2.3.tar.gz

cdzlib-1.2.3

./configure

make

makeinstall

8>【安装libpng】

[html]view plaincopy

tar-zxvflibpng-1.2.31.tar.gz

cdlibpng-1.2.31

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

make

mkdir -p /usr/loca/libpng/man/man1

makeinstall

9>【安装jpegsrc.v6b】

[html]view plaincopy

mkdir/usr/local/jpeg6

mkdir/usr/local/jpeg6/bin

mkdir/usr/local/jpeg6/lib

mkdir/usr/local/jpeg6/include

mkdir-p/usr/local/jpeg6/man/man1

tar-zxvfjpegsrc.v6b.tar.gz

cdjpeg-6b

./configure--prefix=/usr/local/jpeg6 --enable-shared--enable-static

make

makeinstall

[root@bogon jpeg-6b]#make; make install

./libtool --mode=compile gcc -O2 -I. -c ./jcapimin.c

make: ./libtool:命令未找到

make: *** [jcapimin.lo] 错误 127

./libtool --mode=compile gcc -O2 -I. -c ./cjpeg.c

make: ./libtool:命令未找到

make: *** [cjpeg.lo] 错误 127

解决办法:

首先看有没有安装libtool及 libtool-ltdl-devel

rpm -qa | grep libtool

错误分析:由于libtool版本过低导致的,重新下载新版本的libtool以默认方式安装,执行以下命令:./configure--prefix=/usr/local/libtoolmakemakeinstall

然后进入jpeg-6b的源码目录,然后执行以下步骤,切记!COPY到当前目录注意后面的点(.)

cp /usr/share/libtool/config/config.sub.

cp /usr/share/libtool/config/config.guess.

也就是把 libtool里面的两个配置文件拿来覆盖掉jpeg-6b目录下的对应文件

make clean 再重新configure

10>【安装freetype】

[html]view plaincopy

tar-zxvffreetype-2.3.5.tar.gz

cdfreetype-2.3.5

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

make &&makeinstall && echo OK && cd ..

11>【安装autoconf】

[html]view plaincopy

tar-zxvfautoconf-2.61.tar.gz

cdautoconf-2.61

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

make &&makeinstall && echo OK && cd ..

12>【安装gd】

[html]view plaincopy

tar-zxvfgd-2.0.35.tar.gz

cdgd-2.0.35

./configure--prefix=/usr/local/gd2--with-jpeg=/usr/local/jpeg6--with-freetype=/usr/local/freetype

make &&makeinstall && echo OK && cd ..

13>【安装apache】

[html]view plaincopy

tar-zxvfhttpd-2.2.9.tar.gz

cdhttpd-2.2.9

./configure--prefix=/usr/local/apache2--sysconfdir=/etc/httpd --with-included-apr--disable-userdir--enable-so--enable-deflate=shared--enable-expires=shared--enable-rewrite=shared--enable-static-support

make &&makeinstall && echo OK

#启动apache

/usr/local/apache2/bin/apachectlstart

#如果出现下面的错误,

#httpd:Couldnotreliablydeterminetheserver'sfullyqualifieddomainname,using::1forServerName

#修改配置文件

vi/etc/httpd/httpd.conf

#查找ServerName,将注释去掉

:80

#添加到自启动

echo"/usr/local/apache2/bin/apachectlstart">>/etc/rc.d/rc.sysinit

#将apache添加到系统服务中

cp/usr/local/apache2/bin/apachectl/etc/init.d/httpd

vi/etc/rc.d/init.d/httpd

#在#!/bin/sh后添加下面两行(包含"#")

#chkconfig:23458515

#description:Apache

#添加执行权限

chmod755/etc/init.d/httpd

#添加到系统服务中

chkconfig--addhttpd

#开启apache

servicehttpdstart

14>【安装ncurses】

[html]view plaincopy

tar-zxvfncurses-5.6.tar.gz

cdncurses-5.6

./configure --prefix=/usr/local/ncurses --with-shared--without-debug--without-ada--enable-overwrite

make &&makeinstall && echo OK && cd ..

15>【安装mysql】

[html]view plaincopy

groupaddmysql

useradd-gmysqlmysql

tar-zxvfmysql-5.1.59.tar.gz

cdmysql-5.1.59

./configure--prefix=/usr/local/mysql/--with-extra-charsets=all

make &&makeinstall && echo OK && cd ..

[html]view plaincopy

cpsupport-files/my-f/etc/f

/usr/local/mysql/bin/mysql_install_db--user=mysql

chown-Rroot/usr/local/mysql

chown-Rmysql/usr/local/mysql/var

chgrp-Rmysql/usr/local/mysql

/usr/local/mysql/bin/mysqld_safe--user=mysql&

cp/lamp/src/mysql-5.1.59/support-files/mysql.server/etc/rc.d/init.d/mysqld

chownroot.root/etc/rc.d/init.d/mysqld

chmod755/etc/rc.d/init.d/mysqld

chkconfig--addmysqld

chkconfig--listmysqld

chkconfig--levels245mysqldoff

[html]view plaincopy

#配置mysql

cd/usr/local/mysql

bin/mysqladminversion//简单的测试

bin/mysqladminVariables//查看所有mysql参数

bin/mysql-uroot//没有密码可以直接登录本机服务器

DELETEFROMmysql.userWHEREHost='localhost'ANDUser='';

FLUSHPRIVILEGES;

#设置root密码为123456

SETPASSWORDFOR'root'@'localhost'=PASSWORD('123456');

#配置可远程连接mysql

usemysql

SELECTuser,password,hostFROMuser;

DELETEFROMuserWHEREhost='localhsot.localdomain'

DELETEFROMuserWHEREhost='127.0.0.1';

UPDATEuserSEThost='%'WHEREuser='root';

#重启mysql

servicemysqldrestart

16>【安装php】

[html]view plaincopy

tar-zxvfphp-5.2.6.tar.gz

cdphp-5.2.6

./configure--prefix=/usr/local/php/--with-config-file-path=/usr/local/php/etc/--with-apxs2=/usr/local/apache2/bin/apxs--with-mysql=/usr/local/mysql/--with-libxml-dir=/usr/local/libxml2/--with-jpeg-dir=/usr/local/jpeg6/--with-freetype-dir=/usr/local/freetype/--with-gd=/usr/local/gd2/--with-mcrypt=/usr/local/libmcrypt/--with-mysqli=/usr/local/mysql/bin/mysql_config--enable-soap--enable-mbstring=all--enable-sockets

注:如果出现报错:

configure:error:GDbuildtestfailed.Pleasechecktheconfig.logfordeta

查看当前目录下的config.log中找到

发现错误如下:

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_destroy_decompress@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_CreateCompress@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_read_header@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_read_scanlines@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_start_compress@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_destroy_compress@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_set_quality@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_finish_decompress@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_set_defaults@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_write_marker@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_start_decompress@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_destroy@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_resync_to_restart@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_simple_progression@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_write_scanlines@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_save_markers@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_CreateDecompress@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_std_error@LIBJPEG_6.2'

/usr/local/gd2//lib/libgd.so:undefinedreferenceto`jpeg_finish_compress@LIBJPEG_6.2'

解决方法:

rm -rf /usr/local/gd

重新安装gd就行了,仔细点我的是在/usr/local/gd/后多了一个/

然后重新编译php就行了

如果还未解决,把--with-gd=/usr/local/gd2改成--with-gd 解决此问题!

make &&makeinstall && echo OK && cd ..

cpphp.ini-development/usr/local/php/etc/php.ini

17>【apache配置】

[html]view plaincopy

#建立工作目录

mkdir-p/var/www/html

#修改httpd.conf

vi/etc/httpd/httpd.conf

#功能:设置工作目录

#说明:搜索DocumentRoot,修改为

DocumentRoot"/var/www/html"

#功能:设置目录选项

#说明:搜索<Directory"/usr/local/apache2//htdocs">,修改为

<Directory"/var/www/html">

#功能:设置默认文档

#说明:搜索<IfModuledir_module>,修改为

DirectoryIndexindex.htmlindex.php

#功能:增加php类型

#说明:搜索AddTypeapplication/x-gzip.gz.tgz在后面添加

AddTypeapplication/x-httpd-php.html.php

功能:不允许访问目录

说明:搜索OptionsIndexesFollowSymLinks项并注释

#OptionsIndexesFollowSymLinks

#注意:修改配置文件后,重启apache才能生效

#重启apache

servicehttpdrestart

18>【添加PDO_MYSQL扩展】

[html]view plaincopy

cd/lamp/src/php-5.2.6/ext/pdo_mysql

/usr/local/php/bin/phpize

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

make

makeinstall

[html]view plaincopy

#执行完makeinstall后会生成

#Installingsharedextensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-0613/

#修改php.ini

vi/usr/local/php/etc/php.ini

#查找extension_dir,修改为

extension_dir="/usr/local/php/lib/php/extensions/no-debug-non-zts-0613/"

#添加pdo_mysql

extension=pdo_mysql.so

#重启apache

servicehttpdrestart

19>【apache虚拟主机配置】

[html]view plaincopy

#建立dev目录

mkdir-p/var/www/html/dev

cd/var/www/html/dev

viindex.php

#添加

<?php

phpinfo();

?>

#保存,退出

#打开httpd.conf

vi/etc/httpd/httpd.conf

#查找Include/etc/httpd//extra/httpd-vhosts.conf并取消注释

Include/etc/httpd//extra/httpd-vhosts.conf

#打开httpd-vhosts.conf

vi/etc/httpd//extra/httpd-vhosts.conf

#将下面几行注释

#<VirtualHost*:80>

#ServerAdminwebmaster@dummy-

#DocumentRoot"/usr/local/apache2//docs/dummy-"

#ServerNamedummy-

#ServerAliaswww.dummy-

#ErrorLog"logs/dummy--error_log"

#CustomLog"logs/dummy--access_log"common

#</VirtualHost>

#<VirtualHost*:80>

#ServerAdminwebmaster@dummy-

#DocumentRoot"/usr/local/apache2//docs/dummy-"

#ServerNamedummy-

#ErrorLog"logs/dummy--error_log"

#CustomLog"logs/dummy--access_log"common

#</VirtualHost>

#添加

<VirtualHost*:80>

ServerNamedev.dev

DocumentRoot"/var/www/html/dev"

<Directory"/var/www/html/dev/">

AllowOverrideAll

</Directory>

</VirtualHost>

#保存,退出

#重启apache

servicehttpdrestart

#修改hosts文件

vi/etc/hosts

#添加

127.0.0.1dev.devlocalhost

#保存,退出

#在浏览器输入http://dev.dev访问,查看能否输出php信息

Apache优化项:

找到以下代码并根据提示修改

<Directory/>

OptionsFollowSymLinks

AllowOverrideAll

Orderdeny,allow

Denyfromall//这句改为Allowfromall

</Directory>

找到这一段并修改,以使Apache支持rewrite(伪静态):

#AllowOverridecontrolswhatdirectivesmaybeplacedin.htaccessfiles.

#Itcanbe"All","None",oranycombinationofthekeywords:

#OptionsFileInfoAuthConfigLimit

#

AllowOverrideNone

更改为

AllowOverrideAll

将以下代码注释掉,禁止目录列表:

OptionsIndexesFollowSymLinks

找到以下代码,修改用户为www

<IfModule!mpm_netware_module>

<IfModule!mpm_winnt_module>

Userdaemon//改为www

Groupdaemon//改为www

</IfModule>

</IfModule>

设置ServerAdminyou@改为你自己的mail地址

查找:

Listen80

改为

Listen81

分别找到以下四段代码,将之前的注释#去除:

Includeconf/extra/httpd-mpm.conf

Includeconf/extra/httpd-info.conf

Includeconf/extra/httpd-vhosts.conf

Includeconf/extra/httpd-default.conf

编辑Includeconf/extra/httpd-mpm.conf找到如下选项,并改成对应的数值

<IfModulempm_prefork_module>

StartServers5

MinSpareServers5

MaxSpareServers10

MaxClients150

MaxRequestsPerChild1000

</IfModule>

编辑conf/extra/httpd-default.conf

Timeout60#与nginx的保持一至

KeepAliveOn

MaxKeepAliveRequests1000

KeepAliveTimeout5

创建以下用户及文件夹:

groupadd www

useradd -gwww -s/sbin/nologin -M www

mkdir-p/usr/local/apache2/docs/dummy-

mkdir-p/usr/local/apache2/docs/dummy-

这样以后Apache启动、关闭、重启只需要输入以下命令:

servicehttpdstart/stop/restart

其次在Nginx-proxy上安装Nginx并做代理:

20 【Nginx安装】

yum -y install pcre-devel

wgethttp://download./releases/libunwind/libunwind-1.1.tar.gz

tar xflibunwind-1.1.tar.gz

cdlibunwind-1.1

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

make && make install && echo OK

yum -y install gperftool*

一般情况下 都没什么错误出现的。安装完成后还不能直接使用。得执行 ldconfig 重建系统动态链接库。

配置nginx和 google perftools :

mkdir /usr/local/nginx/tmp/tcmalloc && chown www:www/usr/local/nginx/tmp/tcmalloc

最后google_perftools 工具这样安装后还不能被Nginx调用。要给其指定该工具的动态链接库路径并重新加载系统动态链接库:

echo ‘/usr/local/gperftools/lib’>/etc/ld.so.conf.d/my_app_lib.conf

到这里。Google_perftools 工具已经安装完成,上面错误提示是在编译安装Nginx 1.4.7的时候出现的错误解决方法如图:

具体图文请参考:

编译安装 google_perftools :http://zlyang./1196234/1752207

wget/download/nginx-1.9.12.tar.gz

tar xf nginx-1.9.12.tar.gz

cd nginx-1.9.12

./configure--user=www--group=www--prefix=/usr/local/nginx--pid-path=/usr/local/nginx/logs/nginx.pid--error-log-path=/usr/local/nginx/logs/error.log--http-log-path=/usr/local/nginx/logs/access.log--with-http_stub_status_module--with-http_ssl_module--http-client-body-temp-path=/tmp/nginx_client--http-proxy-temp-path=/tmp/nginx_proxy--http-fastcgi-temp-path=/tmp/nginx_fastcgi--with-http_gzip_static_module--with-google_perftools_module--with-ld-opt='-ltcmalloc_minimal'--with-ipv6

make && make install && echo OK

修改配置文件:nginx.conf

#usernobody;

#worker_processes1;

#error_loglogs/error.log;

#error_loglogs/error.lognotice;

#error_loglogs/error.loginfo;

#pidlogs/nginx.pid;

#################NginxSetup######################

userwww;

worker_processes4;

error_loglogs/error.log;

pidlogs/nginx.pid;

google_perftools_profiles/usr/local/nginx/tmp/tcmalloc;

worker_rlimit_nofile51200;

events{

useepoll;

worker_connections51200;

}

http{

includemime.types;

default_typeapplication/octet-stream;

#log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'

#'$status$body_bytes_sent"$http_referer"'

#'"$http_user_agent""$http_x_forwarded_for"';

#access_loglogs/access.logmain;

#################NginxSetup###############

server_names_hash_bucket_size128;

client_header_buffer_size256k;

large_client_header_buffers4256k;

client_max_body_size50m;

client_body_buffer_size256k;

client_header_timeout3m;

client_body_timeout3m;

send_timeout3m;

sendfileon;

#tcp_nopushon;

tcp_nopushon;

tcp_nodelayon;

#keepalive_timeout0;

keepalive_timeout120;

#gzipon;

gzipon;

gzip_min_length1k;

gzip_buffers416k;

gzip_http_version1.0;

gzip_comp_level2;

gzip_varyon;

includevhost/*.conf;

####################loadbalancing####################

{ #负责均衡

server192.168.30.132:81; #Node节点

server192.168.30.133:81; #Node节点

}

server{

listen80;

;#网站域名

#charsetkoi8-r;

#access_loglogs/host.access.logmain;

location/{

proxy_pass; #网站域名

proxy_set_headerHost$host;

proxy_set_headerX-Real-IP$remote_addr;

proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;

}

#location/{

#roothtml;

#indexindex.htmlindex.htm;

#}

#error_page404/404.html;

#redirectservererrorpagestothestaticpage/50x.html

#

error_page500502503504/50x.html;

location=/50x.html{

roothtml;

}

#proxythePHPscriptstoApachelisteningon127.0.0.1:80

#

#location~\.php${

#proxy_passhttp://127.0.0.1;

#}

#passthePHPscriptstoFastCGIserverlisteningon127.0.0.1:9000

#

#location~\.php${

#roothtml;

#fastcgi_pass127.0.0.1:9000;

#fastcgi_indexindex.php;

#fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;

#includefastcgi_params;

#}

#denyaccessto.htaccessfiles,ifApache'sdocumentroot

#concurswithnginx'sone

#

#location~/\.ht{

#denyall;

#}

}

#anothervirtualhostusingmixofIP-,name-,andport-basedconfiguration

#

#server{

#listen8000;

#listensomename:8080;

#server_namesomenamealiasanother.alias;

#location/{

#roothtml;

#indexindex.htmlindex.htm;

#}

#}

#HTTPSserver

#

#server{

#listen443ssl;

#server_namelocalhost;

#ssl_certificatecert.pem;

#ssl_certificate_keycert.key;

#ssl_session_cacheshared:SSL:1m;

#ssl_session_timeout5m;

#ssl_ciphersHIGH:!aNULL:!MD5;

#ssl_prefer_server_cipherson;

#location/{

#roothtml;

#indexindex.htmlindex.htm;

#}

#}

}

重启nginx服务:

service nginx restart

安装 Redis:

wgethttp://download.redis.io/releases/redis-2.8.24.tar.gz

tar xfredis-2.8.24.tar.gz

ln -s redis-2.6.14 redis #建立一个链接

cdredis

make PREFIX=/usr/local/redis install #安装到指定目录中

注意上面的最后一行,我们通过PREFIX指定了安装的目录。如果make失败,一般是你们系统中还未安装gcc,那么可以通过yum安装:

yum -y install gcc*

将redis做成一个服务

cputils/redis_init_script /etc/rc.d/init.d/redis

vim /etc/rc.d/init.d/redis

在#!/bin/bash 下面加入以下代码:

#chkconfig: 2345 80 90

修改

EXEC=/usr/local/redis/bin/redis-server

CLIEXEC=/usr/local/redis/bin/redis-cli

在start)函数中修改:

$EXEC $CONF

为:

$EXEC $CONF &

保存退出

创建Redis的配置文件目录:

mkdir /etc/redis

find / -nameredis.conf

grep"REDISPORT="/etc/rc.d/init.d/redis

cp/soft/redis-2.8.24/redis.conf/etc/redis/6379.conf

chkconfig --add redis

将Redis的命令所在目录添加到系统参数PATH中

修改profile文件:

vi /etc/profile

在最后加入:

export PATH="$PATH:/usr/local/redis/bin"

启动Redis:

/usr/local/redis/bin/redis-server/etc/redis/6379.conf&

这样就可以直接调用redis-cli的命令了,如下所示:

$ redis-cli

redis 127.0.0.1:6379> auth superman

OK

redis 127.0.0.1:6379> ping

PONG

redis 127.0.0.1:6379>

至此,redis 就成功安装了。

如果在执行redis-cli中报错:

[root@Redis redis]# redis-cli

127.0.0.1:6379> auth superman

(error) ERR Client sent AUTH, but no password is set

原因是redis没有设置验证口令!

解决方法:

设置Redis密码:

vim /etc/redis/redis.conf

#requirepassfoobared

修改为:

requirepassauth密码

将redis写成服务脚本

vim /etc/init.d/redis

#!/bin/sh

#

#Author:Zlyang

#Date:-6-14

#

#chkconfig:23458090

#SimpleRedisinit.dscriptconceivedtoworkonLinuxsystems

#asitdoesuseofthe/procfilesystem.

#REDISPORT=6379

#EXEC=/usr/local/bin/redis-server

EXEC=/usr/local/redis/bin/redis-server

CLIEXEC=/usr/local/redis/bin/redis-cli

PID=`ps-ef|grep6379|grep-Ev"grep"|awk'{print$2}'`

PID_NUM=`ps-ef|grep6379|grep-Ev"grep"|awk'{print$2}'|wc-l`

#PIDFILE=/var/run/redis_${REDISPORT}.pid

#CONF="/etc/redis/${REDISPORT}.conf"

CONF="/etc/redis/redis.conf"

functionstart()

{

if["$PID_NUM"!=0]

then

echo"Redisserviceisalreadyrunning..."

else

echo"StartingRedisserver..."

$EXEC$CONF2>&1>/dev/null&

sleep1

if[`ps-ef|grep6379|grep-Ev"grep"|awk'{print$2}'|wc-l`!=0]

then

echo-e"StartRedisservice..............................[\E[1;32mOK\E[0m]"

fi

fi

}

functionstop()

{

if[$PID_NUM==0]

then

echo"Redisserviceisnotrunning!"

else

echo"WaitingforRedistostop..."

kill-9$PID

sleep1

echo-e"StopRedisservice...............................[\E[1;32mOK\E[0m]"

fi

}

case"$1"in

start)

start

;;

stop)

stop

;;

status)

if["$PID_NUM"!=0]

then

echo"Redisserviceisalreadyrunning..."

else

echo"Redisserviceisstoped!"

fi

;;

restart)

if["$PID_NUM"!=0]

then

stop

sleep1

echo"StartingRedisserver..."

$EXEC$CONF2>&1>/dev/null&

sleep1

if[`ps-ef|grep6379|grep-Ev"grep"|awk'{print$2}'|wc-l`!=0]

then

echo-e"StartRedisservice..............................[\E[1;32mOK\E[0m]"

fi

else

start

fi

;;

*)

echo-e"\E[1;35mUsage:/etc/init.d/redos{start|stop|status|restart|}\E[0m"

;;

esac

保存退出:

将redis添加为服务:

chkconfig --add redis

chkconfig redis on

如果觉得《Linux+Nginx+Apache+Atlas+Mysql+Php+Redis 分部式部署详细版》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。