安装配置LAMP
yum -y install httpd mysql mysql-server php php-mysql php-devel php-fpm
Apache默认支持html,
整合php和Apache
编辑apache的配置文件
vim /etc/httpd/conf/httpd.conf
主页支持php
402 DirectoryIndex index.php index.html index.html.var
781 AddType application/x-httpd-php .php
重启httpd
创建php测试页
vim /var/www/html/index.php
内容:
#############################
#############################
启动数据库
service mysqld start
redis主从
1.拉取安装包
wget http://download.redis.io/releases/redis-5.0.2.tar.gz
2.将安装包移到指定目录
mv redis-5.0.2.tar.gz /usr/local/src/
cd /usr/local/src/
3.安装依赖
yum -y install gcc gcc-c++
4.安装redis
tar xfz redis-5.0.2.tar.gz
cd redis-5.0.2/
make && make install
5.配置一主两从
cp redis.conf /etc/redis_6379.conf
cp redis.conf /etc/redis_6380.conf
cp redis.conf /etc/redis_6381.conf
6.修改主从的配置文件
vim /etc/redis_6379.conf
bind 0.0.0.0
port 6379(默认就是不用改)
daemonize yes
vim /etc/redis_6380.conf
bind 0.0.0.0
port 6380
daemonize yes
replica-priority 100
replicaof 主的ip 端口
pidfile /var/run/redis_6380.pid
vim /etc/redis_6381.conf
bind 0.0.0.0
port 6381
daemonize yes
replica-priority 90
replicaof 主的ip 端口
pidfile /var/run/redis_6381.pid
7.启动服务(在解压的目录下执行)
/usr/local/src/redis-5.0.2
redis-server /etc/redis_6379.conf
redis-server /etc/redis_6380.conf
redis-server /etc/redis_6381.conf
netstat -lnpt |grep 6379
netstat -lnpt |grep 6380
netstat -lnpt |grep 6381
8.登录主
redis-cli -p 6379
info
如果两个从连接成功就ok
安装配置php的redis扩展模块
wget https://github.com/phpredis/phpredis/archive/3.1.2.tar.gz
tar -zxvf 3.1.2.tar.gz
cd phpredis-3.1.2
phpize
./configure
sudo make
make install(得到路径复制路径/xx/xx/xx/)
vim /etc/php.ini
配置文件最后一行
extension=/xx/xx/xx/redis.so
service php-fpm restart
service httpd restart