How to Install Apache and PHP on OpenSUSE 15.1

In this article, let’s see How to Install Apache and PHP on OpenSUSE 15.1

Install Apache2 on OpenSUSE 15.1

The Apache web server is incredibly popular within Unix-based systems like OpenSUSE. Therefore, it is also available from the official repositories.

So, open a terminal and refresh the cache of the repositories.

:~$ sudo zypper refresh

When you are done, you can install it by running the following command:

:~$ sudo zypper in apache2

Installing Apache web server on OpenSUSE 15.1Enter the user password. Then you will see all the packages to be installed along with the main one. If you agree, just press the and key.

Unlike Ubuntu and Debian, the apache service is not initialized. So you have to do it manually using systemctl command.

:~$ sudo systemctl start apache2

Similarly, if you want it to start with the system, which is highly recommended in these cases, run it:

:~$ sudo systemctl enable apache2

It is not superfluous to check the status of the service to verify any errors.

:~$ sudo systemctl status apache2

Check the Apache service statusThe image above indicates that Apache is running properly.

Remember that Apache2 is a system service that you can manage with the systemctl command.

Also, you can show the version of Apache that we just installed.

:~$ sudo httpd -v

Apache version on OpenSUSE 15.1

Testing the Apache installation

Everything looks good, but you need to do a test and make sure everything is correct.

And the best way to do this is to create an HTML file and put it in the Apache root directory which in OpenSUSE is /srv/www/htdocs/

:~$ sudo nano /srv/www/htdocs/index.html

And write some simple HTML code like for example

<html> 
    <body> 
       <Hello world! 
    </body> 
</html>

Create an HTML file to test ApacheSave the changes and close the editor.

OpenSUSE takes security very seriously, which is why it installs and configures a firewall by default. If you do not set up a rule to make Apache run, it simply will not work.

So, either open ports 80 and 443 or add the HTTP service to the firewall.

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

In the command, it is specified that the change is permanent. Although you can delete it for personal reasons.

And to apply these changes you have to restart the Firewall.

:~$ sudo firewall-cmd --reload

Configuring the firewall to work with ApacheAnd now you can open your web browser and go to

http://computer_IP

Or:

http://your-domain
Apache is working on OpenSUSE 15.1
Apache is working on OpenSUSE 15.1

And you will have to watch the code you have written run.

Apache and PHP on OpenSUSE – Install PHP

Apache is working well, but it is useless without a programming language that processes dynamic web sites.

So this language can be Python, Ruby, or PHP. In this case, we will choose the latter.

PHP is also available in the official OpenSUSE repositories so to install it, run it in the terminal:

:~$ sudo zypper install php7 php7-mysql apache2-mod_php7

Install PHP on OpenSUSE 15.1Also, you can install many different PHP modules but for now only these are enough.

By default, the PHP module is not loaded into Apache. You have to tell it manually.

:~$ sudo a2enmod php7

For the changes to take effect, restart Apache.

:~$ sudo systemctl restart apache2

Just like with Apache, you have to prove that everything is in order. Again, the best way to do this is to create a PHP file and have Apache serve it and be able to display it.

:~$ sudo nano /srv/www/htdocs/test.php

Then, add PHP content such as the phpinfo method:

<?php
phpinfo();
?>

Testing PHP on OpenSUSE 15.1Again, save the changes and close the editor.

And now you can open your web browser and go to

http://computer_IP/test.php

Or:

http://your-domain/test.php

If everything went well, you will see the PHP information.

Apache and PHP on OpenSUSE 15.1So, Apache and PHP are working on OpenSUSE 15.1 Congratulations.

Conclusion

network service. This makes it a basic thing to learn. But every Linux distribution has a way of working with them.

OpenSUSE, which comes with SUSE, is one of the best solutions for deploying a web server with Apache and PHP. This is thanks to the stability and reputation that a distribution that knows how to do things enjoys.

That’s why the installation requires some extra steps different from Ubuntu or Debian. But the result is the same.

Now it is your turn, do you like Apache? have you used it? what about OpenSUSE?

Scroll to Top