阿里云ECS安装配置Apache+PHP+MySQL环境(CentOS 7)

本文详细介绍了如何在阿里云ECS的CentOS 7系统上安装和配置Apache、PHP7.0及MySQL。包括apache的安装配置,php7.0的yum源获取与安装,mysql的下载与初始化,以及防火墙规则和安全组的设置,确保外网可以成功访问和远程连接MySQL。

apache安装配置

1.安装

yum install httpd

在这里插入图片描述
2.启动apache

systemctl start httpd

在这里插入图片描述
3.查看apache服务器状态

systemctl status httpd

在这里插入图片描述
4.apache配置

vim /etc/httpd/conf/httpd.conf

重启修改配置
systemctl reload httpd.service

5.开启防火墙80端口

查看端口
firewall-cmd --list-ports  
添加端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
重启防火墙
firewall-cmd --reload

6.添加安全组规则在这里插入图片描述
7.外网输入ip访问在这里插入图片描述

8.其他的apache操作指令

systemctl start httpd.service   启动

systemctl status httpd.service 查看状态

systemctl stop httpd.service 停止

systemctl restart httpd.service 重启

systemctl reload httpd.service   重启修改配置

systemctl enable httpd.service   配置开机自启动

php7.0安装

1.获取php7.0的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

在这里插入图片描述
2.查看php7.0扩展

yum search php70w

在这里插入图片描述
2.安装通用扩展(安装扩展yum install 扩展名)

yum install php70w php70w-fpm php70w-cli php70w-common php70w-devel php70w-gd php70w-pdo php70w-mysql php70w-mbstring php70w-bcmath

在这里插入图片描述
在这里插入图片描述
3.查看php版本

php -v

在这里插入图片描述
4.其他的php操作指令

systemctl start php-fpm.service   启动

systemctl status php-fpm.service 查看状态

systemctl stop php-fpm.service 停止

systemctl restart php-fpm.service 重启

systemctl reload php-fpm.service   重启修改配置

systemctl enable php-fpm.service   配置开机自启动

mysql安装

1.下载mysql的repo源

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

在这里插入图片描述
2.安装下载好的mysql-community-release-el7-5.noarch.rpm包

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

在这里插入图片描述
3.安装mysql

yum install mysql-community-server

在这里插入图片描述
4.启动MySQL

systemctl start mysqld

5.初始登录MySQL(不需要密码)

mysql -u root

在这里插入图片描述
6.设置密码为root

set password for 'root'@'localhost' =password('root');

7.退出重新登录

 exit;

在这里插入图片描述

  mysql -u root -p

在这里插入图片描述

8.开启防火墙3306端口

  查看端口
    firewall-cmd --list-ports  
    添加端口
    firewall-cmd --zone=public --add-port=3306/tcp --permanent
    重启防火墙
    firewall-cmd --reload

9.远程连接MySQL

root是用户名,%是所有ip地址,你也可以写自己的IP地址比较安全,password是远程连接的密码。

grant all privileges on *.* to root@'%'identified by 'password';

也可以通过下面的指令创建新的用户来分配权限。

username是用户名,%是所有IP地址,如果输入的是IP地址,就规定只有改IP地址才能使用,password是登录密码。

create user 'username'@'%' identified by 'password';

添加安全组规则在这里插入图片描述
Navicat连接
在这里插入图片描述

10.开机启动MySQL

vi /etc/rc.local

将service mysqld start添加进去
在这里插入图片描述
11.其他的MySQL操作指令

首先启动MySQL:systemctl start mysqld

查看MySQL状态:systemctl status mysqld

重启MySQL指令:systemctl restart mysqld

停止MySQL指令:systemctl stop mysqld
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值