這篇文章主要介紹了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-server4.啟動mysql服務
systemctl start mysqld#5.檢視MySQL的啟動狀態
systemctl status mysqld6.開機啟動
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
##
[mysqld] character_set_server=utf8 init_connect='SET NAMES utf8'#8.設定預設編碼為utf8
##
mysql -uroot -p use mysql; Grant all on *.* to 'root'@'%' identified by 'root用户的密码' with grant option; flush privileges;
## 修改/etc/my.cnf設定文件,在[mysqld]下新增編碼設定
select user,host from user;
#9.設定mysql遠端連線
firewall-cmd --zone=public --add-port=3306/tcp --permanent firewall-cmd --reload#######9.設定mysql遠端連線### ######
mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost'; mysql> flush privileges; mysql> quit;#########然後用以下命令查看哪些使用者和host可以訪問,%代表任意ip位址#########rrreee####### ##防火牆新增3306埠#########rrreee##########10.mysql忘記密碼######1.修改MySQL的設定檔(預設為/etc/my .cnf),在[mysqld]下方加入一行skip-grant-tables######2.service mysqld restart後,即可直接用mysql進入######3.######## ##rrreee######### 將/etc/my.cnf檔案還原,重新啟動mysql:service mysql restart,這個時候可以使用mysql -u root -p'123qwe'進入了###### # mysql>SET PASSWORD = PASSWORD('newpasswd'); 設定新密碼############總結#########
以上是php7和apache與CentOS7和mysql5.7的設定教學詳解的詳細內容。更多資訊請關注PHP中文網其他相關文章!