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的運行狀態(tài)
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的啟動狀態(tài)
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),默認密碼檢查策略要求密碼必須包含:大小寫字母、數(shù)字和特殊符號,并且長度不能少于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配置教程詳解,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對本站網(wǎng)站的支持!
版權聲明:本站文章來源標注為YINGSOO的內容版權均為本站所有,歡迎引用、轉載,請保持原文完整并注明來源及原文鏈接。禁止復制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務器上建立鏡像,否則將依法追究法律責任。本站部分內容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學習參考,不代表本站立場,如有內容涉嫌侵權,請聯(lián)系alex-e#qq.com處理。