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:
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.
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.
Open the httpd.conf configuration file and add the following code at the end of the file:
ServerAdmin admin@example.com DocumentRoot “D:/web” ServerName yourservername.local Options Indexes FollowSymLinks AllowOverride All Require all granted
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.
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.
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!