-3

I copied a folder with all my website in a ubuntu server, I configured apache with the route of the folder, I restarted the service and all but I don't get anything more than a page that seems like an error [screenshot (view larger)

view source of the code actually i'm using 7.2.24 php version, and i was using 7.0.33, does that influence in something? also ubuntu version?

  • 1
    For a proper answer you need provide more details as which PHP version was running? which version are moving? Which apache version was old and was is new? – David L Nov 14 '19 at 19:35
  • 1
    Welcome to Stack Overflow, Noel. When you look at the error page in your browser and then use the "View Source" feature, do you see PHP source code that has not been interpreted/executed at all? – daveloyall Nov 14 '19 at 19:46
  • 1
    Looks like the server is not set up to handle php files. Is php installed? – Gavin Nov 14 '19 at 22:45
  • I added the source code of the page, also the version of php I was using and the actual, I installed php and did the a2enmod – Noel Jimenez Nov 15 '19 at 11:59

1 Answers1

0

Try changing your opening tag from <? to <?php;

Pierre François
  • 5,850
  • 1
  • 17
  • 38
  • Ok, I think thats the problem, I wanted to ask if there is any way I can do for apache to read as php files, or I have to change all my php files? Thanks – Noel Jimenez Nov 15 '19 at 12:07
  • @NoelJimenezBenages: According to https://www.php.net/manual/en/language.basic-syntax.phptags.php, PHP also allows for short open tag (which is discouraged since it is only available if enabled using the short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option). – Pierre François Nov 15 '19 at 13:16
  • Since the website resides on an Ubuntu server, I suggest you to connect to the server through `ssh`, to go to the directory containing the PHP files and to issue one command for changing the tag in all the PHP files at once: `sed -i '/ *$/s// – Pierre François Nov 15 '19 at 15:19
  • How I can make to do that in files that are inside other folders, and another question is that will that happen with other files like js, html or similar? – Noel Jimenez Nov 15 '19 at 18:56
  • @NoelJimenezBenages: The command `sed` above will only affect the files in the current directory that are ending with the suffix .php. If you need a recursive command over a directory structure, I suggest you to open a new question or to read the manual of commands like `sed` and `find`. – Pierre François Nov 16 '19 at 09:20
  • I searched for a command like that, and i found this one: find /var/www/html/ -name \*.php -exec sed -i "s// – Noel Jimenez Nov 16 '19 at 13:53
  • I would have run: `find /var/www/html/ -name *.php -exec sed -i "s/ *$/ – Pierre François Nov 16 '19 at 19:38
  • I took a look, and yes, I changed some other things i didn't have to, as I have html code on some php files and some of the html code had – Noel Jimenez Nov 19 '19 at 20:43
  • I am sorry to hear you changed some `` into ` – Pierre François Nov 20 '19 at 10:09
  • there is no problem, by the way you know about any other way to solve this, maybe changing something in apache? if not it is ok you helped a lot, thanks. – Noel Jimenez Nov 20 '19 at 19:56
  • According to https://www.ntchosting.com/encyclopedia/scripting-and-programming/php/php-in/, «if you want to shorten your code as much as possible, you can go for the short_tags option. This will save you from typing – Pierre François Nov 21 '19 at 14:53
  • I searched for a php.ini, and I found some, I modified one that was on /etc/php/7.2/apache2/php.ini, i modified one that was short_open_tag to On, but I get a blank page, also I restored my /var/www/html folder. – Noel Jimenez Nov 21 '19 at 21:02
  • Try to load a short php file like `Test

    echo "Hello world!"; ?>

    ` and don't forget to restart your apache server by issuing `sudo service apache2 restart` after editing php.ini.
    – Pierre François Nov 22 '19 at 09:49