Apache Web Server Lab - Zacham17/my-tech-journal GitHub Wiki

Brief Summary

In this lab, I installed and setup Apache and PHP on my mail01 VM to have it function as a web server as well.

How To Set up Apache on CentOS 7

  • To install Apache, in the terminal enter the command, sudo yum install httpd
  • Allow HTTP services through the firewall using the following commands:
    • sudo firewall-cmd --permanent --add-service=http
    • sudo firewall-cmd --permanent --add-service=https
    • sudo firewall-cmd --reload
  • Enable Apache to start on boot using the command sudo systemctl enable httpd.service
  • After that command finished running, start the httpd service by entering the command, sudo systemctl start httpd.service
  • To make sure the install went properly, you can enter the IP address of your web server into the address bar of a browser on the network and you should see a default webpage.
  • On the web server in the /var/www/html folder, you can add an index.html file and add html code to customize your web page.

How to Set Up PHP on CentOS 7

  • To install PHP on your web server, type the command, sudo yum install php php-mysql
  • Restart Apache by typing sudo systemctl restart httpd.service
  • Install php-fpm using the command sudo yum install php-fpm
  • Add and edit the info.php file in the /var/www/html folder.
    • You can add ``` to the info.php file to have the information page show
    • You can add other php code to customize the php page.
  • Enter the command, sudo systemctl start php-fpm
  • You can view your PHP page by going to your browser and entering the ip address of your web server followed by a forward slash and the php filename. Ex: x.x.x.x/info.php