星五博客

centos7安装php与mysql

1.安装centos7
官网下载最新的centos7.5,下载最小的版本进行安装,其它略过;

2.配置网络
centos安装完成,网络默认是不通的,需要修改

vi /etc/sysconfig/network-scripts/ifcfg-ens33

将 ONBOOT=no 改为 ONBOOT=yes
编辑完成后,保存退出,并重启network服务

systemctl restart network

3.防火墙
卸载firewalld

yum remove firewalld

安装iptables

yum install -y iptables-services

配置iptables

iptables -F
iptables -X
iptables -P INPUT DROP
iptables -I INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT
iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables-save > /etc/sysconfig/iptables

开机启动

systemctl enable iptables.service

4.安装php7
更新yum源

yum -y install epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

安装php(ubuntu下直接sudo install php7.2就行,centos下要一个个打,好麻烦)

yum install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm
yum install php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml

5.安装httpd(Apache)
安装httpd

yum install -y httpd

开机启动

systemctl enable httpd.service

6.安装mysql5.7
下载安装配置包(wget未安装的要先yum install wget安装)

wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

安装mysql源

yum localinstall mysql57-community-release-el7-8.noarch.rpm

安装mysql

yum install mysql-community-server

启动服务

systemctl start mysqld

开机启动

systemctl enable mysqld

查看安装密码

grep 'temporary password' /var/log/mysqld.log

登录mysql

mysql -uroot -p

修改密码(在mysql中)

set password for 'root'@'localhost'=password('Password8!'); 


其它一些常用指令

查看ip        ip address
查看服务状态   systemctl status httpd
启动服务      systemctl start httpd
开机启动      systemctl enable httpd.service

有其它疑问,请百度解决,哈^_^

Linux