1、安装nginx
yum install nginx
##启动 nginx
service nginx start
2、安装MYSQL
yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum install mysql-community-server
//开启mysql
service mysqld start
//查看mysql的root账号的密码
grep 'temporary password' /var/log/mysqld.log
//登录mysql
mysql -uroot -p
//修改密码
set global validate_password_policy=0;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
//刷新
flush privileges;
3、安装php
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
//查看
yum search php71w
//安装php以及扩展
yum install php71w php71w-fpm php71w-cli php71w-common php71w-devel php71w-gd php71w-pdo php71w-mysql php71w-mbstring php71w-bcmath
//开启服务
service php-fpm start
//修改/etc/nginx/nginx.conf 使其支持php 见下
//重启nginx
service nginx restart
server{
listen 80;
server_name 域名;
index index.html index.htm index.php;
root 应用目录;
location / {
if (-f $request_filename) {
break;
}
if (-d $request_filename) {
break;
}
if ($request_filename ~* .*\.(gif|jpg|jpeg|png|bmp|swf)$ ) {
break;
}
rewrite ^(.+)$ /index.php?url=$1 last;
}
location ~ \.php {
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+\.php)(/.*)") {
set $script $1;
set $path_info $2;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME 应用目录/$script;
fastcgi_param PATH_INFO $path_info;
fastcgi_param HTTPS off;
fastcgi_param CI_ENV production;
fastcgi_param SCRIPT_NAME $script;
}
}
4、安装redis
yum install redis
//修改配置
vi /etc/redis.conf
//daemonize yes 后台运行
//appendonly yes 数据持久化
service redis start
5、安装php-redis扩展
//先装git
yum install git
//git下扩展
cd /usr/local/src
git clone https://github.com/phpredis/phpredis.git
//安装扩展
cd phpredis
phpize
make
make install
//修改php配置
vi /etc/php.ini 添加extension=redis.so
//重启php
service php-fpm restart