PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

怎么把php项目部署到apache上

王林
王林 原创
2021-06-09 14:09:39 4399浏览

把php项目部署到apache上的方法:首先安装apache和php,给需要写入的文件赋予权限;然后编辑httpd.conf配置文件,使apache支持php;最后上传php项目到正确目录下即可。

本文操作环境:windows10系统、php 5&&apache 2.2、thinkpad t480电脑。

我们要想将php项目部署到apache上,首先要做的就是安装apache和php。

安装apache和php然后进行后续操作(以63服务器的安装路径为例)

首先查看php项目运行的报错信息

路径:  cd  /var/log/httpd/error_log

如果错误如下:

378a6dd15e6f1f9de93db9628ebbd3e.png

可以尝试给需要写入的文件赋权限,例如: 

chmod 777 ../type.json

然后编辑httpd.conf文件,使apache支持php

[root@localhost conf]# vim /etc/httpd/conf/httpd.conf

找到  AddType text/html .shtml

在后面添加:     

AddType application/x-httpd-php .php(使Apcche支持PHP)
AddType application/x-httpd-php-source .php5

找到      #ServerName www.example.com:8 

修改为:     ServerName localhost:80

找到      DirectoryIndex index.html

添加        DirectoryIndex index.html index.php  

修改默认的Web站点目录

找到          DocumentRoot "/usr/local/apache2/htdocs"

修改为      DocumentRoot "/var/www/html" --该目录为自己创建的目录

找到          

修改为     

接着php项目包存放位置:  /var/www/html

最后apche启动和停止

[root@localhost httpd]# /etc/init.d/httpd start
[root@localhost httpd]# /etc/init.d/httpd stop

相关视频分享:编程视频

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。