溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

如何配置CentOS7+apache+php7+mysql5.7環境

發布時間:2021-06-18 11:31:40 來源:億速云 閱讀:247 作者:小新 欄目:服務器

這篇文章主要介紹了如何配置CentOS7+apache+php7+mysql5.7環境,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

yum upgrade
yum install net-tools

安裝apache

關閉SELinux

編輯器打開 etc/selinux/config 文件,找到 SELINUX=enforcing 字段,將其改成 SELINUX=disabled ,并重啟設備。

yum -y install httpd mod_ssl

配置防火墻

firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=443/tcp
firewall-cmd --reload

開機啟動

systemctl start httpd
systemctl enable httpd

終端輸入如下指令檢查httpd的運行狀態

sudo systemctl status httpd

安裝PHP7

添加源

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 install php70w

安裝mysql5.7

1.安裝wget

  yum -y install wget

2.安裝源

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

3.安裝mysql

  yum install mysql-server

4.啟動mysql服務  

 systemctl start mysqld

5.查看MySQL的啟動狀態   

 systemctl status mysqld

6.開機啟動  

 systemctl enable mysqld
  systemctl daemon-reload

7.修改root本地登錄密碼

    查找mysql生成的隨機密碼  

 grep 'temporary password' /var/log/mysqld.log
  mysql -uroot -p

    修改密碼,注意:mysql5.7默認安裝了密碼安全檢查插件(validate_password),默認密碼檢查策略要求密碼必須包含:大小寫字母、數字和特殊符號,并且長度不能少于8位。否則會提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements錯誤

  ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

8.配置默認編碼為utf8

    修改/etc/my.cnf配置文件,在[mysqld]下添加編碼配置   

 [mysqld]
  character_set_server=utf8
  init_connect='SET NAMES utf8'

9.配置mysql遠程連接

  mysql -uroot -p
  use mysql;
  Grant all on *.* to 'root'@'%' identified by 'root用戶的密碼' with grant option;
flush privileges;

然后用以下命令查看哪些用戶和host可以訪問,%代表任意ip地址

select user,host from user;

防火墻添加3306端口

firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload

10.mysql忘記密碼

1.修改MySQL的配置文件(默認為/etc/my.cnf),在[mysqld]下添加一行skip-grant-tables

2.service mysqld restart后,即可直接用mysql進入

3.

mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
  mysql> flush privileges;
  mysql> quit;

 將/etc/my.cnf文件還原,重新啟動mysql:service mysql restart,這個時候可以使用mysql -u root -p'123qwe'進入了

 mysql>SET PASSWORD = PASSWORD('newpasswd'); 設置新密碼

感謝你能夠認真閱讀完這篇文章,希望小編分享的“如何配置CentOS7+apache+php7+mysql5.7環境”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女