Jump to content

I'm back again in need of some more apache/ubuntu help. I'm having a really hard time getting apache2 to show a php page when I go to it in my browser. I have installed 'php7.0' and libapache2-mod-php7.0' successfully using 'apt-get install' and I thought that was all I needed for php support but I guess not. Googling either gave me answers which didn't work or understand so can anyone here help me? HTML works fine but PHP does not. I tried it by running

<?php
phpinfo();
?>

which I believe is like a test php file or something. My browser shows that literal code when i go to the ip

Thanks

Link to comment
https://linustechtips.com/topic/728681-apache2-only-showing-php-code/
Share on other sites

Link to post
Share on other sites

2 minutes ago, Dutch-stoner said:

Whenever I wanted to play with webservers, I would just download usbwebserver. It's apache, php and mysql, with a "single startup thingy". Not sure how it would run on Linux/ubuntu/anything else then windows.

 

ok, would I need to uninstall apache and such first before I do that or is it fine to leave it as is? If so, how do I uninstall stuff on ubuntu?

Link to post
Share on other sites

USBwebserver is a standalone pack. Put it on an USB stick, plug said USB stick into any windows pc, start up that main program (it's just a simple program starting up other programs), and you are online. (in your local network, to be truely online, you should need to open ports in your modem) Not sure how it works with Linux, never used/tryed it.

Link to post
Share on other sites

1 minute ago, Dutch-stoner said:

USBwebserver is a standalone pack. Put it on an USB stick, plug said USB stick into any windows pc, start up that main program (it's just a simple program starting up other programs), and you are online. (in your local network, to be truely online, you should need to open ports in your modem) Not sure how it works with Linux, never used/tryed it.

 

oh, i see. I'll look into it but i kinda want to get it to work in my current setup. 

Link to post
Share on other sites

Installing apache 2 and php7 from apt should configure everything for you. You should not need to configure anything else.

 

Just make sure you have restarted apache

sudo systemctl restart apache2

 

And you are going to http://localhost (or use your lan ip).

Link to post
Share on other sites

If above didn't help, then:

 

- Can you check that apache knows how to handle php files with modphp in your apache config:


#Add PHP 7 directives

<IfModule php7_module>

  AddType application/x-httpd-php .php

  AddType application/x-httpd-php-source .phps

  <IfModule dir_module>

    DirectoryIndex index.html index.php

  </IfModule>

</IfModule>

 

- You also need to make sure that you're loading modphp, e.g. (you'll need to find the path to your PHP7 module)


#Enable PHP 7 module

LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so

 

- On ubuntu, you'll probably find your apache config at

/etc/apache2/httpd.conf

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×