此實驗須要三臺服務器:php
一臺服務器以下:html
192.168.72.130 安裝LAMP環境mysql
1.yum 安裝AP環境:linux
yum install httpd httpd-devel php php-devel php-mysql -y
2.安裝數據庫 詳見如下連接:git
http://jiaxinwang.blog.51cto.com/12273793/1935065github
3.啓動httpd服務redis
systemctl start httpd
4. 關閉防火牆和selinux服務或者加上相應的端口sql
systemctl stop firewalld setenforce 0
5.下載discuz網站模板(下載在/var/www/html目錄下)數據庫
wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zipvim
6.解壓
unzip Discuz_X3.2_SC_UTF8.zip
因爲網站代碼在upload 因此把upload文件夾的文件移動到發佈目錄下
7.發現目錄不存在和不可寫;給權限
chmod -R 757 data/ config/ uc_client/ uc_server/ setenforce 也要關掉
8.在發佈目錄下找到config_global.php文件修改文件
目錄:/var/www/html/config
修改成:$_config['db']['1']['dbhost'] = '192.168.1.156';
9.建立數據庫
數據庫名:服務器的IP或者域名 192.168.72.130
數據庫名:在數據庫中建立個數據庫
數據庫用戶名:root
數據庫密碼:123456
再加個密碼,其餘默認
建立數據庫的命令:create database discuz;
10.當下一步時出現Host '192.168.1.156' is not allowed to connect to this MySQL server這個錯誤時;
解決:給數據庫root一個能夠遠程訪問的權限
grant all on *.* to root@'%' identified by '123456';
而後問題解決,下一步,等待安裝完成!
11.下載redis 本實驗使用的是redis-2.8.18
cd /usr/src
wget http://download.redis.io/releases/redis-2.8.18.tar.gz
解壓:tar zvxf redis-2.8.18.tar.gz 進入解壓目錄:cd redis-2.8.18/
預編譯: make PREFIX=/usr/local/redis install
安裝:make && make install
12.將安裝目錄的bin文件的文件作個軟鏈接到/usr/bin/下
ln -s /usr/local/redis/bin/* /usr/bin/
13.在解壓目錄下有redis.conf配置文件 拷貝到安裝目錄下
cp /usr/src/redis-2.8.18/redis.conf /etc/redis/
14.啓動redis
進入配置文件
vim /etc/redis/redis.conf
將daemonize no 改成daemonize yes
保存、退出
啓動接配置文件 redis-server /etc/redis/redis.conf
ps -ef | grep redis root 53762 1 0 17:53 ? 00:00:06 redis-server *:6379 root 54130 1700 0 18:24 pts/0 00:00:00 grep --color=auto redis
15.到發佈目錄下修改config_global.php文件
/var/www/html/config $_config['memory']['redis']['server'] = '192.168.1.135';####改成redis服務器IP地址
16.在redis服務器輸入 redis-cli進入redis
在論壇上隨便點擊(產生keys值)而後在redis服務器輸入keys *查看keys值
發現沒有 由於php沒有redis模塊,要添加phpredis模塊
(作個php測試頁面,若是找不到redis說明沒有redis模塊)
17.下載安裝phpredis
wget https://github.com/phpredis/phpredis/archive/3.1.2.tar.gz
tar zvxf 3.1.2.tar.gz
cd phpredis-3.1.2/
phpize(php初始化)
./configure --with-php-config=/usr/bin/php-config --enable-redis(預編譯)
make && make install(安裝)
18.在php配置文件中添加redis模塊
vim /etc/php.ini extension_dir = "/usr/lib64/php/modules/" extension=redis.so
18.重啓httpd服務
systemctl restart httpd
19.再去論壇點幾下,產生keys值,而後去redis看下有沒有keys值產生
127.0.0.1:6379> keys * 1) "iducIG_announcements" 2) "iducIG_common_member_count_1" 3) "iducIG_magic" 4) "iducIG_usergroup_7" 5) "iducIG_forumlinks" 6) "iducIG_onlinerecord" 7) "iducIG_common_member_status_1" 8) "iducIG_plugin" 9) "iducIG_diytemplatenamehome" 10) "iducIG_historyposts" 11) "iducIG_forum_index_page_1" 12) "iducIG_userstats" 13) "iducIG_common_member_field_home_1" 14) "iducIG_pluginlanguage_script" 15) "iducIG_onlinelist" 16) "iducIG_creditrule" 17) "iducIG_common_member_1" 18) "iducIG_usergroup_1" 19) "iducIG_pluginlanguage_system" 20) "iducIG_diytemplatename" 21) "iducIG_stamps" 22) "iducIG_forum_guide" 23) "iducIG_home_follow_1" 24) "iducIG_common_member_profile_1" 25) "iducIG_cronpublish" 26) "iducIG_forums" 27) "iducIG_common_member_field_forum_1" 28) "iducIG_style_default" 29) "iducIG_cronnextrun" 30) "iducIG_profilesetting" 31) "iducIG_userapp" 32) "iducIG_posttable_info" 33) "iducIG_usergroups" 34) "iducIG_setting" 35) "iducIG_diytemplatenameforum" 36) "iducIG_heats" 127.0.0.1:6379>
#vim /usr/redis/redis.conf
將主庫bind 127.0.0.1 改成 bind 0.0.0.0保存退出
#vim /usr/redis/redis.conf
從庫在bind下添加一行
啓動redisz主庫和從庫
注:防火牆和setenforce