今天更换了服务器(centos8.2),重新搭建了网站,记录一下~
1 安装Apache
(1)安装apache
yum install -y httpd
(2)设置开机自启动
systemctl enable httpd.service
(3)启动服务/查看状态
systemctl start httpd
systemctl status httpd
(4)访问网址验证
(5)修改默认网站路径
vim /etc/httpd/conf/httpd.conf
systemctl restart httpd
2 安装Mysql8.0
(1)安装Repository
wget https://repo.mysql.com//mysql80-community-release-el8-1.noarch.rpm
(2)安装MySQL
rpm -ivh mysql80-community-release-el8-1.noarch.rpm
yum install -y mysql-server
(3)设置开机自启动
systemctl enable mysqld.service
(4)启动服务/查看状态
systemctl start mysqld
systemctl status mysqld
(5)修改root默认密码
如果有密码:
grep 'temporary password' /var/log/mysql/mysqld.log
如果没有密码:
cat /var/log/mysql/mysqld.log
结果:root@localhost is created with an empty password !
根据上面结果登录数据库
mysql -uroot -p
低版本
> set password for 'root'@'localhost'=password('你的密码');
高版本
> ALTER user'root'@'localhost' IDENTIFIED BY '你的密码';
(6)允许远程访问
> use mysql;
> update user set host = '%' where user = 'root';
> exit;
重启服务很重要!
systemctl restart mysqld
(7)设置默认编码为utf8
文件名或路径可能大同小异
在[mysqld]下如下代码:
vim /etc/my.cnf.d/mysql-server.cnf
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
3 安装PHP7.4
(1)安装EPEL、REMI库
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
yum install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
(2)查看可供安装的php版本
dnf module list php
(3)选择要安装的php版本
dnf module reset php
dnf module -y enable php:remi-7.4
(4)安装php及常用扩展
dnf install -y php php-cli php-gd php-mysql php-common
4 版本检查
检查版本(注意大小写)
httpd -v
mysqld -V
php -v
至此安装结束啦,完美!
如果觉得安装过慢,可以更换国内镜像源哦~
转载:https://blog.csdn.net/weixin_43290709/article/details/114852067
查看评论