1. Open the terminal and start the Apache

Sudo apachectl start sudo apachectl restart sudo apachectl stop Sudo apachectl stopCopy the code

Open your browser and typehttp://127.0.0.1Start test, as shown in the following figure

2. Create a directory under the user directory of the PC (otherwise, the user may fail)

! [[email protected]] (p3-juejin.byteimg.com/tos-cn-i-k3…

3. Locate the Apache configuration file

  • Go to the Apache directory
cd /etc/apache2  
Copy the code
  • Back up apache files for emergencies
sudo cp httpd.conf httpd.conf.bak
Copy the code
  • Edit the httpd.conf file using vim
sudo vim httpd.conf
Copy the code
  • Press I to enter edit mode

  • See the following figure to configure a path to the newly created Sites directory path

  • Press ESC to exit editing mode and enter :wq to save and exit. If you do not want to save, enter :q!

4. Enter localhost. If the following information is displayed, the configuration is successful