CentOS7+apache+php7+mysql5.7配置教程詳解
yum upgrade yum install net-tools
安裝apache
關(guān)閉SELinux
編輯器打開 etc/selinux/config 文件,找到 SELINUX=enforcing 字段,將其改成 SELINUX=disabled ,并重啟設(shè)備。
yum -y install httpd mod_ssl
配置防火墻
firewall-cmd --permanent --add-port=80/tcp firewall-cmd --permanent --add-port=443/tcp firewall-cmd --reload
開機(jī)啟動(dòng)
systemctl start httpd systemctl enable httpd
終端輸入如下指令檢查httpd的運(yùn)行狀態(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.啟動(dòng)mysql服務(wù)
systemctl start mysqld
5.查看MySQL的啟動(dòng)狀態(tài)
systemctl status mysqld
6.開機(jī)啟動(dòng)
systemctl enable mysqld systemctl daemon-reload
7.修改root本地登錄密碼
查找mysql生成的隨機(jī)密碼
grep 'temporary password' /var/log/mysqld.log mysql -uroot -p
修改密碼,注意:mysql5.7默認(rèn)安裝了密碼安全檢查插件(validate_password),默認(rèn)密碼檢查策略要求密碼必須包含:大小寫字母、數(shù)字和特殊符號(hào),并且長(zhǎng)度不能少于8位。否則會(huì)提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements錯(cuò)誤
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
8.配置默認(rèn)編碼為utf8
修改/etc/my.cnf配置文件,在[mysqld]下添加編碼配置
[mysqld] character_set_server=utf8 init_connect='SET NAMES utf8'
9.配置mysql遠(yuǎn)程連接
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的配置文件(默認(rèn)為/etc/my.cnf),在[mysqld]下添加一行skip-grant-tables
2.service mysqld restart后,即可直接用mysql進(jìn)入
3.
mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
mysql> flush privileges;
mysql> quit;
將/etc/my.cnf文件還原,重新啟動(dòng)mysql:service mysql restart,這個(gè)時(shí)候可以使用mysql -u root -p'123qwe'進(jìn)入了
mysql>SET PASSWORD = PASSWORD('newpasswd'); 設(shè)置新密碼
總結(jié)
以上所述是小編給大家介紹的CentOS7+apache+php7+mysql5.7配置教程詳解,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- CentOS7部署Flask(Apache、mod_wsgi、Python36、venv)
- centos7上編譯安裝php7以php-fpm方式連接apache
- Centos7的apache網(wǎng)站環(huán)境搭建wordpress
- Centos7重啟apache、nginx、mysql、php-fpm命令方法
- CentOS7下 Apache的安裝配置方法
- CentOS7服務(wù)器中apache、php7以及mysql5.7的安裝配置代碼
- 阿里云CentOS7搭建Apache+PHP+MySQL環(huán)境
- 詳解CentOS7安裝配置Apache HTTP Server
- Centos7.4服務(wù)器安裝apache及安裝過程出現(xiàn)的問題解決方法
相關(guān)文章
在Bash腳本中創(chuàng)建和使用數(shù)組方法總結(jié)
在本篇文章里小編給大家整理了關(guān)于在Bash腳本中創(chuàng)建和使用數(shù)組方法和相關(guān)知識(shí)點(diǎn),需要的朋友們?cè)趯W(xué)習(xí)下。2019-03-03
CentOS 7 虛擬機(jī)無法開機(jī)問題的快速解決方法
這篇文章主要介紹了CentOS 7 虛擬機(jī)無法開機(jī)問題的快速解決方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,感興趣的朋友一起看看吧2016-11-11
Win10 安裝Linux ubuntu-18.04雙系統(tǒng)(安裝指南)
這篇文章主要介紹了Win10+Linux ubuntu-18.04雙系統(tǒng)安裝教程,本文分步驟給大家記錄下來,需要的朋友可以參考下2019-10-10

