前言:
本文是本人学习过程中对百度相关教程的整理补充。
正文:
SSH连接服务器
安装
Apache
yum -y install httpd
开启apache服务
systemctl start httpd.service
设置apache服务开机启动
systemctl enable httpd.service
测试: (由于防火墙未配置导致的无法打开,见下文)
安装MariaDB
yum -y install mariadb*
开启服务
systemctl start mariadb.service
设置开机启动服务
systemctl enable mariadb.service
设置密码
mysql_secure_installation
验证是否成功
mysql -uroot -p
MariaDB安装成功(按Ctrl+C返回)
安装PHP( CentOS7默认安装PHP5.4,安装PHP7见后文)
yum -y install php
PHP-MySQL关联
yum -y install php-mysql
rpm -ql php-mysql
安装常用PHP模块
yum -y install php-gd php-ldap php-odbcphp-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel libjpeg*php-imap php-pear php-mcrypt php-bcmath php-mhash libmcrypt php-devel
重启服务器
systemctl restart httpd
防火墙配置
开启端口
firewall-cmd --zone=public --permanent --add-port=80/tcp #Web服务器默认的端口
firewall-cmd --zone=public --permanent --add-port=3306/tcp #Mysql数据库默认的端口
重启防火墙
firewall-cmd --reload
更多命令
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
更新到PHP7
查看是否有老版本
yum list installed | grep php
移除老版本
yum remove php.x86_64 php-bcmath.x86_64 php-cli.x86_64 php-common.x86_64 php-devel.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mysql.x86_64 php-pdo.x86_64 php-pear.noarch php-process.x86_64 php-snmp.x86_64 php-soap.x86_64 php-xml.x86_64 php-xmlrpc.x86_64
linux的yum源不存在php7.x,先更改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
查看yum源中的php7.x
yum search php7
安装php72w和各种拓展
yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml php72w-pear
重启服务器
systemctl restart httpd
测试PHP
完成安装
教程来源:
https://blog.csdn.net/a203778513/java/article/details/80890748
https://www.pcgho.com/t-81833.html
https://developer.aliyun.com/adc/scenario/exp/fdecd528be6145dcbe747f0206e361f3