Linux+Nginx+Apache+Atlas+Mysql+Php+Redis 分部式部署详细版
環(huán)境描述:
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>【卸載系統(tǒng)自帶的apache】
[html]?view plain?copy
#查看apache是否己安裝??
rpm?-qa?httpd??
#卸載??
rpm?-e?httpd?--nodeps??
2>【安裝gcc, gcc-c++】
[html]?view plain?copy
yum?install?gcc??
yum?install?gcc-c++??
3>【開放80、3306、22端口】
[html]?view plain?copy
#關閉防火墻??
service?iptables?stop??
vi?/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?22?-j?ACCEPT??
#重啟防火墻??
service?iptables?restart??
4>【建立lamp/src目錄, 將源碼包上傳】5>【安裝libxml2】
[html]?view plain?copy
tar?-zxvf?libxml2-2.6.30.tar.gz??
cd?libxml2-2.6.30??
./configure?--prefix=/usr/local/libxml2
make???
make?install??
6>【安裝libmcrypt】
[html]?view plain?copy
tar?-zxvf?libmcrypt-2.5.8.tar.gz??
cd?libmcrypt-2.5.8??
./configure?--enable-ltdl-install??
make??
make?install??
7>【安裝zlib】
[html]?view plain?copy
tar?-zxvf?zlib-1.2.3.tar.gz??
cd?zlib-1.2.3??
./configure??
make??
make?install??
8>【安裝libpng】
[html]?view plain?copy
tar?-zxvf?libpng-1.2.31.tar.gz??
cd?libpng-1.2.31??
./configure?--prefix=/usr/local/libpng ?
make??
mkdir -p /usr/loca/libpng/man/man1
make?install ?
9>【安裝jpegsrc.v6b】
[html]?view plain?copy
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?-zxvf?jpegsrc.v6b.tar.gz??
cd?jpeg-6b??
./configure?--prefix=/usr/local/jpeg6 --enable-shared?--enable-static??
make??
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以默認方式安裝,執(zhí)行以下命令:? ./configure??--prefix=/usr/local/libtool make? make?install
然后進入jpeg-6b的源碼目錄,然后執(zhí)行以下步驟,切記!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
tar?-zxvf?freetype-2.3.5.tar.gz??
cd?freetype-2.3.5??
./configure?--prefix=/usr/local/freetype ?
make &&?make?install && echo OK && cd .. ?
11>【安裝autoconf】
[html]?view plain?copy
tar?-zxvf?autoconf-2.61.tar.gz??
cd?autoconf-2.61??
./configure?--prefix=/usr/local/autoconf??
make &&?make?install && echo OK && cd ..
12>【安裝gd】
[html]?view plain?copy
tar?-zxvf?gd-2.0.35.tar.gz??
cd?gd-2.0.35?
./configure?--prefix=/usr/local/gd2?--with-jpeg=/usr/local/jpeg6?--with-freetype=/usr/local/freetype
make &&?make?install && echo OK && cd ..
13>【安裝apache】
[html]?view plain?copy
tar?-zxvf?httpd-2.2.9.tar.gz??
cd?httpd-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 &&?make?install && echo OK?
#啟動apache??
/usr/local/apache2/bin/apachectl?start??
#如果出現(xiàn)下面的錯誤,??
#httpd:?Could?not?reliably?determine?the?server's?fully?qualified?domain?name,?using?::1?for?ServerName??
#修改配置文件??
vi?/etc/httpd/httpd.conf??
#查找ServerName,將注釋去掉??
ServerName?www.example.com:80??
#添加到自啟動??
echo?"/usr/local/apache2/bin/apachectl?start"?>>?/etc/rc.d/rc.sysinit??
#將apache添加到系統(tǒng)服務中??
cp?/usr/local/apache2/bin/apachectl?/etc/init.d/httpd??
vi?/etc/rc.d/init.d/httpd??
#在#!/bin/sh后添加下面兩行(包含"#")??
#?chkconfig:2345?85?15??
#?description:Apache??
#添加執(zhí)行權(quán)限??
chmod?755?/etc/init.d/httpd??
#添加到系統(tǒng)服務中??
chkconfig?--add?httpd??
#開啟apache??
service?httpd?start ?
14>【安裝ncurses】
[html]?view plain?copy
tar?-zxvf?ncurses-5.6.tar.gz??
cd?ncurses-5.6??
./configure --prefix=/usr/local/ncurses --with-shared?--without-debug?--without-ada?--enable-overwrite??
make &&?make?install && echo OK && cd ..
?
15>【安裝mysql】
[html]?view plain?copy
groupadd?mysql??
useradd?-g?mysql?mysql??
tar?-zxvf?mysql-5.1.59.tar.gz??
cd?mysql-5.1.59??
./configure?--prefix=/usr/local/mysql/?--with-extra-charsets=all?
make &&?make?install && echo OK && cd ..
?
[html]?view plain?copy
cp?support-files/my-medium.cnf?/etc/my.cnf??
/usr/local/mysql/bin/mysql_install_db?--user=mysql??
chown?-R?root?/usr/local/mysql??
chown?-R?mysql?/usr/local/mysql/var??
chgrp?-R?mysql?/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??
chown?root.root?/etc/rc.d/init.d/mysqld??
chmod?755?/etc/rc.d/init.d/mysqld??
chkconfig?--add?mysqld??
chkconfig?--list?mysqld??
chkconfig?--levels?245?mysqld?off?
[html]?view plain?copy
#配置mysql??
cd?/usr/local/mysql??
bin/mysqladmin?version?//簡單的測試??
bin/mysqladmin?Variables?//查看所有mysql參數(shù)??
bin/mysql?-uroot?//沒有密碼可以直接登錄本機服務器??
DELETE?FROM?mysql.user?WHERE?Host='localhost'?AND?User='';??
FLUSH?PRIVILEGES;??
#設置root密碼為123456??
SET?PASSWORD?FOR?'root'@'localhost'?=?PASSWORD('123456');??
#配置可遠程連接mysql??
use?mysql??
SELECT?user,password,host?FROM?user;??
DELETE?FROM?user?WHERE?host='localhsot.localdomain'??
DELETE?FROM?user?WHERE?host='127.0.0.1';??
UPDATE?user?SET?host='%'?WHERE?user='root';??
#重啟mysql??
service?mysqld?restart?
16>【安裝php】
[html]?view plain?copy
tar?-zxvf?php-5.2.6.tar.gz??
cd?php-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??
注:如果出現(xiàn)報錯:
configure:?error:?GD?build?test?failed.?Please?check?the?config.log?for?deta
查看當前目錄下的config.log中找到
發(fā)現(xiàn)錯誤如下:
/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 解決此問題!
make &&?make?install && echo OK && cd ..
??
cp?php.ini-development?/usr/local/php/etc/php.ini
??17>【apache配置】
[html]?view plain?copy
#建立工作目錄??
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">??
??
#功能:?設置默認文檔??
#說明:?搜索<IfModule?dir_module>,?修改為??
DirectoryIndex?index.html?index.php??
??
#功能:?增加php類型??
#說明:?搜索?AddType?application/x-gzip?.gz?.tgz在后面添加??
AddType?application/x-httpd-php?.html?.php??
??
功能:?不允許訪問目錄??
說明:?搜索Options?Indexes?FollowSymLinks項并注釋??
#Options?Indexes?FollowSymLinks??
??
#注意:?修改配置文件后,?重啟apache才能生效??
#重啟apache??
service?httpd?restart?
?
18>【添加PDO_MYSQL擴展】
[html]?view plain?copy
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??
make?install??
[html]?view plain?copy
#執(zhí)行完make?install后會生成??
#Installing?shared?extensions:?/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/??
#修改php.ini??
vi?/usr/local/php/etc/php.ini??
#查找extension_dir,修改為??
extension_dir?=?"/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"??
#添加pdo_mysql??
extension?=?pdo_mysql.so??
#重啟apache??
service?httpd?restart ?
19>【apache虛擬主機配置】
[html]?view plain?copy
#建立dev目錄??
mkdir?-p?/var/www/html/dev??
cd?/var/www/html/dev??
vi?index.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>??
#????ServerAdmin?webmaster@dummy-host.example.com??
#????DocumentRoot?"/usr/local/apache2//docs/dummy-host.example.com"??
#????ServerName?dummy-host.example.com??
#????ServerAlias?www.dummy-host.example.com??
#????ErrorLog?"logs/dummy-host.example.com-error_log"??
#????CustomLog?"logs/dummy-host.example.com-access_log"?common??
#</VirtualHost>??
??
??
#<VirtualHost?*:80>??
#????ServerAdmin?webmaster@dummy-host2.example.com??
#????DocumentRoot?"/usr/local/apache2//docs/dummy-host2.example.com"??
#????ServerName?dummy-host2.example.com??
#????ErrorLog?"logs/dummy-host2.example.com-error_log"??
#????CustomLog?"logs/dummy-host2.example.com-access_log"?common??
#</VirtualHost>??
#添加??
<VirtualHost?*:80>??
????????ServerName?dev.dev??
????????DocumentRoot?"/var/www/html/dev"??
????????<Directory?"/var/www/html/dev/">??
????????????????AllowOverride?All??
????????</Directory>??
</VirtualHost>??
#保存,?退出??
#重啟apache??
service?httpd?restart??
#修改hosts文件??
vi?/etc/hosts??
#添加??
127.0.0.1???????dev.dev?localhost??
#保存,?退出??
#在瀏覽器輸入http://dev.dev訪問,查看能否輸出php信息 ?
Apache優(yōu)化項:
找到以下代碼并根據(jù)提示修改
<Directory?/>
Options?FollowSymLinks
AllowOverride?All
Order?deny,allow
Deny?from?all????????//這句改為Allow?from?all
</Directory>
找到這一段并修改,以使Apache支持rewrite(偽靜態(tài)):
#?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?找到如下選項,并改成對應的數(shù)值
<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
創(chuàng)建以下用戶及文件夾:
groupadd www
useradd -g?www -s?/sbin/nologin -M www
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*
一般情況下 都沒什么錯誤出現(xiàn)的。安裝完成后還不能直接使用。得執(zhí)行 ldconfig 重建系統(tǒng)動態(tài)鏈接庫。
配置?nginx?和 google perftools :
mkdir /usr/local/nginx/tmp/tcmalloc && chown www:www?/usr/local/nginx/tmp/tcmalloc
最后google_perftools 工具這樣安裝后還不能被Nginx調(diào)用。要給其指定該工具的動態(tài)鏈接庫路徑并重新加載系統(tǒng)動態(tài)鏈接庫:
echo ‘/usr/local/gperftools/lib’>/etc/ld.so.conf.d/my_app_lib.conf?
到這里。Google_perftools 工具已經(jīng)安裝完成,上面錯誤提示是在編譯安裝Nginx 1.4.7的時候出現(xiàn)的錯誤解決方法如圖:
具體圖文請參考:
編譯安裝 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節(jié)點
??????server??192.168.30.133:81; ? ? ? ? ? ? ? ? ? ? #Node節(jié)點
????}?????
????server?{
????????listen???????80;
????????server_name??www.zlyang.com; ? ? ? ? ? ?#網(wǎng)站域名
????????#charset?koi8-r;
????????#access_log??logs/host.access.log??main;
????????location?/?{
????????????proxy_pass?????????http://www.zlyang.com; ? ? ? ? ? ? #網(wǎng)站域名
????????????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失敗,一般是你們系統(tǒng)中還未安裝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)函數(shù)中修改:
$EXEC $CONF?
為:
$EXEC $CONF &
保存退出
創(chuàng)建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的命令所在目錄添加到系統(tǒng)參數(shù)PATH中
修改profile文件:
vi /etc/profile
在最后加入:
export PATH="$PATH:/usr/local/redis/bin"
啟動Redis:
/usr/local/redis/bin/redis-server?/etc/redis/6379.conf?&
這樣就可以直接調(diào)用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 就成功安裝了。
如果在執(zhí)行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
轉(zhuǎn)載于:https://blog.51cto.com/zlyang/1752284
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的Linux+Nginx+Apache+Atlas+Mysql+Php+Redis 分部式部署详细版的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 口袋妖怪复刻闪光精灵图鉴大全 闪光精灵图
- 下一篇: 元气骑士宠物哪个最好 元气骑士宠物战斗力