国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
1. Create a website with wamp
1.1 Understand the default website program
1.2 Create a new virtual host
2. Creating a website with Phpstudy
1.1 Effect demonstration
1.2 配置文件查看
httpd-vhosts.conf詳解
Home Backend Development PHP Tutorial Teach you to create a virtual host and run php projects (phpstudy + wamp)

Teach you to create a virtual host and run php projects (phpstudy + wamp)

Aug 07, 2022 pm 03:17 PM
php phpstudy wamp

Creation of PHP environment and virtual host (phpstudy wamp)

This article involves two PHP Integrated environment

  • phpstudy
  • wampserver

Both of these two include mysql apache php, phpstudy is more powerful than wamp, and is very Simple and easy to use.

phpstudy is easy to use because it helps us encapsulate many tedious and error-prone operations. However, if we use it directly, we do not understand the implementation behind it, so learning wamp first can familiarize us with the principles.

1. Create a website with wamp

1.1 Understand the default website program

After the installation is completed, the tray icon is normal green.
Teach you to create a virtual host and run php projects (phpstudy + wamp)

My program is installed in D:\wamp64. After finding it normal, directly access the page localhost. The default port is 80. You can ignore

Teach you to create a virtual host and run php projects (phpstudy + wamp)

to get a normal response. This page comes from D:\wamp64\www\index.php, which is under the wamp installation directory. The www folder stores the default website programs.

1.2 Create a new virtual host

At this point we need to understand a few files first.


  1. hosts, file location: C:\Windows\System32\drivers\etc
    Teach you to create a virtual host and run php projects (phpstudy + wamp)

Teach you to create a virtual host and run php projects (phpstudy + wamp)

The function is to establish an associated "database" between some commonly used URL domain names and their corresponding IP addresses. When the user enters a URL that needs to be logged in in the browser, the system will first automatically start from Hosts file looks for the corresponding IP address. Once found, the system will immediately open the corresponding web page. If not found, the system will submit the URL to the DNS domain name resolution server for IP address resolution.

  1. httpd.conf, file location: D:\wamp64\bin\apache\apache2.4.17\conf

This file is the configuration file of apache and generally does not need to be changed.

  1. httpd-vhosts.conf, file location: D:\wamp64\bin\apache\apache2.4.17\conf\extra

This file is a virtual host file. When creating a new website, it needs to be configured in this file to take effect.


The following I have a requirement:

I think it is too wasteful to run only one program on one computer, and port 80 of my local machine is occupied. I want to open a website for ittest.com:81 to access

1) According to the function of the hosts file, when I visit test.com:81, I need it to jump directly without going. Perform dns domain name resolution

So, add a line in the hosts file according to the fixed format

#?當(dāng)訪問www.test.com時?,?我們告訴電腦直接解析到本機127.0.0.1?不用去dns域名解析。#?:81屬于端口號?不需要添加到這里127.0.0.1?www.test.com

2). The previous step only tells the computer to resolve to the local, but we haven’t done that yet. The corresponding virtual host is

, so a new virtual host needs to be configured in httpd-vhosts.conf.

<virtualhost>
????DocumentRoot?"網(wǎng)站程序目錄"
????ServerName?綁定的域名
????ServerAlias?綁定的域名別名
??<directory>
??????Options?FollowSymLinks?ExecCGI
??????AllowOverride?All
??????Order?allow,deny
??????Allow?from?all
??????Require?all?granted
??</directory>
</virtualhost>

Teach you to create a virtual host and run php projects (phpstudy + wamp)

In additionVirtuaHost *:Port number

After filling in here, it will not take effect because we have not allowed apache to be enabled. Virtual host, now enable it, in the httpd.conf file

Teach you to create a virtual host and run php projects (phpstudy + wamp)

Finally set the default port of wamp's apache service:

Teach you to create a virtual host and run php projects (phpstudy + wamp)
Teach you to create a virtual host and run php projects (phpstudy + wamp)
Successfully obtained response.

2. Creating a website with Phpstudy

After reading wamp, it feels very cumbersome. Next, try using phpstudy.

The demand remains unchanged, let’s create a websitewww.test.com:81,

1.1 Effect demonstration

1), directly Start apache

Teach you to create a virtual host and run php projects (phpstudy + wamp)

2) Create website

Teach you to create a virtual host and run php projects (phpstudy + wamp)

根目錄選擇項目的根目錄

三)、查看效果

Teach you to create a virtual host and run php projects (phpstudy + wamp)

這就完成了…

1.2 配置文件查看

使用過wamp后我們知道,配置一個虛擬主機需要改三個文件,下面看一下phpstudy的操作。

一)、hosts

由于做wamp的時候已經(jīng)手動添加過了,所以這個文件看不出來兩者的差異。

二)、httpd.conf和vhost.conf

Teach you to create a virtual host and run php projects (phpstudy + wamp)

在wamp中,我們將多個虛擬主機的配置項都放在了一個文件中。

在phpstudy里,將每個網(wǎng)站的配置項單獨抽離出個自己的文件并放到了一個文件夾中。

httpd-vhosts.conf詳解

首先看下面的配置:

<virtualhost>
????ServerAdmin?webmaster@dummy-host.example.com
????DocumentRoot?"D:/xampp/htdocs/wherein"
????ServerName?www.shop_dev.com
????ErrorLog?"logs/wherein.com-error.log"
????CustomLog?"logs/wherein.com-access.log"?common
????<directory>
????Options?FollowSymLinks?IncludesNOEXEC?Indexes
????DirectoryIndex?index.html?index.htm?index.php
????AllowOverride?all
????Order?Deny,Allow
????Allow?from?all
????Require?all?granted
????</directory>
</virtualhost>

ServerAdmin指令:

語法: ServerAdmin email-address|URL

用來設(shè)置服務(wù)器返回給客戶端的錯誤信息中包含的管理員郵件地址。便于用戶在收到錯誤信息后能及時與管理員取得聯(lián)系。

ServerName指令:

語法:ServerName [scheme://] FQDN [:port]

用來設(shè)置服務(wù)器用于辨識自己的主機名和端口號。主要用于創(chuàng)建重定向URL。

DocumentRoot指令:

語法:DocumentRoot directory-path

用來設(shè)置httpd提供服務(wù)的目錄。即你所在項目入口處的文件夾。

ErrorLog指令:

語法: ErrorLog file-path

來設(shè)置當(dāng)服務(wù)器遇到錯誤時記錄錯誤日志的文件。如果file-path不是以/開頭的絕對路徑,那么將會被認(rèn)為是一個相對于ServerRoot的相對路徑。

CustomLog指令:

語法: ErrorLog file-path common

設(shè)置日志文件,并指明日志文件所用的格式(通常通過格式的名字)。

為主目錄或虛擬目錄設(shè)置權(quán)限。

特性:

Options FollowSymLinks IncludesNOEXEC Indexes

命 令 說 明
Indexes 允許目錄瀏覽當(dāng)客戶僅指定要訪問的目錄,但沒有指定要訪問目錄下的哪個文件,而且目錄下不存在默認(rèn)文檔時,Apache以超文本形式返回目錄中的文件和子目錄列表(虛擬目錄不會出現(xiàn)在目錄列表中)
MultiViews 允許內(nèi)容協(xié)商的多重視圖MultiViews其實是Apache的一個智能特性。當(dāng)客戶訪問目錄 中一個不存在的對象時,如訪問“http://192.168.66.6/data/a”,則Apache會查找這個目錄下所有a.*文件。由于 data目錄下存在a.gif文件,因此Apache會將a.gif文件返回給客戶,而不是返回出錯信息
All All包含了除MultiViews之外的所有特性,如果沒有Options語句,默認(rèn)為All
ExecCGI 允許在該目錄下執(zhí)行CGI腳本
FollowSymLinks 可以在該目錄中使用符號連接
Includes 允許服務(wù)器端包含功能
IncludesNoExec 允許服務(wù)器端包含功能,但禁用執(zhí)行CGI腳本

一旦定義允許目錄瀏覽,就會將Web站點的文件夾和文件名結(jié)構(gòu)暴露給黑客。目錄瀏覽還會允許黑客瀏覽文件并掌握服務(wù)器配置信息,所以指定該權(quán)限往往帶來安全性上的隱患。除非有充足的理由要使用目錄瀏覽,否則應(yīng)該禁用它。

DirectoryIndex index.html index.htm index.php

設(shè)置訪問目錄后進入的默認(rèn)文件

AllowOverride all

定義位于每個目錄下.htaccess(訪問控制)文件中的指令類型。none為禁止使用.htaccess文件

Order Deny,Allow

Allow from all

設(shè)置缺省的訪問權(quán)限與Allow和Deny語句的處理順序

allow, deny:缺省禁止所有客戶機的訪問,且Allow語句在Deny語句之前被匹配。如果某條件既匹配Deny語句又匹配Allow語句,則Deny語句會起作用(因為Deny語句覆蓋了Allow語句)。

deny, allow:缺省允許所有客戶機的訪問,且Deny語句在Allow語句之前被匹配。如果某條件既匹配Deny語句又匹配Allow語句,則Allow語句會起作用(因為Allow語句覆蓋了Deny語句)。

eg.

Order?deny?,allow
Deny?from?baidu.com
Deny?from?192.168.66.6除了來自baidu.com域和ip地址為192.168.66.6的客戶機外,允許所有客戶機訪問
Order?deny?,allow
Allow?from?192.168.66.6
Deny?from?192.168.66.1既匹配Deny語句又匹配Allow語句,由于allow語句覆蓋了deny語句,所以是允許所有客戶機訪問
Order?allow?,deny
Allow?from?192.168.66.6
Deny?from?192.168.66.1既匹配Deny語句又匹配Allow語句,由于deny語句覆蓋了allow語句,所以是禁止所有客戶機訪問

推薦學(xué)習(xí):《PHP視頻教程

The above is the detailed content of Teach you to create a virtual host and run php projects (phpstudy + wamp). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Why We Comment: A PHP Guide Why We Comment: A PHP Guide Jul 15, 2025 am 02:48 AM

PHPhasthreecommentstyles://,#forsingle-lineand/.../formulti-line.Usecommentstoexplainwhycodeexists,notwhatitdoes.MarkTODO/FIXMEitemsanddisablecodetemporarilyduringdebugging.Avoidover-commentingsimplelogic.Writeconcise,grammaticallycorrectcommentsandu

How to Install PHP on Windows How to Install PHP on Windows Jul 15, 2025 am 02:46 AM

The key steps to install PHP on Windows include: 1. Download the appropriate PHP version and decompress it. It is recommended to use ThreadSafe version with Apache or NonThreadSafe version with Nginx; 2. Configure the php.ini file and rename php.ini-development or php.ini-production to php.ini; 3. Add the PHP path to the system environment variable Path for command line use; 4. Test whether PHP is installed successfully, execute php-v through the command line and run the built-in server to test the parsing capabilities; 5. If you use Apache, you need to configure P in httpd.conf

Your First PHP Script: A Practical Introduction Your First PHP Script: A Practical Introduction Jul 16, 2025 am 03:42 AM

How to start writing your first PHP script? First, set up the local development environment, install XAMPP/MAMP/LAMP, and use a text editor to understand the server's running principle. Secondly, create a file called hello.php, enter the basic code and run the test. Third, learn to use PHP and HTML to achieve dynamic content output. Finally, pay attention to common errors such as missing semicolons, citation issues, and file extension errors, and enable error reports for debugging.

What is PHP and What is it Used For? What is PHP and What is it Used For? Jul 16, 2025 am 03:45 AM

PHPisaserver-sidescriptinglanguageusedforwebdevelopment,especiallyfordynamicwebsitesandCMSplatformslikeWordPress.Itrunsontheserver,processesdata,interactswithdatabases,andsendsHTMLtobrowsers.Commonusesincludeuserauthentication,e-commerceplatforms,for

How Do You Handle File Operations (Reading/Writing) in PHP? How Do You Handle File Operations (Reading/Writing) in PHP? Jul 16, 2025 am 03:48 AM

TohandlefileoperationsinPHP,useappropriatefunctionsandmodes.1.Toreadafile,usefile_get_contents()forsmallfilesorfgets()inaloopforline-by-lineprocessing.2.Towritetoafile,usefile_put_contents()forsimplewritesorappendingwiththeFILE_APPENDflag,orfwrite()w

PHP Syntax: The Basics PHP Syntax: The Basics Jul 15, 2025 am 02:46 AM

The basic syntax of PHP includes four key points: 1. The PHP tag must be ended, and the use of complete tags is recommended; 2. Echo and print are commonly used for output content, among which echo supports multiple parameters and is more efficient; 3. The annotation methods include //, # and //, to improve code readability; 4. Each statement must end with a semicolon, and spaces and line breaks do not affect execution but affect readability. Mastering these basic rules can help write clear and stable PHP code.

PHP 8 Installation Guide PHP 8 Installation Guide Jul 16, 2025 am 03:41 AM

The steps to install PHP8 on Ubuntu are: 1. Update the software package list; 2. Install PHP8 and basic components; 3. Check the version to confirm that the installation is successful; 4. Install additional modules as needed. Windows users can download and decompress the ZIP package, then modify the configuration file, enable extensions, and add the path to environment variables. macOS users recommend using Homebrew to install, and perform steps such as adding tap, installing PHP8, setting the default version and verifying the version. Although the installation methods are different under different systems, the process is clear, so you can choose the right method according to the purpose.

python if else example python if else example Jul 15, 2025 am 02:55 AM

The key to writing Python's ifelse statements is to understand the logical structure and details. 1. The infrastructure is to execute a piece of code if conditions are established, otherwise the else part is executed, else is optional; 2. Multi-condition judgment is implemented with elif, and it is executed sequentially and stopped once it is met; 3. Nested if is used for further subdivision judgment, it is recommended not to exceed two layers; 4. A ternary expression can be used to replace simple ifelse in a simple scenario. Only by paying attention to indentation, conditional order and logical integrity can we write clear and stable judgment codes.

See all articles