Home  >  Article  >  Backend Development  >  How to build a php website and achieve LAN access

How to build a php website and achieve LAN access

PHPz
PHPzOriginal
2023-04-11 09:11:442127browse

With the continuous development of the Internet and computer technology, more and more people are beginning to pay attention to and learn about website construction and development. If you need to build a PHP website at work or study and want to access it within a local area network, then the method introduced in this article may help you.

1. Build a PHP environment

First of all, building a PHP website requires environmental support, that is, you need to install a PHP parser and Apache or IIS server. Here we take the Apache server as an example. The specific steps are as follows:

  1. Download and install the Apache server. Download address: https://httpd.apache.org/download.cgi
  2. Installation PHP parser, download address: http://windows.php.net/download/
  3. Open the Apache server configuration file httpd.conf and add the following code at the end of the file:
LoadModule php7_module “d:/php/php7apache2_4.dll”
PHPIniDir “d:/php”
AddType application/x-httpd-php .php

Among them, d:/php and php7apache2_4.dll need to be modified according to the specific installation path and version.

  1. Start the Apache service and enter localhost in the browser to verify whether it is successful.

2. Configure LAN access

After the above steps, we have completed the construction of the PHP website and can access it on this machine. Next we need to configure it to be accessible on the LAN.

  1. Configure virtual host

Open the httpd.conf configuration file and add the following code at the end of the file:

<VirtualHost *:80>
    ServerAdmin admin@example.com
    DocumentRoot “D:/web”
    ServerName yourservername.local
    <directory “D:/web”>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted 
    </directory>
</VirtualHost>

Among them, D:/web needs to be based on Modify the specific website folder path, yourservername.local needs to be modified according to your actual situation.

  1. Configuring Windows Network

Click the "Start" menu, select "Control Panel"->"Network and Sharing Center"->"Advanced Sharing Settings", In the "Network Discovery" and "File and Printer Sharing" options, check "Enable Network Discovery" and "Enable File and Printer Sharing" and turn off the firewall.

  1. Configure LAN IP

In the CMD command line, enter ipconfig to view the IP address of the machine, and then enter the IP address in the browser of other devices to access the website .

At this point, you have successfully built a PHP website and can access it within the local area network. If you want to access your website on the Internet, you also need to perform operations such as port mapping and domain name binding.

The above is the detailed content of How to build a php website and achieve LAN access. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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