Facebook Twitter Instagram
    Facebook Twitter Instagram
    Techtown
    • General
    • Linux
      • Linux Commands
      • Debian
      • Ubuntu
      • Linux Mint
      • Centos
      • OpenSUSE
      • Fedora
    • Text Editors
      • Notepad++
      • Sublime Text
    • Resources
      • Books
    • Write for Us
    Techtown
    Home » Installing Apache and PHP on CentOS 8
    Linux

    Installing Apache and PHP on CentOS 8

    By AMMay 9, 2020Updated:May 9, 2020No Comments3 Mins Read
    Share
    Facebook Twitter LinkedIn Pinterest Email

    This article explains How to install Apache and PHP on CentOS 8

    Apache webserver

    Apache httpd is an open-source web server especially for Unix platforms born in 1995. It is one of the most popular and used servers in the world. Almost half of the websites are served with Apache.

    Install Apache and PHP on CentOS 8

    Apache webserver can be downloaded and compiled from the project website. But this is not optimal so it is best to install it from the CentOS 8 repository.

    So, open a terminal and install it using the following command:

    :~$ sudo dnf install httpd

    Install Apache on CentOS 8

    In case you do not have sudo enabled just run the commands as root without the command sudo.

    As you see in the image, many dependencies have to be satisfied. But this will be taken care of by DNF. So just accept the installation proposal and it will start.

    Apache web server is installed but still needs to start the service. To do this, run:

    :~$ sudo systemctl start httpd

    However, you should set up Apache to start at boot time.

    :~$ sudo systemctl enable httpd

    Now you can check the status of the service to see if it is initiated or not.

    :~$ sudo systemctl status httpd

    Check the Apache service status to know if it is running

    On CentOS, the Firewall is on by default, so if you do not set the rules for Apache it will not work.

    :~$ sudo firewall-cmd --add-service=http --zone=public --permanent

    And apply the changes by restarting the firewall:

    :~$ sudo firewall-cmd --reload

    Now, open a web browser and access your server. In the address bar type http://IP-address-of-the-server or http://Domain-name

    If everything went well, you will have to see the Apache test page at CentOS 8.

    Apache Default page. So, it is running

    Now, Install PHP

    PHP is a fast, easy to learn programming language available for Linux. It is in this language that many great web applications such as WordPress have been created. In this sense, having it is a guarantee of compatibility with many applications.

    To install PHP and some of its modules, just run the following command:

    :~$ sudo dnf install php php-common php-pecl-apcu php-cli php-mysqlnd

    Install PHP on CentOS 8

    Then, as a matter of course, you have to prove that everything is all right.

    Create a PHP file in the Apache root directory.

    :~$ sudo nano /var/www/html/test.php

    And add this content:

    <?php
    phpinfo();
    ?>

    Create a new PHP file to test it

    Save the changes and close the file.

    And since you have installed PHP after Apache, you have to restart the Apache service so that it can interpret it.

    :~$ sudo systemctl restart httpd

    Again, open your web browser and try to open the newly created PHP file.

    If you see an image like this, then Apache and PHP work correctly on CentOS 8.

    Apache and PHP are running on CentOS 8

    So congratulations you’ve achieved the goal. Already the Apache web server and PHP are working properly.

    Conclusion

    As a conclusion to this post, we can affirm that Apache is a very useful web server used by many people around the world. Thanks to being open source we will be able to examine the source code and for this reason, it is quite safe and stable.

    However, Apache needs to be coupled with a programming language for the interpretation of web sites. This is why PHP has been installed. Together they can run most of today’s web sites.

    Now we want to hear from you, do you like Apache? Have you installed it? Let us know

    CentOS
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleSQL vs NoSQL
    Next Article How to Solve Cannot load 64 bit plugin…. is not compatible with the current version of Notepad++
    AM

    Related Posts

    How to Open a Terminal in Linux Mint

    May 24, 2022

    How to Restart Ubuntu From the Terminal

    May 23, 2022

    How to Install Zoom on openSUSE

    May 22, 2022
    Add A Comment

    Comments are closed.

    Recent Posts
    • How to Open a Terminal in Linux Mint
    • How to Restart Ubuntu From the Terminal
    • How to Install Zoom on openSUSE
    • How to Install xArchiver on Debian 11
    • How to Install UNRAR on Fedora 35/34/33/32
    Affiliate Disclosure
    This website contains Affiliate Links. We get small commission for purchases made through affiliate links (at no extra cost to you)
    Facebook Twitter Instagram Pinterest
    • Debian
    • Ubuntu
    • Mint
    • Fedora
    • CentOS
    • openSUSE
    • Chrome
    • XAMPP
    • Forums
    • Notepad++
    • Privacy Policy
    • About Me
    © 2022 ThemeSphere. Designed by ThemeSphere.

    Type above and press Enter to search. Press Esc to cancel.