1. 程式人生 > >CentOS7服務器中apache、php7以及mysql5.7的安裝配置代碼

CentOS7服務器中apache、php7以及mysql5.7的安裝配置代碼

emctl 啟動mysql cin mod_ssl disable str apache set 啟動

技術分享圖片

  CentOS7服務器中apache、php7以及mysql5.7的配置代碼如下所示:

  yum upgradeyum install net-tools

  安裝apache

  (http://m.8682222.com)關閉SELinux編輯器打開 etc/selinux/config 文件,找到 SELINUX=enforcing 字段,將其改成 SELINUX=disabled ,並重啟設備。yum -y install httpd mod_ssl配置防火墻firewall-cmd --permanent --add-port=80/tcpfirewall-cmd --permanent --add-port=443/tcpfirewall-cmd --reload開機啟動systemctl start httpdsystemctl enable httpd終端輸入如下指令檢查httpd的運行狀態sudo systemctl status httpd

  安裝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安裝yum install php70w

  安裝mysql5.7

  1.安裝wget yum -y install wget

  2.安裝源 wget https://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 --permanentfirewall-cmd --reload

  10.mysql忘記密碼1.修改MySQL的配置文件(默認為/etc/my.cnf),在[mysqld]下添加一行skip-grant-tables2.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的安裝配置代碼,希望對大家有所幫助。

CentOS7服務器中apache、php7以及mysql5.7的安裝配置代碼