- 执行如下命令,安装Apache服务及其扩展包。
$ yum -y install httpd httpd-manual mod_ssl mod_perl mod_auth_mysql
启动Apache服务
$ systemctl start httpd
- 安装并配置MySQL
执行以下命令,下载并安装MySQL官方的Yum Repository。
$ rpm -e mariadb-libs --nodeps
$ yum install -y https://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-common-5.7.35-1.el7.x86_64.rpm
$ yum install -y https://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-libs-5.7.35-1.el7.x86_64.rpm
$ yum install -y https://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-libs-compat-5.7.35-1.el7.x86_64.rpm
$ yum install -y https://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-client-5.7.35-1.el7.x86_64.rpm
$ yum install -y https://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-server-5.7.35-1.el7.x86_64.rpm
查看MySQL版本号。
$ mysql -V
启动数据库
$ systemctl start mysqld
查看数据库运行状态
$ systemctl status mysqld
开机自启
$ systemctl enable mysqld
查看密码
$ grep "password" /var/log/mysqld.log
登录mysql
$ mysql -uroot -p<password>
修改密码安全策略为低
mysql> set global validate_password_policy=0;
修改root本地登录密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678';
授予root远程管理权限
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345678';
退出
mysql> exit
- 安装php
安装PHP环境
$ yum -y install php php-mysql gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap
创建PHP测试页面
$ echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
重启Apache服务
$ systemctl restart httpd
通过访问 公网IP/phpinfo.php 查看php是否配置正确
- 安装 phpMyAdmin
创建phpMyAdmin数据存放目录
mkdir -p /var/www/html/phpmyadmin
下载phpMyAdmin压缩包
wget --no-check-certificate https://files.phpmyadmin.net/phpMyAdmin/4.0.10.20/phpMyAdmin-4.0.10.20-all-languages.zip
安装unzip
yum install -y unzip
解压phpMyAdmin压缩包
unzip phpMyAdmin-4.0.10.20-all-languages.zip
复制phpMyAdmin文件到数据存放目录
mv phpMyAdmin-4.0.10.20-all-languages/* /var/www/html/phpmyadmin
网页访问 IP/phpmyadmin 页面
用户 root
密码 12345678