PHP scripts pop-up from browser instead of executing

I installed LAMP using YaST, configured web server using script **mysql_secure_installation
**as suggested in

Now I have got problem: scripts not execute - they pop up from browser in popup windows that asks if I want to open it or download it (like it does for attachments). What can i do to make my scripts execute in web browser?

Thank you for answering my questions

Most likely you haven’t enabled the php apache module. That will cause the webserver not knowing how to handle it. Do

sudo a2enmod php
sudo systemct restart apache2.service

You may have to change ‘php’ to ‘php7’.

I didn’t want to open new thred, buz I have this problem again, but with php7. I tried to things you suggested:

sudo a2enmod php
sudo systemct restart apache2.service

after second step

sudo systemct restart apache2.service

I got message:

sudo: systemct: command not found

I installed LAMP using YaST Pattern (PHP is version 7)

What can I do to make this fixed?

Sorry that I post in old thread, and tell me if I have to start new with this question.

Thank you for answering my questions.

A typo in Knurpht’s post.

systemctl restart apache2.service

But OTOH, you, as system maintainer, should know about things like systemd in general and systemctl in particular.

And please next time when you want to show us something your saw in a terminal emulator (computer text), do a copy/paste of the whole thing, that is the line with the prompt and the command, all output lines and the line with the new prompt. All between CODE tags. And not as you did: splitting the command and part of the output and posting one part between CODE tags and the other part between QUOTE tags. A lot of work for you and for others difficult to interprete and to trust.

I did what you said: typed

systemctl restart apache2.service

but it is still the same.

No, you didn’t. I asked you to post what you see on the screen complete.

I will give you an example:

I did

uname -s

but all I got was

Linux boven 4.12.14-lp151.28.16-default #1 SMP Wed Sep 18 05:32:19 UTC 2019 (3e458e0) x86_64 x86_64 x86_64 GNU/Linux


henk@boven:~> uname -a
Linux boven 4.12.14-lp151.28.16-default #1 SMP Wed Sep 18 05:32:19 UTC 2019 (3e458e0) x86_64 x86_64 x86_64 GNU/Linux

I hope you see the difference and how this is done.

I thionk this time I didn’t made wrong:

zlatic@linux-ntw3:~> su
linux-ntw3:/home/zlatic # systemctl restart apache2.service
linux-ntw3:/home/zlatic # 

And then I got situation: popup window that asks me if I want to open or save php script

Thanks. We now see that that the restarting of Apache went ok.

But I have one more remark (oh, am I pedantic, am I :)).
You prefer su. That is fine, I do also. But please then always use

su -

Do not forget about the - sign (which is btw short for -l, read the man page of su). Omitting it is a security risk and can also bring other surprises.

Back to your problem. We did not see anything about the

a2enmod php

This was started almost 9 months ago and you did not report then if the advice from Knurpht did help you.
So please tell if you either forgot about your own problem for 9 months or if there was succes in January and that now you have the same problem again and when that is the case, what did you do that it reappeared? Update or whatever?

Last time I wrote, it wass successfully. Now, please, I would like to start new thread, because I did not write it correctly. I did not forget, I am lost in the wood of problem Thank you for undestand me :slight_smile:

Yes, I think a new thread is better. And please, first sit down and overthink it before you compose a post. Always understand that others are unknown to your system, your situation and can not see what you do. Never assume that the way you do things are automaticaly undrstood by others that may get the same results in a different way.

Communication here is not always easy, but everybody does what he can.

I am taking a wild guess (based on what Henk has teased out).

I think that there may be a problem with .conf file for this Host or VirtualHost.
Or in /etc/apache2/conf.d/php7.conf
Or in an htaccess file
Do you have an entry something like:

AddHandler application/x-httpd-php .php

Without this pages whose names have the “.php” suffix will be treated as plain text files and served as-is by Apache. The recipient browser will then probably either display the raw text or offer to download the file. somewhere,

Do you have a “phpinfo.php” page to check that the PHP7 module is loaded and running?