首先登錄Centos
ssh root@xxx.xxx.xxx.xxx –i /xxx.pem
安裝Apache
- 命令安裝:
yum install -y httpd - 安裝成功后,開啟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
- 進(jìn)入根目錄:
cd /var/www/html/,然后創(chuàng)建index.html,然后瀏覽器直接訪問(如圖)
image.png - 查看是否開機(jī)自啟
systemctl is-enabled httpd.service;echo $?
如果disabled,則需要開機(jī)自啟輸入:
systemctl enable httpd.service
安裝PHP
- 命令安裝:
yum -y install php - 重啟Apache,讓PHP生效:
systemctl restart httpd.service - 查看PHP版本:
php -v
image.png - 配置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è)人推薦)
- 添加 MySQL Yum Repository 到你的系統(tǒng) repository 列表中:
yum localinstall mysql-community-release-el7-5.noarch.rpm
提示Is this ok [y/d/N],輸入:y。 - 安裝 MySQL:
yum install mysql-community-server
提示Is this ok [y/d/N],輸入:y。 - 啟動(dòng)MySQL Server:
systemctl start mysqld -
查看是否成功:
image.png - 重設(shè)root密碼:
set password for 'root'@'localhost'=password(‘新密碼'); - 查看MySQL是否開機(jī)啟動(dòng)
systemctl is-enabled mysql.service;echo $?
如果enabled則說明是開機(jī)自動(dòng),如果不是,執(zhí)行:
chkconfig --levels 235 mysqld on
尼瑪!MySQL真tm折騰...
安裝phpMyAdmin
- 安裝:
yum install phpmyadmin php-mcrypt
提示Is this ok [y/d/N],輸入:y。 - 修改配置文件
vi /etc/httpd/conf.d/phpMyAdmin.conf
做一下修改:
image.png -
瀏覽器訪問phpMyAdmin:
image.png
安裝Git
- 安裝:
yum install git-core
提示Is this ok [y/d/N],輸入:y。 - 好了,去拉代碼咯!!!
git clone ...
哦哦,拉下來代碼后記得分配下權(quán)限...
MySQL安裝參考:https://yq.aliyun.com/articles/47237




