日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

centos7.2 Apache+PHP7.2+Mysql5.6环境搭建

發(fā)布時間:2024/4/17 数据库 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 centos7.2 Apache+PHP7.2+Mysql5.6环境搭建 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

yum安裝PHP7.2

由于linux的yum源不存在php7.x,所以我們要更改yum源:
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源中有沒有php7.x

yum search php7

看到下圖,證明php已經(jīng)存在yum源中

 

yum 安裝php72w和各種拓展,選自己需要的即可:
yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml

安裝完成

查看php版本

php -v

配置php.ini

vi /etc/php.ini 按下esc進(jìn)入命令模式

?

yum安裝Apacha

yum -y?install httpd

安裝Apache擴(kuò)展包

yum -y?install httpd-manual?mod_ssl mod_perl mod_auth_mysql

?

yum安裝Mysql

yum -y?install mysql

yum -y?install mysql-server

yum -y?install php-mysql

?

安裝mysql-server遇到問題

錯誤:No package mysql-server available.Package php-mysql-5.4.16-36.el7_1.x86_64 already installed and latest versionNothing to do

原因是因為CentOS 7 版本將MySQL數(shù)據(jù)庫軟件從默認(rèn)的程序列表中移除,用mariadb代替了

解決方案:從官網(wǎng)下載mysql-server

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm?

rpm -ivh?mysql-community-release-el7-5.noarch.rpm

yum install mysql-community-server

然后需要確定,輸入y回車即可

Is this ok[y/d/N]:y

?

安裝Mysql擴(kuò)展包

yum -y?install mysql-connector-odbc?mysql-devel?libdbi-dbd-mysql

?

配置Apache、mysql開機(jī)啟動

chkconfig httpd on

chkconfig mysqld on

或者

systemctl enable mysqld

systemctl daemon-reload

?

重啟Apache、mysql服務(wù)

service mysqld restart

service php-fpm start

systemctl restart httpd

?

查看mysql運(yùn)行狀態(tài)

service mysqld status

systemctl status mysqld.service

?

獲取MySQL的臨時密碼

grep 'temporary password' /var/log/mysqld.log

?

登陸并修改密碼

使用默認(rèn)的密碼登陸

mysql -uroot -p

用該密碼登錄到服務(wù)端后,必須馬上修改密碼,不然會報如下錯誤:

mysql> select @@log_error;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>

修改密碼

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123';

?

授權(quán)其他機(jī)器登陸

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;???#123456為你需要設(shè)置的密碼

mysql> FLUSH ?PRIVILEGES;

mysql> exit;

?

mysq配置默認(rèn)編碼為utf8

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

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

?

重新啟動mysql服務(wù)

默認(rèn)配置文件路徑:配置文件:/etc/my.cnf

日志文件:/var/log//var/log/mysqld.log

服務(wù)啟動腳本:/usr/lib/systemd/system/mysqld.service socket

文件:/var/run/mysqld/mysqld.pid

?

如果忘記密碼或者沒有從log日志中找到密碼

首先確認(rèn)服務(wù)器出于安全的狀態(tài),也就是沒有人能夠任意地連接MySQL數(shù)據(jù)庫。

修改MySQL的登錄設(shè)置:

vim /etc/my.cnf

[mysqld]的段中加上一句:skip-grant-tables

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

skip-grant-tables

保存并且退出vi。

重新啟動mysqld

service mysqld restart

Stopping MySQL: [ OK ]

Starting MySQL: [ OK ]

登錄并修改MySQL的root密碼

Welcome to?the MySQL monitor. Commands end?with?; or?\g.

Your MySQL connection?id is?3 to?server version: 3.23.56

Type ‘help;' or ‘\h'?for?help. Type ‘\c' to clear the buffer.

mysql> USE mysql ;

Database changed

mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ;

Query OK, 0 rows?affected (0.00 sec)

Rows?matched: 2 Changed: 0 Warnings: 0

mysql> flush privileges?;

Query OK, 0 rows?affected (0.01 sec)

mysql> quit

MySQL的登錄設(shè)置修改回來

vim /etc/my.cnf

將剛才在[mysqld]的段中加上的skip-grant-tables刪除

保存并且退出vim

重新啟動mysqld

service mysqld restart

Stopping MySQL: [ OK ]

Starting MySQL: [ OK ]

?

?

配置Apache項目

安裝完成Apache后,我們可以使用http://你的服務(wù)器ip/測試訪問Apache,如果能顯示如下圖,則說明Apache已經(jīng)安裝成功。

?

注:如果我們測試無法打開這個頁面,那么首先要考慮幾個情況:?

1、是不是開啟了iptables防火墻,如果是的話,可以用systemctl stop iptables關(guān)閉后再試

2、是不是開啟了firewalld防火墻,如果是的話,可以用systemctl stop firewalld關(guān)閉后再試

3、是不是開啟了SELinux功能,如果是的話,可以用setenforce 0臨時關(guān)閉SELinux后再試

4、重啟Apache 服務(wù)

systemctl restart httpd

?

Apache安裝好后配置文件在/etc/httpd/conf/httpd.conf編輯它

vim /etc/httpd/conf/httpd.conf

打開文件后,我們輸入/docu,然后按下回車,這樣就可以快速搜索到我們要找到內(nèi)容。如下圖,可以看到有兩個/var/www/html的地方,我們要修改的就是這兩個地方,把/var/www/html修改成我們想要的路徑,比如/www/soundasia-oa/public,該路徑為我們項目的啟動路徑,那么修改后就是這樣的。?

?

重啟Apache服務(wù)了

systemctl restart httpd

?

CentosApache重啟,mysql重啟, nginx 重啟方法

1.重啟 apache

service httpd restrat

/etc/init.d/httpd stop

/etc/init.d/httpd start

systemctl start httpd.service #啟動

systemctl stop httpd.service #停止

systemctl restart httpd.service #重啟

systemctl enable httpd.service #開機(jī)啟動

systemctl disable httpd.service #開機(jī)不啟動

systemctl status httpd.service?#檢查httpd狀態(tài)

2.重啟 mysql

service mysql restart

/etc/init.d/mysqld stop

/etc/init.d/mysqld start

3.重啟Nginx

service nginx restart

/etc/init.d/nginx stop

/etc/init.d/nginx start

linux版本重啟apache命令

Slackware Linux命令:

/etc/rc.d/rc.httpd restart

ubuntuDebian?系統(tǒng)命令:

/etc/init.d/apache2 restart

Fedora RedhatCentOS系統(tǒng)重啟Apache命令:

/etc/init.d/httpd restart

service httpd restart(CentOS 成功)

?

轉(zhuǎn)載于:https://www.cnblogs.com/mjhblog/p/10529036.html

總結(jié)

以上是生活随笔為你收集整理的centos7.2 Apache+PHP7.2+Mysql5.6环境搭建的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。