亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

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時(shí)?,?我們告訴電腦直接解析到本機(jī)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)

根目錄選擇項(xiàng)目的根目錄

三)、查看效果

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

這就完成了…

1.2 配置文件查看

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

一)、hosts

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

二)、httpd.conf和vhost.conf

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

在wamp中,我們將多個(gè)虛擬主機(jī)的配置項(xiàng)都放在了一個(gè)文件中。

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

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ù)器返回給客戶端的錯(cuò)誤信息中包含的管理員郵件地址。便于用戶在收到錯(cuò)誤信息后能及時(shí)與管理員取得聯(lián)系。

ServerName指令:

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

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

DocumentRoot指令:

語法:DocumentRoot directory-path

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

ErrorLog指令:

語法: ErrorLog file-path

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

CustomLog指令:

語法: ErrorLog file-path common

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

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

特性:

Options FollowSymLinks IncludesNOEXEC Indexes

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

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

DirectoryIndex index.html index.htm index.php

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

AllowOverride all

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

Order Deny,Allow

Allow from all

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

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

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

eg.

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

推薦學(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)

Hot Topics

PHP Tutorial
1488
72
How to use PHP to build social sharing functions PHP sharing interface integration practice How to use PHP to build social sharing functions PHP sharing interface integration practice Jul 25, 2025 pm 08:51 PM

The core method of building social sharing functions in PHP is to dynamically generate sharing links that meet the requirements of each platform. 1. First get the current page or specified URL and article information; 2. Use urlencode to encode the parameters; 3. Splice and generate sharing links according to the protocols of each platform; 4. Display links on the front end for users to click and share; 5. Dynamically generate OG tags on the page to optimize sharing content display; 6. Be sure to escape user input to prevent XSS attacks. This method does not require complex authentication, has low maintenance costs, and is suitable for most content sharing needs.

PHP calls AI intelligent voice assistant PHP voice interaction system construction PHP calls AI intelligent voice assistant PHP voice interaction system construction Jul 25, 2025 pm 08:45 PM

User voice input is captured and sent to the PHP backend through the MediaRecorder API of the front-end JavaScript; 2. PHP saves the audio as a temporary file and calls STTAPI (such as Google or Baidu voice recognition) to convert it into text; 3. PHP sends the text to an AI service (such as OpenAIGPT) to obtain intelligent reply; 4. PHP then calls TTSAPI (such as Baidu or Google voice synthesis) to convert the reply to a voice file; 5. PHP streams the voice file back to the front-end to play, completing interaction. The entire process is dominated by PHP to ensure seamless connection between all links.

How to use PHP combined with AI to achieve text error correction PHP syntax detection and optimization How to use PHP combined with AI to achieve text error correction PHP syntax detection and optimization Jul 25, 2025 pm 08:57 PM

To realize text error correction and syntax optimization with AI, you need to follow the following steps: 1. Select a suitable AI model or API, such as Baidu, Tencent API or open source NLP library; 2. Call the API through PHP's curl or Guzzle and process the return results; 3. Display error correction information in the application and allow users to choose whether to adopt it; 4. Use php-l and PHP_CodeSniffer for syntax detection and code optimization; 5. Continuously collect feedback and update the model or rules to improve the effect. When choosing AIAPI, focus on evaluating accuracy, response speed, price and support for PHP. Code optimization should follow PSR specifications, use cache reasonably, avoid circular queries, review code regularly, and use X

PHP creates a blog comment system to monetize PHP comment review and anti-brush strategy PHP creates a blog comment system to monetize PHP comment review and anti-brush strategy Jul 25, 2025 pm 08:27 PM

1. Maximizing the commercial value of the comment system requires combining native advertising precise delivery, user paid value-added services (such as uploading pictures, top-up comments), influence incentive mechanism based on comment quality, and compliance anonymous data insight monetization; 2. The audit strategy should adopt a combination of pre-audit dynamic keyword filtering and user reporting mechanisms, supplemented by comment quality rating to achieve content hierarchical exposure; 3. Anti-brushing requires the construction of multi-layer defense: reCAPTCHAv3 sensorless verification, Honeypot honeypot field recognition robot, IP and timestamp frequency limit prevents watering, and content pattern recognition marks suspicious comments, and continuously iterate to deal with attacks.

PHP realizes commodity inventory management and monetization PHP inventory synchronization and alarm mechanism PHP realizes commodity inventory management and monetization PHP inventory synchronization and alarm mechanism Jul 25, 2025 pm 08:30 PM

PHP ensures inventory deduction atomicity through database transactions and FORUPDATE row locks to prevent high concurrent overselling; 2. Multi-platform inventory consistency depends on centralized management and event-driven synchronization, combining API/Webhook notifications and message queues to ensure reliable data transmission; 3. The alarm mechanism should set low inventory, zero/negative inventory, unsalable sales, replenishment cycles and abnormal fluctuations strategies in different scenarios, and select DingTalk, SMS or Email Responsible Persons according to the urgency, and the alarm information must be complete and clear to achieve business adaptation and rapid response.

How to use PHP to combine AI to generate image. PHP automatically generates art works How to use PHP to combine AI to generate image. PHP automatically generates art works Jul 25, 2025 pm 07:21 PM

PHP does not directly perform AI image processing, but integrates through APIs, because it is good at web development rather than computing-intensive tasks. API integration can achieve professional division of labor, reduce costs, and improve efficiency; 2. Integrating key technologies include using Guzzle or cURL to send HTTP requests, JSON data encoding and decoding, API key security authentication, asynchronous queue processing time-consuming tasks, robust error handling and retry mechanism, image storage and display; 3. Common challenges include API cost out of control, uncontrollable generation results, poor user experience, security risks and difficult data management. The response strategies are setting user quotas and caches, providing propt guidance and multi-picture selection, asynchronous notifications and progress prompts, key environment variable storage and content audit, and cloud storage.

Beyond the LAMP Stack: PHP's Role in Modern Enterprise Architecture Beyond the LAMP Stack: PHP's Role in Modern Enterprise Architecture Jul 27, 2025 am 04:31 AM

PHPisstillrelevantinmodernenterpriseenvironments.1.ModernPHP(7.xand8.x)offersperformancegains,stricttyping,JITcompilation,andmodernsyntax,makingitsuitableforlarge-scaleapplications.2.PHPintegrateseffectivelyinhybridarchitectures,servingasanAPIgateway

PHP integrated AI speech recognition and translator PHP meeting record automatic generation solution PHP integrated AI speech recognition and translator PHP meeting record automatic generation solution Jul 25, 2025 pm 07:06 PM

Select the appropriate AI voice recognition service and integrate PHPSDK; 2. Use PHP to call ffmpeg to convert recordings into API-required formats (such as wav); 3. Upload files to cloud storage and call API asynchronous recognition; 4. Analyze JSON results and organize text using NLP technology; 5. Generate Word or Markdown documents to complete the automation of meeting records. The entire process needs to ensure data encryption, access control and compliance to ensure privacy and security.

See all articles