linux环境下配置Apache与PHP

第一步:打开Apache的配置文件

vim /usr/local/apache2/conf/httpd.conf
/ServerName
加一行ServerName localhost:80  //常见会写错成ServieName

第二步:配置Apache语言支持中文

打开注释159行和483行

/nego和/languages

166行添加:

AddHandler php7-script .php
AddType text/html .php

第三步:添加index.php默认首页

270行左右

/dir-module

第四步:让Apache优先支持中文

vim /usr/local/apache2/conf/extra/httpd-languages.conf
19行:/DefaultLanguage zh-CN
78行:LanguagePriority zh-CN en....................把中文首选
cd /usr/local/apache2
bin/apachectl -k start         //重启Apache

第五步:在Windows中配置本地Dns

运行(Win+R),drivers回车到hosts修改域名指向:ip 域名

然后测试ping一下(特别注意只能用IDEA或者其他代码编辑器修改,因为记事本修改没用)

第六步:编写php测试脚本

cd /usr/local/apache2/htdocs   //htdocs是Apache的默认目录
rm -rf index.html
vim index.php
<?php
    phpinfo();
?>

从网页输入192.168.1.1/index.php 
  

如果是白屏就一直重启Apache服务就行

pkill httpd
cd /usr/local/apache2
bin/apachectl 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值