阿里云Centos7+Apache+PHP+MySQL+phpMyAdmin+Git 環(huán)境配置

首先登錄Centos
ssh root@xxx.xxx.xxx.xxx –i /xxx.pem

安裝Apache
  1. 命令安裝:
    yum install -y httpd
  2. 安裝成功后,開啟Apache:
    systemctl start httpd.service
相關(guān)命令
# systemctl start httpd.service          //啟動(dòng)Apache
# systemctl stop httpd.service          //關(guān)閉Apache
# systemctl restart httpd.service      //重啟Apache
# systemctl enable httpd.service     //設(shè)置開機(jī)自啟
或者
# systemctl start httpd
  1. 進(jìn)入根目錄:cd /var/www/html/,然后創(chuàng)建index.html,然后瀏覽器直接訪問(如圖)
    image.png
  2. 查看是否開機(jī)自啟
    systemctl is-enabled httpd.service;echo $?
    如果disabled,則需要開機(jī)自啟輸入:
    systemctl enable httpd.service
安裝PHP
  1. 命令安裝:
    yum -y install php
  2. 重啟Apache,讓PHP生效:
    systemctl restart httpd.service
  3. 查看PHP版本:
    php -v
    image.png
  4. 配置php:
    vi /etc/php.ini
    ...
    重啟服務(wù)器生效systemctl restart httpd
MySQL分支MariaDB(個(gè)人不推薦,因?yàn)椴皇煜ぃ?/h5>

yum下沒有mysql-server包,需要下載后安裝:
yum -y install mysql mysql-server mysql-devel,會(huì)先下載,然后輸入y安裝,然而又出現(xiàn)了問題,一些常用的MySQL命令都不能使用,原因是在CentOS 7中,默認(rèn)安裝的MySQL是它的分支MariaDB,所以常規(guī)的MySQL命令是不能用的。

MySQ安裝(個(gè)人推薦)
  1. 添加 MySQL Yum Repository 到你的系統(tǒng) repository 列表中:
    yum localinstall mysql-community-release-el7-5.noarch.rpm
    提示Is this ok [y/d/N],輸入:y。
  2. 安裝 MySQL:
    yum install mysql-community-server
    提示Is this ok [y/d/N],輸入:y。
  3. 啟動(dòng)MySQL Server:
    systemctl start mysqld
  4. 查看是否成功:


    image.png
  5. 重設(shè)root密碼:
    set password for 'root'@'localhost'=password(‘新密碼');
  6. 查看MySQL是否開機(jī)啟動(dòng)
    systemctl is-enabled mysql.service;echo $?
    如果enabled則說明是開機(jī)自動(dòng),如果不是,執(zhí)行:
    chkconfig --levels 235 mysqld on

尼瑪!MySQL真tm折騰...

安裝phpMyAdmin
  1. 安裝:
    yum install phpmyadmin php-mcrypt
    提示Is this ok [y/d/N],輸入:y。
  2. 修改配置文件
    vi /etc/httpd/conf.d/phpMyAdmin.conf
    做一下修改:
    image.png
  3. 瀏覽器訪問phpMyAdmin:


    image.png
安裝Git
  1. 安裝:
    yum install git-core
    提示Is this ok [y/d/N],輸入:y。
  2. 好了,去拉代碼咯!!!
    git clone ...
    哦哦,拉下來代碼后記得分配下權(quán)限...

MySQL安裝參考:https://yq.aliyun.com/articles/47237

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容