LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   New Install: How to enable PHP? (https://www.linuxquestions.org/questions/slackware-14/new-install-how-to-enable-php-4175672041/)

maschelsea 03-26-2020 07:08 PM

New Install: How to enable PHP?
 
I have just completed a new install of Slackware 14.2-64 I'm trying to get back the capabilities of my previous Slackware install. The problem I'm dealing with at this moment is I can't seem to run php through apache. My test file (<php>phpinfo(); </php>) only shows text. I have gone into the apache config file and deleted the # before the Include of mod_php.conf. Rebooted apache. Nothing. My test file displays phpinfo(); I was expecting it to execute the command. It did not. Why did it not?

bassmadrigal 03-26-2020 07:49 PM

How is your test file named? If I remember right, by default, it needs to end in .php for it to be parsed by php.

Also, what happens if you run php -f /location/to/test.php

maschelsea 03-26-2020 08:00 PM

Code:

root@caitlyn:/var/www/htdocs# php -f /var/www/htdocs/index.php
<php>
phpinfo();
</php>


kingbeowulf 03-26-2020 09:48 PM

you need to read up on the apache modules configuration for php. Maybe take a peek at
http://www.slackware.com/~mrgoblin/slackware-lamp2.php
https://docs.slackware.com/howtos:ne...ache_php_mysql

volkerdi 03-26-2020 10:31 PM

Try nmapping yourself like this:

Code:

nmap -sV 127.0.0.1
If PHP is enabled, you'll see a line like this:

80/tcp open http Apache httpd 2.4.41 ((Unix) PHP/7.4.4)

Next, try this in your index.php instead:

Code:

<?php
phpinfo();
?>


bassmadrigal 03-27-2020 10:14 AM

Quote:

Originally Posted by volkerdi (Post 6104815)
Code:

<?php
phpinfo();
?>


This is likely your issue. PHP requires the question mark in the open/close tags to be able to parse the contents as php code.

https://www.php.net/manual/en/langua...ax.phptags.php
https://www.php.net/manual/en/langua...ax.phpmode.php

maschelsea 03-29-2020 03:21 PM

Yeah. My PHP is a bit rusty. I corrected the PHP, and then it worked! Thank you to all who have helped me in this thread.


All times are GMT -5. The time now is 06:55 PM.