Php学习之Apache服务器详解
Php学习之服务器——Apache服务器详解
Iis服务器:主要是服务于微软,基于运行Microsoft windows的互联网基本服务
Lighttpd服务器:开源软件,针对高性能,底内存开销,cpu占用底,成熟度还不够
Apache服务器的介绍
1、 抓包软件:httpwatch.rar,了解发送和接受数据包
2、 Apache服务器的安装
1、 查看windows中已经安装的服务,确定原先没有安装apache
2、 安装apache服务器:
3、 测试是否真的成功。在浏览器中输入http://localhost/ 显示itworks,说明安装成功
3、 Apache服务器使用及配置,启动停止,安装和配置
1、参考Apache官方网站中文版参考手册
2、Apache安装成功以后,windows是以服务的方式来运行的。
3、大多数情况下,apahce服务器并不在本地,因此学习用命令行远程管理开启或者停止很重要。
Httpd –k start[shutdown"restart] 【注】httpd这个应用程序是在apache的安装文件的目录下的,设置环境变量有必要。
4、 Apache的默认端口是80:http://localhost:80/,在实际开发中,经常使用
netstat –an
查看机器有哪些端口在监听。
Netstat –anb
发现哪个程序监听该端口,从而使用kill命令关闭该进程
5、 apache如何配置端口:
apache同时可以监听多个端口,修改httpd.conf文件中配置,我们修改端口。修改完成之后重新启动apache服务器。
监听多个端口:
Apache实现同时监听多个端口。
6、 apache目录的详细解析:
站点的访问方式比较简单,可直接按照目录中子目录的路径来访问:
Apache是以模块形式来管理功能的。Apache在启动的时候会读httpd.conf这个文件,去加载modules中的各种.so文件的模块。
如果不想其加载(不使用其功能),可直接注释掉(前面加#号注释)。【注】正常情况下不改动其加载的模块……
Apache的核心服务是httpd的,然后依次加载各类服务,apache开源,可阅读其源代码。
(apache的运行机制图)
(apache生命周期图)
(apache启动图)
7、 apache的虚拟目录
需求:apache安装在c盘,完成将d盘中的一个文件夹作为站点来管理。
设置以实现:
1、 修改httpd.conf文件,添加一个虚拟目录的节点:
2、 修改httpd.conf文件,注销documentRoot主目录:
注销掉之后就不能直接访问apache安装目录下的默认目录网站了。
3、重启既可以实现。(写的内容有错,apache将重启失败,并报错!)
(原文件所在地址)
使用(虚拟目录之后进行的导向)
8、 设置apache的欢迎页面
需求:直接输入http://localhost/myblog,需要得到欢迎页面【注】myblog是存放网站的文件夹,而非文件。
实现:修改虚拟目录:
(在DirectoryIndex后面添加网页,当前目录的哈,作为欢迎界面)
9、 关于apache服务器的访问权限
设置对网站存放地点的访问权限:
Order确定权限的顺序,先考虑allow(图中为Allow from all),再考虑deny(图中没有写,则为null)
10、 apache中虚拟主机的配置
其实就是给自己的网站设置ip地址与虚拟域名,开始配置虚拟主机,然后在本地nds域名解析中假借域名以方便在浏览器中使用域名访问(域名访问,然后访问本地dns解析,找不到则远程域名解析)
1、 启用httpd-vhosts.conf
取消掉httpd.conf中httpd-vhosts.conf文件的注释,以示启动了
2、 在httpd-vhosts.conf中添加一条以配置虚拟主机
找到httpd-vhosts.conf文件,并在其中添加一条
在其中这样修改:
本地的DNS解析文件,增删改该文件以便域名解析(实际上是域名重定向,容易被黑客攻击)文件路径c:\\windows\system32\drivers\etc\hosts
远程DNS域名解析服务器地址:
修改本地的DNS解析文件,添加一条,以使得假的www.sohu.com重定向到本地网站。
详细说明访问网页的流程(php,jsp,asp,asp.net均适用)
时序图:
【注】在内网中配置公网(非127.0.0.1)ip的域名,电脑不会予以适配,同时还会指向127.0.0.1
虚拟主机ip地址相同,否则解析403错误

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The way to update ByBit exchanges varies by platform and device: Mobile: Check for updates and install in the app store. Desktop Client: Check for updates in the Help menu and install automatically. Web page: You need to manually access the official website for updates. Failure to update the exchange can lead to security vulnerabilities, functional limitations, compatibility issues and reduced transaction execution efficiency.

Detailed explanation and installation guide for PiNetwork nodes This article will introduce the PiNetwork ecosystem in detail - Pi nodes, a key role in the PiNetwork ecosystem, and provide complete steps for installation and configuration. After the launch of the PiNetwork blockchain test network, Pi nodes have become an important part of many pioneers actively participating in the testing, preparing for the upcoming main network release. If you don’t know PiNetwork yet, please refer to what is Picoin? What is the price for listing? Pi usage, mining and security analysis. What is PiNetwork? The PiNetwork project started in 2019 and owns its exclusive cryptocurrency Pi Coin. The project aims to create a one that everyone can participate

The official website entrance of the Coinsuper Exchange: https://www.coinsuper.com. The client download channels are: Windows client, macOS client, and mobile (iOS/Android). Registration requires an email, mobile phone number and password, and you need to complete real-name authentication before you can trade. The platform provides a variety of digital asset transactions, including Bitcoin, Ethereum, etc., with the transaction fee rate of 0.1% for both orders and acceptors. Security safeguards include cold wallet storage, dual-factor verification, anti-money laundering and anti-terrorism financing measures, and with security public

Ouyi OKX, the world's leading digital asset exchange, has now launched an official installation package to provide a safe and convenient trading experience. The OKX installation package of Ouyi does not need to be accessed through a browser. It can directly install independent applications on the device, creating a stable and efficient trading platform for users. The installation process is simple and easy to understand. Users only need to download the latest version of the installation package and follow the prompts to complete the installation step by step.

BITGet is a cryptocurrency exchange that provides a variety of trading services including spot trading, contract trading and derivatives. Founded in 2018, the exchange is headquartered in Singapore and is committed to providing users with a safe and reliable trading platform. BITGet offers a variety of trading pairs, including BTC/USDT, ETH/USDT and XRP/USDT. Additionally, the exchange has a reputation for security and liquidity and offers a variety of features such as premium order types, leveraged trading and 24/7 customer support.

Gate.io is a popular cryptocurrency exchange that users can use by downloading its installation package and installing it on their devices. The steps to obtain the installation package are as follows: Visit the official website of Gate.io, click "Download", select the corresponding operating system (Windows, Mac or Linux), and download the installation package to your computer. It is recommended to temporarily disable antivirus software or firewall during installation to ensure smooth installation. After completion, the user needs to create a Gate.io account to start using it.

Ouyi, also known as OKX, is a world-leading cryptocurrency trading platform. The article provides a download portal for Ouyi's official installation package, which facilitates users to install Ouyi client on different devices. This installation package supports Windows, Mac, Android and iOS systems. Users can choose the corresponding version to download according to their device type. After the installation is completed, users can register or log in to the Ouyi account, start trading cryptocurrencies and enjoy other services provided by the platform.

Need to download the Gate.io app to start your cryptocurrency journey? This guide details the latest version download steps for iOS, Android, and Windows devices. Simply visit the official website, find the download link and select the appropriate option based on your device. For iOS, it will go directly to the App Store, while Android and Windows users will download the APK or installer for manual installation. Once installed, you can launch the app and set up your account to step into the world of cryptocurrency.
