原文:
一、系统镜像源切换
系统:centos7关闭防火墙和selinuxcp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backupyum -y install wgetwget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repovim /etc/yum.repos.d/CentOS-Media.repoenable=0yum clean allyum makecacheyum update
二、安装nginx
##增加一个nginx的源nginx.repovi /etc/yum.repos.d/nginx.repo[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=0enabled=1yum list nginxyum list |grep nginx----------------------------------------------------------------------------------##安装nginxyum -y install nginxnginx #启动curl 127.0.0.1 #查看是否有HTML反馈,有的话,代表安装成功##开机启动systemctl enable nginxsystemctl daemon-reload
三、安装mysql5.7
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm##查看5.7版本是否已经启用yum repolist all | grep mysql##如果没有启用的话,我们可以修改源文件/etc/yum.repos.d/mysql-community.repo##把mysql57的enabled改为1就可以了,其他的版本改为0yum repolist enabled | grep mysql---------------------------------------------------------------------------------##安装yum -y install mysql-community-server##启动service mysqld start##开机启动设置systemctl enable mysqldsystemctl daemon-reload---------------------------------------------------------------------------------##MySql安装完成之后会在LOG文件(/var/log/mysqld.log)中生成一个root的默认密码grep 'temporary password' /var/log/mysqld.log##登录MySql并修改root密码,xxxxxx代指密码mysql -u root -p #这里的密码就是刚才日志文件里的密码mysql> set password=password('xxxxxx'); #进去以后改root密码,有复杂度要求,设置复杂一些##授权mysql> grant all privileges on *.* to root@'%' identified by 'xxxxxx'; #解决客户端root用户远程连接服务器的问题mysql> grant all privileges on *.* to 'root'@'node1' identified by 'xxxxxx' with grant option; #解决root权限访问所有库的问题,node01可以换为localhost mysql> flush privileges;
四、安装PHP7
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmrpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm##安装PHP7yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64##安装php-fpmyum install php70w-fpm php70w-opcache##启动php-fpmsystemctl start php-fpm##开机启动设置systemctl enable php-fpmsystemctl daemon-reload
五、让nginx支持PHP
修改 /etc/nginx/conf.d/default.conflocation ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }