2025年centos7安装php环境_docker搭建php开发环境

centos7安装php环境_docker搭建php开发环境centos7 php 环境手动搭建 1 先安装 apache yum 安装 yum install httpd 进入配置文件 vi etc httpd conf httpd conf etc httpd conf httpd conf 为配置文件位置 apache 默认就是使用 80 端口 防火墙开启 80 端口 一般例如在阿里云网站控制台直接开启即可 服务器常用指令

centos7 php环境手动搭建:

1.先安装apache:

yum安装
yum install httpd
进入配置文件
vi /etc/httpd/conf/httpd.conf( /etc/httpd/conf/httpd.conf为配置文件位置)
apache默认就是使用80端口
防火墙开启80端口(一般例如在阿里云网站控制台直接开启即可)

服务器常用指令:

linux常用服务的启动、停止、重启操作
服务/操作 启动 停止 重启
apache
systemctl start httpd 开启
systemctl stop httpd 停止
systemctl restart httpd 重启

nginx
systemctl start nginx 开启
systemctl stop nginx 停止
systemctl restart nginx 重启

mysql
systemctl start mysqld 开启
systemctl stop mysqld 停止
systemctl restart mysqld 重启

设置开机启动/关闭

systemctl enable httpd.service #开机启动
systemctl disable httpd.service #开机不启动
其他类似

查询端口是否开放

firewall-cmd –query-port=8080/tcp

开放80端口

firewall-cmd –permanent –add-port=80/tcp

移除端口

firewall-cmd –permanent –remove-port=8080/tcp

重启防火墙(修改配置后要重启防火墙)

firewall-cmd –reload

参数解释

1、firwall-cmd:是Linux提供的操作firewall的一个工具;
2、–permanent:表示设置为持久;
3、–add-port:标识添加的端口;

开启

service firewalld start

重启

service firewalld restart

关闭

service firewalld stop

systemctl status httpd.service
systemctl start mysqld.service #启动mysql服务
systemctl status mysqld.service #查看mysql服务状态

解决方案:

开启httpd

systemctl start httpd.service

进入httpd.conf文件

vi /etc/httpd/conf/httpd.conf
更改监听端口

更改文件路径


更改路径下执行文件名(my.php)


配置好保存退出

启动服务

systemctl start httpd.service

安装mysql

yum install mysql mysql-server
不多解释

yum安装php

yum install php php-devel

重启apache 使之生效

systemctl restart httpd.service

/var/www/html/下建立一个PHP文件(my.php)

内容

重启apache 浏览器输入IP即可看见PHP页面

安装PHP扩展

yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

重启apache : systemctl restart httpd.service

测试MYSQOL连接

connect_error) { die(“连接失败: ” .

放在新的.php文件下 更改配置文件即可在浏览器下看见测试结果

编程小号
上一篇 2025-04-13 15:33
下一篇 2025-04-07 22:01

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/hz/119568.html