Apache的本地配置

如果配置了Apache,就不需要每次都在Laravel中执行”php artisan serve”,而且在公司的初始阶段就这样做了,所以我也在自己的电脑上复习了一下。

首先需要从xampp文件夹中找到httpd.vhosts.conf文件。对于我的情况,我将它放在C盘,所以httpd.vhosts.conf的位置是。

c:/xampp/apache//conf/extra/httpd.vhosts.conf

是的。
我创建的项目文件夹都放在d:/project下,所以我在那里创建了httpd.vhosts.conf的快捷方式。
文件的内容大致如下。

# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
##NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ##ServerName or ##ServerAlias in any <VirtualHost> block.
#
##<VirtualHost *:80>
    ##ServerAdmin webmaster@dummy-host.example.com
    ##DocumentRoot "D:/xampp/htdocs/dummy-host.example.com"
    ##ServerName dummy-host.example.com
    ##ServerAlias www.dummy-host.example.com
    ##ErrorLog "logs/dummy-host.example.com-error.log"
    ##CustomLog "logs/dummy-host.example.com-access.log" common
##</VirtualHost>

##<VirtualHost *:80>
    ##ServerAdmin webmaster@dummy-host2.example.com
    ##DocumentRoot "D:/xampp/htdocs/dummy-host2.example.com"
    ##ServerName dummy-host2.example.com
    ##ErrorLog "logs/dummy-host2.example.com-error.log"
    ##CustomLog "logs/dummy-host2.example.com-access.log" common
##</VirtualHost>

NameVirtualHost *:80

#================================================================#
# default
#================================================================#

#以下記述しましょう
<VirtualHost *:80>
  DocumentRoot "D:/project/inouegram.localhost"
  ServerName inouegram.localhost
</VirtualHost>

#ブラウザにのURLにinouegram.localhostと入れると、D:/project/inouegram.localhostの中身を読み込みに行く。
#Laravelの場合DocumentRootは
#D:/project/inouegram.localhost/public

<Directory "D:/xampp/htdocs/inouegram.localhost">
    AllowOverride All
    Require all granted
</Directory>
#AllowOverride AllにすることでD:/xampp/htdocs/inouegram.localhostにある.htaccessファイルの内容を受け入れることになる

如果一位没有经验的工程师要创建并上线他的作品集,最好还是记住这一点。
因为我当时没有认识到熟悉这方面的人,所以记得我曾经感到相当困惑。

接下来创建hosts文件的快捷方式。
附带一提,以下是一篇介绍hosts文件是什么的网站URL:
https://wa3.i-3-i.info/word16969.html

C:\Windows\System32\drivers\etc\hosts

主持人组织内部情况如下所示。

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost


127.0.0.1       inouegram.localhost  #これを記入



# Added by Docker Desktop
192.168.10.36 host.docker.internal
192.168.10.36 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section

如果将 127.0.0.1 [文件夹名称] 进行记录,就完成了。此外,在使用VScode保存时,由于权限问题导致无法保存,只需点击底部的某个名为“管理员什么的”按钮,即可保存。
务必重新启动 Apache 一次。

广告
将在 10 秒后关闭
bannerAds