Centos7单主机部署 LAMP + phpmyadmin 服务
LAMP -> centos + apache + mysql + php + phpmyadmin
一:搭建yum仓库:
安装utils:
yum -y install yum-utils
centos7镜像:
http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1804.iso
http://mirrors.163.com/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1804.iso
http://mirrors.aliyun.com/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1804.iso
添加yum配置
http://mirrors.163.com/centos/7.5.1804/os/x86_64/
https://mirrors.aliyun.com/centos/7.5.1804/os/x86_64/
yum clean all 清除缓存
yum repolist all 刷新yum仓库
二:安装apache服务
yum -y install httpd #安装httpd服务
systemctl start httpd.service #启动httpd服务
systemctl enable httpd.servicce #设置开机启动
三:安装MySQL服务
yum -y install mariadb-server #安装mysql服务
systemctl start mariadb.service #启动mysql服务
systemctl enable mariadb.service #设置开机启动
mysqladmin -u root password "root“ #设置mysql的开机密码
四:安装php服务
yum -y install php php-mysql php-fpm php-mbstring #安装php相关服务
systemctl start php-fpm.service
systemctl enable php-fpm.service
systemctl restart httpd.service
五:安装phpmyadmin数据库管理工具
cd /var/www/html
wget https://files.phpmyadmin.net/phpMyAdmin/4.8.1/phpMyAdmin-4.8.1-all-languages.zip
mkdir phpmyadmin
unzip phpMyAdmin-4.8.1-all-languages.zip -d phpmyadmin/
mkdir phpmyadmin
yum -y zip unzip
unzip phpMyAdmin-4.8.1-all-languages.zip -d phpmyadmin/
mv /var/www/html/phpmyadmin/phpMyAdmin-4.8.1-all-languages/* /var/www/html/phpmyadmin/
cp /var/www/html/phpmyadmin/config.sample.inc.php /var/www/html/phpmyadmin/config.inc.php
六:测试服务
echo "<?php phpinfo();?>“>> /var/www/html/index.php
> http://10.0.0.204/index.php
> http://10.0.0.204/phpmyadmin
x.py
from fabric.api import * env.usr = "root" env.hosts = ["10.0.0.203"] env.password = { 'root@10.0.0.203:22':'密码' } @task def config_yum(): run("yum-config-manager --add http://mirrors.163.com/centos/7.5.1804/os/x86_64/") run("echo 'gpgcheck=0' >> /etc/yum.repos.d/mirrors.163.com_centos_7.5.1804_os_x86_64_.repo") run("yum clean all") run("yum repolist all") @task def install_apache(): run("yum -y install httpd") @task def install_mysql(): run("yum -y install mariadb-server") @task def install_php(): run("yum -y install php php-fpm php-mysql php-mbstring") @task def install_phpmysdmin(): with cd ("/var/www/html/"): run("echo'<?php phpinfo();?>' >> index.php") run("wget https://files.phpmyadmin.net/phpMyAdmin/4.0.10.20/phpMyAdmin-4.0.10.20-all-languages.tar.gz") run("mkdir phpmyadmin") run("tar -zxf phpMyAdmin-4.0.10.20-all-languages.tar.gz -C phpmyadmin/") run("mv /var/www/html/phpmyadmin/phpMyAdmin-4.0.10.20-all-languages/* /var/www/html/phpmyadmin/") run("cp /var/www/html/phpmyadmin/config.sample.inc.php /var/www/html/phpmyadmin/config.inc.php") @task def start_server(): run("systemctl start httpd.service") run("systemctl enable httpd.service") run("systemctl start mariadb.service") run("systemctl enable mariadb.service") run("mysqladmin -uroot password 'z'") run("systemctl start php-fpm.service") run("systemctl enable php-fpm.service") def run_all(): execute(config_yum) execute(install_apache) execute(install_mysql) execute(install_php) execute(install_phpmysdmin) execute(start_server) if __name__ == "__main__" : run_all()