Linux 避免大家踩坑霜定。這里采用yum 安裝邑时!
1.安裝apache服務(wù)器
//1.安裝apache服務(wù)器,-y表示后面的提示全部都通過(以后就不會彈出選擇yes? no)
yum install httpd -y
//2.啟動apache服務(wù)器
systemctl start httpd
//其他常用命令
//重啟apache服務(wù)器
systemctl restart httpd
//關(guān)閉apache服務(wù)器
systemctl stop httpd
//3.使apache服務(wù)器開機自啟
systemctl enable httpd.service
2.安裝mysql數(shù)據(jù)庫
安裝mariadb數(shù)據(jù)汛闸,這個數(shù)據(jù)庫是mysql的一個分支珊楼,有專人維護,推薦使用绪爸。畢竟mysql已經(jīng)被oracle收購了湾碎,你懂得。
//1.安裝mariadb(mysql)數(shù)據(jù)庫
yum install mariadb mariadb-server -y
//2.啟動mariadb服務(wù)
systemctl start mariadb
//其他命令
//重啟mariadb服務(wù)
systemctl restart mariadb
//停止mariadb服務(wù)
systemctl stop mariadb
//3.使mariadb服務(wù)開機自啟
systemctl enable mariadb
配置mariadb數(shù)據(jù)庫
//1.輸入這個命令開始配置
mysql_secure_installation
//2.會提示你輸入當前的root密碼奠货,如果沒有設(shè)置過介褥,就直接回車
Enter current password for root (enter for none):
//3.提示是否設(shè)置root密碼,輸入y递惋,回車
Set root password? [Y/n]
//4.輸入root密碼
New password:
//5.確認root密碼
Re-enter new password:
//6.移除匿名用戶柔滔,輸入y,回車
Remove anonymous users? [Y/n]
//7.禁用遠程root用戶登錄萍虽,這個看個人需求睛廊,如果你想在遠程連接mysql,你就輸入n杉编,回車超全;如果為了安全考慮,不允許的話邓馒,輸入y嘶朱,回車
Disallow root login remotely? [Y/n]
//8.是否移除test數(shù)據(jù)庫,不想要的話光酣,輸入y疏遏,回車
Remove test database and access to it? [Y/n]
//9.刷新權(quán)限、表救军,輸入y财异,回車
Reload privilege tables now? [Y/n]
至此,mariadb安裝唱遭、配置完成戳寸。
3.安裝php環(huán)境
//1.安裝php及其擴展,默認安裝的是php5.4
yum install php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash -y
//2.如果想升級php到5.6/7.0
//2.1首先需要升級軟件倉庫胆萧,依次執(zhí)行下面2個命令
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
//2.2刪除舊的php
yum remove php-common
//2.3安裝所需要的版本庆揩,5.6版本俐东,
yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring
//2.3安裝所需要的版本,7.0版本
yum install -y php70w php70w-opcache php70w-xml php70w-mcrypt php70w-gd php70w-devel php70w-mysql php70w-intl php70w-mbstring
//3.檢查php是否安裝成功
php -v //可以看到自己安裝的php版本信息
//4.重啟服務(wù)器
systemctl restart httpd
4.安裝phpmyadmin數(shù)據(jù)庫管理系統(tǒng)
//1.下載phpmyadmin包
wget https://files.phpmyadmin.net/phpMyAdmin/4.7.0/phpMyAdmin-4.7.0-all-languages.zip
//2.解壓phpmyadmin包
unzip phpMyAdmin-4.7.0-all-languages.zip
//2.如果沒有安裝unzip和zip订晌,請先安裝虏辫,然后再執(zhí)行上面的操作
yum install zip unzip -y
//3.將解壓后的phpmyadmin移動到/var/www/html/phpmyadmin文件夾下
//3.1首先創(chuàng)建phpmyadmin文件夾
mkdir /var/www/html/phpmyadmin
//3.2移動文件
mv phpMyAdmin-4.7.0-all-languages/* /var/www/html/phpmyadmin/
//4.重啟apache服務(wù)器
systemctl restart httpd
然后就可以在瀏覽器輸入 ip地址或域名/phpmyadmin訪問了,至此锈拨,CentOS7安裝apache砌庄、mysql、php奕枢、phpmyadmin完成了娄昆。