环境描述:

192.168.30.131 Nginx-proxy.test.com

192.168.30.132 Apache1.test.com

192.168.30.133 Apache2.test.com

192.168.30.134 redis.test.com

192.168.30.135 MySQL.test.com

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

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

[html] view plain copy

  1. #查看apache是否己安装

  2. rpm -qa httpd

  3. #卸载

  4. rpm -e httpd --nodeps

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

[html] view plain copy

  1. yum install gcc

  2. yum install gcc-c++

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

[html] view plain copy

  1. #关闭防火墙

  2. service iptables stop

  3. vi /etc/sysconfig/iptables

  4. #添加

  5. -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

  6. -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

  7. -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

  8. #重启防火墙

  9. service iptables restart

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

[html] view plain copy

  1. tar -zxvf libxml2-2.6.30.tar.gz

  2. cd libxml2-2.6.30

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

  4. make

  5. make install

6>【安装libmcrypt】

[html] view plain copy

  1. tar -zxvf libmcrypt-2.5.8.tar.gz

  2. cd libmcrypt-2.5.8

  3. ./configure --enable-ltdl-install

  4. make

  5. make install

7>【安装zlib】

[html] view plain copy

  1. tar -zxvf zlib-1.2.3.tar.gz

  2. cd zlib-1.2.3

  3. ./configure

  4. make

  5. make install

8>【安装libpng】

[html] view plain copy

  1. tar -zxvf libpng-1.2.31.tar.gz

  2. cd libpng-1.2.31

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

  4. make

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

  6. make install

9>【安装jpegsrc.v6b】

[html] view plain copy

  1. mkdir /usr/local/jpeg6

  2. mkdir /usr/local/jpeg6/bin

  3. mkdir /usr/local/jpeg6/lib

  4. mkdir /usr/local/jpeg6/include

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

  6. tar -zxvf jpegsrc.v6b.tar.gz

  7. cd jpeg-6b

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

  9. make

  10. make install

[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/libtool
make
make install

然后进入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 plain copy

  1. tar -zxvf freetype-2.3.5.tar.gz

  2. cd freetype-2.3.5

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

  4. make && make install && echo OK && cd ..

11>【安装autoconf】

[html] view plain copy

  1. tar -zxvf autoconf-2.61.tar.gz

  2. cd autoconf-2.61

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

  4. make && make install && echo OK && cd ..

12>【安装gd】

[html] view plain copy

  1. tar -zxvf gd-2.0.35.tar.gz

  2. cd gd-2.0.35

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

  4. make && make install && echo OK && cd ..

13>【安装apache】

[html] view plain copy

  1. tar -zxvf httpd-2.2.9.tar.gz

  2. cd httpd-2.2.9

  3. ./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

  4. make && make install && echo OK

  5. #启动apache

  6. /usr/local/apache2/bin/apachectl start

  7. #如果出现下面的错误,

  8. #httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName

  9. #修改配置文件

  10. vi /etc/httpd/httpd.conf

  11. #查找ServerName,将注释去掉

  12. ServerName www.example.com:80

  13. #添加到自启动

  14. echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.sysinit

  15. #将apache添加到系统服务中

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

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

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

  19. # chkconfig:2345 85 15

  20. # description:Apache

  21. #添加执行权限

  22. chmod 755 /etc/init.d/httpd

  23. #添加到系统服务中

  24. chkconfig --add httpd

  25. #开启apache

  26. service httpd start

14>【安装ncurses】

[html] view plain copy

  1. tar -zxvf ncurses-5.6.tar.gz

  2. cd ncurses-5.6

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

  4. make && make install && echo OK && cd ..

15>【安装mysql】

[html] view plain copy

  1. groupadd mysql

  2. useradd -g mysql mysql

  3. tar -zxvf mysql-5.1.59.tar.gz

  4. cd mysql-5.1.59

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

  6. make && make install && echo OK && cd ..

[html] view plain copy

  1. cp support-files/my-medium.cnf /etc/my.cnf

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

  3. chown -R root /usr/local/mysql

  4. chown -R mysql /usr/local/mysql/var

  5. chgrp -R mysql /usr/local/mysql

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

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

  8. chown root.root /etc/rc.d/init.d/mysqld

  9. chmod 755 /etc/rc.d/init.d/mysqld

  10. chkconfig --add mysqld

  11. chkconfig --list mysqld

  12. chkconfig --levels 245 mysqld off

[html] view plain copy

  1. #配置mysql

  2. cd /usr/local/mysql

  3. bin/mysqladmin version //简单的测试

  4. bin/mysqladmin Variables //查看所有mysql参数

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

  6. DELETE FROM mysql.user WHERE Host='localhost' AND User='';

  7. FLUSH PRIVILEGES;

  8. #设置root密码为123456

  9. SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');

  10. #配置可远程连接mysql

  11. use mysql

  12. SELECT user,password,host FROM user;

  13. DELETE FROM user WHERE host='localhsot.localdomain'

  14. DELETE FROM user WHERE host='127.0.0.1';

  15. UPDATE user SET host='%' WHERE user='root';

  16. #重启mysql

  17. service mysqld restart

16>【安装php】

[html] view plain copy

  1. tar -zxvf php-5.2.6.tar.gz

  2. cd php-5.2.6

  3. ./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

  4. 注:如果出现报错:

  5. configure: error: GD build test failed. Please check the config.log for deta

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

    发现错误如下:

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_destroy_decompress@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_CreateCompress@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_read_header@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_read_scanlines@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_start_compress@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_destroy_compress@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_set_quality@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_finish_decompress@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_set_defaults@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_write_marker@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_start_decompress@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_destroy@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_resync_to_restart@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_simple_progression@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_write_scanlines@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_save_markers@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_CreateDecompress@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_std_error@LIBJPEG_6.2'

    /usr/local/gd2//lib/libgd.so: undefined reference to `jpeg_finish_compress@LIBJPEG_6.2'

    解决方法:

    rm -rf /usr/local/gd

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

    然后重新编译php就行了

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

  6. make && make install && echo OK && cd ..

  7. cp php.ini-development /usr/local/php/etc/php.ini

17>【apache配置】

[html] view plain copy

  1. #建立工作目录

  2. mkdir -p /var/www/html

  3. #修改httpd.conf

  4. vi /etc/httpd/httpd.conf

  5. #功能: 设置工作目录

  6. #说明: 搜索DocumentRoot, 修改为

  7. DocumentRoot "/var/www/html"

  8. #功能: 设置目录选项

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

  10. <Directory "/var/www/html">

  11. #功能: 设置默认文档

  12. #说明: 搜索<IfModule dir_module>, 修改为

  13. DirectoryIndex index.html index.php

  14. #功能: 增加php类型

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

  16. AddType application/x-httpd-php .html .php

  17. 功能: 不允许访问目录

  18. 说明: 搜索Options Indexes FollowSymLinks项并注释

  19. #Options Indexes FollowSymLinks

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

  21. #重启apache

  22. service httpd restart

18>【添加PDO_MYSQL扩展】

[html] view plain copy

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

  2. /usr/local/php/bin/phpize

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

  4. make

  5. make install

[html] view plain copy

  1. #执行完make install后会生成

  2. #Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

  3. #修改php.ini

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

  5. #查找extension_dir,修改为

  6. extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"

  7. #添加pdo_mysql

  8. extension = pdo_mysql.so

  9. #重启apache

  10. service httpd restart

19>【apache虚拟主机配置】

[html] view plain copy

  1. #建立dev目录

  2. mkdir -p /var/www/html/dev

  3. cd /var/www/html/dev

  4. vi index.php

  5. #添加

  6. <?php

  7. phpinfo();

  8. ?>

  9. #保存,退出

  10. #打开httpd.conf

  11. vi /etc/httpd/httpd.conf

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

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

  14. #打开httpd-vhosts.conf

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

  16. #将下面几行注释

  17. #<VirtualHost *:80>

  18. #    ServerAdmin webmaster@dummy-host.example.com

  19. #    DocumentRoot "/usr/local/apache2//docs/dummy-host.example.com"

  20. #    ServerName dummy-host.example.com

  21. #    ServerAlias www.dummy-host.example.com

  22. #    ErrorLog "logs/dummy-host.example.com-error_log"

  23. #    CustomLog "logs/dummy-host.example.com-access_log" common

  24. #</VirtualHost>

  25. #<VirtualHost *:80>

  26. #    ServerAdmin webmaster@dummy-host2.example.com

  27. #    DocumentRoot "/usr/local/apache2//docs/dummy-host2.example.com"

  28. #    ServerName dummy-host2.example.com

  29. #    ErrorLog "logs/dummy-host2.example.com-error_log"

  30. #    CustomLog "logs/dummy-host2.example.com-access_log" common

  31. #</VirtualHost>

  32. #添加

  33. <VirtualHost *:80>

  34. ServerName dev.dev

  35. DocumentRoot "/var/www/html/dev"

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

  37. AllowOverride All

  38. </Directory>

  39. </VirtualHost>

  40. #保存, 退出

  41. #重启apache

  42. service httpd restart

  43. #修改hosts文件

  44. vi /etc/hosts

  45. #添加

  46. 127.0.0.1       dev.dev localhost

  47. #保存, 退出

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

  49. Apache优化项:

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

    <Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all        //这句改为Allow from all
    </Directory>

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

    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    更改为

    AllowOverride All

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

    Options Indexes FollowSymLinks

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

    <IfModule !mpm_netware_module>
    <IfModule !mpm_winnt_module>

    User daemon              //改为www
    Group daemon             //改为www

    </IfModule>
    </IfModule>

    设置 ServerAdmin you@example.com 改为你自己的mail地址

    查找:

    Listen 80

    改为

    Listen 81

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

    Include conf/extra/httpd-mpm.conf

    Include conf/extra/httpd-info.conf

    Include conf/extra/httpd-vhosts.conf

    Include conf/extra/httpd-default.conf

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

    <IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   1000
    </IfModule>

    编辑 conf/extra/httpd-default.conf

    Timeout 60   #与nginx的保持一至
    KeepAlive On
    MaxKeepAliveRequests 1000
    KeepAliveTimeout 5

    创建以下用户及文件夹:

  51. groupadd www

  52. useradd -g www -s /sbin/nologin -M www

  53. mkdir -p /usr/local/apache2/docs/dummy-host.example.com

    mkdir -p /usr/local/apache2/docs/dummy-host2.example.com

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

    service httpd start/stop/restart

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

20 【Nginx安装】

yum -y install pcre-devel

wget http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz

tar xf libunwind-1.1.tar.gz

cd libunwind-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.blog.51cto.com/1196234/1752207

wget http://nginx.org/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

#user  nobody;

#worker_processes  1;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

################# Nginx Setup ######################

user www;

worker_processes 4;

error_log  logs/error.log;

pid        logs/nginx.pid;

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

worker_rlimit_nofile 51200;

events {

use epoll;

worker_connections  51200;

}

http {

include       mime.types;

default_type  application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

#                  '$status $body_bytes_sent "$http_referer" '

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

#access_log  logs/access.log  main;

################# Nginx Setup ###############

server_names_hash_bucket_size     128;

client_header_buffer_size         256k;

large_client_header_buffers 4 256k;

client_max_body_size             50m;

client_body_buffer_size         256k;

client_header_timeout             3m;

client_body_timeout             3m;

send_timeout                     3m;

sendfile        on;

#tcp_nopush     on;

tcp_nopush     on;

tcp_nodelay    on;

#keepalive_timeout  0;

keepalive_timeout  120;

#gzip  on;

gzip  on;

gzip_min_length  1k;

gzip_buffers     4 16k;

gzip_http_version 1.0;

gzip_comp_level 2;

gzip_vary on;

include vhost/*.conf;

#################### load balancing ####################

upstream www.zlyang.com {                 #负责均衡

server  192.168.30.132:81;                     #Node节点

server  192.168.30.133:81;                     #Node节点

}

server {

listen       80;

server_name  www.zlyang.com;            #网站域名

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {

proxy_pass         http://www.zlyang.com;             #网站域名

proxy_set_header   Host             $host;

proxy_set_header   X-Real-IP        $remote_addr;

proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

}

#    location / {

#       root   html;

#      index  index.html index.htm;

# }

#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html

#

error_page   500 502 503 504  /50x.html;

location = /50x.html {

root   html;

}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80

#

#location ~ \.php$ {

#    proxy_pass   http://127.0.0.1;

#}

# 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  /scripts$fastcgi_script_name;

#    include        fastcgi_params;

#}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

#location ~ /\.ht {

#    deny  all;

#}

}

# another virtual host using mix of IP-, name-, and port-based configuration

#

#server {

#    listen       8000;

#    listen       somename:8080;

#    server_name  somename  alias  another.alias;

#    location / {

#        root   html;

#        index  index.html index.htm;

#    }

#}

# HTTPS server

#

#server {

#    listen       443 ssl;

#    server_name  localhost;

#    ssl_certificate      cert.pem;

#    ssl_certificate_key  cert.key;

#    ssl_session_cache    shared:SSL:1m;

#    ssl_session_timeout  5m;

#    ssl_ciphers  HIGH:!aNULL:!MD5;

#    ssl_prefer_server_ciphers  on;

#    location / {

#        root   html;

#        index  index.html index.htm;

#    }

#}

}

重启nginx服务:

service nginx restart

安装 Redis:

wget http://download.redis.io/releases/redis-2.8.24.tar.gz

tar xf redis-2.8.24.tar.gz

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

cd redis

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

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

yum -y install gcc*

将redis做成一个服务

cp utils/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 / -name redis.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

# requirepass foobared

修改为:

requirepass auth密码


将redis写成服务脚本

vim /etc/init.d/redis

#!/bin/sh

#

# Author: Zlyang

# Date  : 2016-6-14

#

# chkconfig: 2345 80 90

# Simple Redis init.d script conceived to work on Linux systems

# as it does use of the /proc filesystem.

#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|grep 6379|grep -Ev "grep" |awk '{print $2}'`

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

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

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

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

function start()

{

if [ "$PID_NUM" != 0 ]

then

echo "Redis service is already running ..."

else

echo "Starting Redis server..."

$EXEC $CONF 2>&1 > /dev/null &

sleep 1

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

then

echo -e "Start Redis service.............................. [\E[1;32m OK \E[0m]"

fi

fi

}

function stop()

{

if [ $PID_NUM == 0 ]

then

echo "Redis service is not running !"

else

echo "Waiting for Redis to stop ..."

kill -9 $PID

sleep 1

echo -e "Stop Redis service............................... [\E[1;32m OK \E[0m]"

fi

}

case "$1" in

start)

start

;;

stop)

stop

;;

status)

if [ "$PID_NUM" != 0 ]

then

echo "Redis service is already running ..."

else

echo "Redis service is stoped !"

fi

;;

restart)

if [ "$PID_NUM" != 0 ]

then

stop

sleep 1

echo "Starting Redis server..."

$EXEC $CONF 2>&1 > /dev/null &

sleep 1

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

then

echo -e "Start Redis service.............................. [\E[1;32m OK \E[0m]"

fi

else

start

fi

;;

*)

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

;;

esac

保存退出:

将redis添加为服务:

chkconfig --add redis

chkconfig redis on

转载于:https://blog.51cto.com/zlyang/1752284

Linux+Nginx+Apache+Atlas+Mysql+Php+Redis 分部式部署详细版相关推荐

  1. PHP实习之路—NO.1(看LINUX、APACHE、MYSQL、PHP文档)

    PHP实习之路-NO.1(看LINUX.APACHE.MYSQL.PHP文档): 基本功一定要扎实! 本文转自 Lee_吉  博客,原文链接:    http://blog.51cto.com/121 ...

  2. ZH奶酪:Ubuntu 14.04配置LAMP(Linux、Apache、MySQL、PHP)

    ZH奶酪:Ubuntu 14.04安装LAMP(Linux,Apache,MySQL,PHP) 之前已经介绍过LAMP的安装,这边文章主要讲解一下LAMP的配置. 1.配置Apache (1)调整Ke ...

  3. LAMP基础环境的搭建,即Linux、Apache、MySQL、PHP环境

    LAMP基础环境的搭建,即Linux.Apache.MySQL.PHP环境 测试环境: 主机:windows server 2008 R2 64位 虚拟机:VMware Workstation 11. ...

  4. 如何在Ubuntu 20.04上安装Linux,Apache,MySQL,PHP(LAMP)堆栈[快速入门]

    介绍 (Introduction) In this quickstart guide, we'll install a LAMP stack on an Ubuntu 20.04 server. 在本 ...

  5. docker安装mysql redis_Docker安装Mysql和Redis以及构建部署应用镜像

    为了方便本地测试项目,为了方便开启新的环境,为了方便部署,打算本地利用Docker安装Mysql和Redis. 搭建Springboot项目,编写Dockerfile,打包构建镜像. 简单使用dock ...

  6. linux下apache+php+mysql升级安装过程

    由于服务器的linux版本太低,apache+php+mysql版本都太低,初次学习linux经过三天除了吃饭睡觉终于把apache+php+mysql给升级了!现说下升级过程: 一删除apache+ ...

  7. linux安装和配置 mysql、redis 过程中遇到的问题记录(转)

    章节目录 mysql redis linux下部署mysql和redis网上的教程很多,这里记录一下我部署.配置的过程中遇到的一些问题和解决办法. mysql ①安装完成后启动的时候报错 Starti ...

  8. Linux下apache+php+mysql配置攻略

    说实话,一直以来Windows服务器玩的还算明白,对于Linux真的可以说是根本不会用,但是这两天公司给我分配的任务就是在Linux下搭建起来apache+php+mysql的环境,并且找一套有漏洞的 ...

  9. 阿里云快速搭建数据库开发环境(宝塔Linux面板)+(mysql,Redis安装,配置,远程链接)

    前言:为什么要买一个服务器搭建服务 当你点开这个文章的时候,说明你已经是即将步入IT行业的萌新,无论是开发.测试.运维基本都需要有一个学习扶服务器的环节,希望这篇文章能对你有所帮助. 第一步:云端环境 ...

最新文章

  1. Ajax弹出式无刷新城市选择特效
  2. 动词ing基本用法_百因必有果,你的“福利”就是我第61篇:过去进行时构成及用法...
  3. android上河南星海科技_分数不高能上什么空乘学校?推荐下
  4. UNIX 动态库和静态库
  5. asp.net权限控制配置web.config
  6. 有的字体,设置了粗体,也不能用粗体方式来绘制
  7. SVM多分类器算法-一对多
  8. iOS之 simlator模拟器截屏
  9. s1 episode1(一)
  10. 能不用事务就尽量别用
  11. 如何在小方框上打对号 小方框内打对勾 word 方框打对勾
  12. 前端开发工程师必备网站
  13. 厦大C语言上机 1413 模式匹配
  14. hdu 4379The More The Better
  15. pip国内常用镜像源汇总
  16. Linux内核源码介绍
  17. ERD ONline 为企业数字化转型助力
  18. Windows 10系统点击任务计划程序,提示找不到远程电脑如何处理
  19. 同一局域网内ping请求超时
  20. 28.文本处理三剑客grep,sed,awk

热门文章

  1. TortoiseGit拉取或推送,输入账号密码后提示 HTTP Basic: Access denied fatal: Authentication failed 解决方案...
  2. .Net Cache
  3. AngularJs的理解
  4. RDIFramework.NET-.NET快速信息化系统开发整合框架 【开发实例 EasyUI】之产品管理(MVC版)...
  5. Java—数据库技术
  6. 在 node.js 的 express web 框架中自动注册路由
  7. sql server 数据库改名
  8. 智能车C车电机传递函数计算
  9. C# 中类对象与JSON字符串互相转换的几种方法
  10. C# 捕获系统闪退BUG