1、PHP是什么?
在网站的服务器端,实现服务器程序(网站功能)业务逻辑的一门常见的编程语言。
做网站:web应用程序开发
web程序的架构:B\S
B:browser 浏览器
S:Server 服务器
完成一个可以被浏览器访问的应用程序。
注意:
PHP是解释运行,所以有些错误,到真正运行才会暴露。
<?php
php代码
?>
编译环境和运行环境要一致。
2、搭建一个web应用程序的开发环境
1、安装apache服务器
(1)准备安装包:httpd-2.4.18-win64-VC14.zip 解压包安装方式(2)启动httpd出现缺少文件或出现错误,安装vc_redist.2015.x64.exe(3)解压完成后,修改配置文件:/Apache24/conf/httpd.conf
(1)ServerRoot "D:/php/Apache24"(2)DocumentRoot "D:/php/Apache24/htdocs"(4)安装apache服务:"D:\php\Apache24\bin\httpd.exe" -k install -n Apache2.4
切记,包含引号。该命令的意思是,安装apache服务,并将该服务名称命名为Apache2.4(你也可以改成别的),回车。
注意执行结果:
Errors reported here must be corrected before the service can be started.
意思是,若该句话后面有错误信息,则表示服务安装失败,需要先改正错误。若没有,则成功。
(5)打开/Apache24/bin/ApacheMonitor.exe,执行start,通过浏览器访问:localhost
遇到错误:
Forbidden
You don't have permission to access / on this server.
修改配置文件:httpd.conf中的:
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
allow from all
</Directory>
配置完成:
It works!
2、apache服务器的使用与介绍
1、管理与配置端口
apache安装好后,操作系统是以服务的方式管理。可以通过服务来启动和关闭,也可以通过 ApacheMonitor.exe来管理。通过命令行:(1)httpd -k start 打开(2)httpd -k shutdown 停止(3)httpd -k restart 重启可以将apache的bin目录的绝对路径加到环境变量的path中。
在httpd.conf文件中配置端口: Listen 81 修改后重启生效
apache可同时占用多个端口:List