2web,1db,负载均衡,magento nginx配置

1.安装memcache,作为memcache的缓存服务器,开放端口11211,或者关闭iptables

开启memcache:

/usr/local/bin/memcached -m 32m -p 11211 -d -u root -P /tmp/memcached.pid -c 256

安装memcache:http://blog.csdn.net/terry_water/article/details/17160431

2.magento网站安装memcache的php扩展

反向代理服务器:

upstream myserver{
    server 192.168.1.215:80 weight=4 max_fails=3 fail_timeout=20s;
    server 192.168.1.216:80 weight=4 max_fails=3 fail_timeout=20s;
    
    }

server:

server {
    listen      80;
    server_name 192.168.1.214;
    root /www/web/test/magento2;
    server_tokens off;
    index index.php index.html index.htm;
    access_log /www/web_logs/comebuyerp_access70.log wwwlogs;
    error_log  /www/web_logs/comebuyerp_error70.log  notice;
    location /{
    
        proxy_pass http://myserver;
        proxy_next_upstream http_500 http_502 http_503 error timeout invalid_header;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        client_body_buffer_size 128k;
        proxy_connect_timeout 90;
        proxy_send_timeout 90;
        proxy_read_timeout 90;
        proxy_buffer_size 4K;
        proxy_buffers 4 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;
        }
    
}


3.安装magento站点:http://blog.csdn.net/terry_water/article/details/17060049

2个magento的配置:注意,使用同一个数据库,也就是2个网站的配置都一样

<config>
    <global>
        <install>
            <date><![CDATA[Thu, 05 Dec 2013 01:42:35 +0000]]></date>
        </install>
        <crypt>
            <key><![CDATA[dddd]]></key>
        </crypt>
        <disable_local_modules>false</disable_local_modules>
        <resources>
            <db>
                <table_prefix><![CDATA[]]></table_prefix>
            </db>
            <default_setup>
                <connection>
                    <host><![CDATA[192.168.1.216]]></host>
                    <username><![CDATA[yuancheng]]></username>
                    <password><![CDATA[yuancheng]]></password>
                    <dbname><![CDATA[magento]]></dbname>
                    <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                    <model><![CDATA[mysql4]]></model>
                    <type><![CDATA[pdo_mysql]]></type>
                    <pdoType><![CDATA[]]></pdoType>
                    <active>1</active>
                </connection>
            </default_setup>
        </resources>
       
    <session_save><![CDATA[memcache]]></session_save> <!-- db / memcache / empty=files -->
        <session_save_path><![CDATA[tcp://192.168.1.214:11211?persistent=1&weight=2&timeout=10&retry_interval=10]]></session_save_path><!-- e.g. for memcache session save handler tcp://10.0.0.1:11211?persistent=1&weight=2&timeout=10&retry_interval=10 -->
        <session_cache_limiter><![CDATA[82174]]></session_cache_limiter><!-- see http://php.net/manual/en/function.session-cache-limiter.php#82174 for possible values -->
        <!-- begin cache config -->
      
       <cache>
            <prefix>alphanumeric</prefix>
            <backend><![CDATA[memcached]]></backend>
            <slow_backend><![CDATA[database]]></slow_backend>
            <memcached>
                <servers>
                    <server>
                        <host><![CDATA[192.168.1.214]]></host>
                        <port><![CDATA[11211]]></port>
                        <persistent><![CDATA[1]]></persistent>
                        <weight><![CDATA[1]]></weight>
                        <timeout><![CDATA[10]]></timeout>
                        <retry_interval><![CDATA[10]]></retry_interval>
                        <status><![CDATA[1]]></status>
                    </server>
                </servers>
                <compression><![CDATA[0]]></compression>
                <cache_dir><![CDATA[]]></cache_dir>
                <hashed_directory_level><![CDATA[]]></hashed_directory_level>
                <hashed_directory_umask><![CDATA[]]></hashed_directory_umask>
                <file_name_prefix><![CDATA[]]></file_name_prefix>
            </memcached>
        </cache>    
    

    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <frontName><![CDATA[admin]]></frontName>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

4

magento网站后台的base_url设置为域名

在magento站点,测试是否可以连接memcache

telnet 192.168.1.214 11211

如果成功,清除,flush_all

qit

上面配置的magento和memcache安装完成后,nginx都要重启

service nginxd restart

5

访问即可。

发布了1086 篇原创文章 · 获赞 82 · 访问量 182万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 精致技术 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览