centos7 php环境搭建
centos7 php环境手动搭建:1.先安装apache:yum安装yum install httpd进入配置文件vi /etc/httpd/conf/httpd.conf( /etc/httpd/conf/httpd.conf为配置文件位置)apache默认就是使用80端口防火墙开启80端口(一般例如在阿里云网站控制台直接开启即可)服务器常用指令:linux常用服务的启动、停止、重启操作服务/
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)
内容 <?php phpinfo(); ?>
重启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连接
<?php $servername = "localhost"; $username = "username"; $password = "password"; // 创建连接 $conn = new mysqli($servername, $username, $password); // 检测连接 if ($conn->connect_error) { die("连接失败: " . $conn->connect_error); } echo "连接成功"; ?>放在新的.php文件下 更改配置文件即可在浏览器下看见测试结果
更多推荐
所有评论(0)