Installing PHP 7 on digitalocean

删除回忆录丶 提交于 2019-12-12 18:33:28

问题


I'm trying to use PHP 7 on digitalocean but the scripts inside files won't run.

This is what I used for install:

sudo apt-get install php7 libapache2-mod-php7 php7-mcrypt

I can do php --version and I get:

PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.8-0ubuntu0.16.04.3, Copyright (c) 1999-2016, by Zend Technologies

But when I check a file with <?php echo "test"; ?> on the browser it just shows <?php echo "test"; ?> not test. Wat do?


回答1:


It is php7.0 not php7. Just checked on DO Ubuntu 16.04.1 x64 image:

apt-get install apache2
apt-get -y install php7.0 libapache2-mod-php7.0 php7.0-mcrypt
systemctl restart apache2



回答2:


Are you opening your file directly or running inside the Apache web server folder? (example: you'll must access http://localhost/nameofthefile.php in the browser)

Does your file have the ".php" extension?




回答3:


If will most probably be your you Nginx or Apache settings?

The guide below should help you out.

https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-in-ubuntu-16-04?utm_source=legacy_reroute



来源:https://stackoverflow.com/questions/40907166/installing-php-7-on-digitalocean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!