As i continue with my first ubuntu server, following the lamp installation tutorial at https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-20-04-quickstart-es i configured everything without much issue until i decided to create a different php script and upload it to the server. the code is supposed to show your ip (here is the script)
<?php
function getUserIpAddr(){
if(!empty($_SERVER['HTTP_CLIENT_IP'])){
//ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
}elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
//ip pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
echo 'User Real IP - '.getUserIpAddr();
?>
but when i connect to it through a web browser like ‘server ip/file.php’ all i get is the ‘User Real IP’ message without the actual interesting part wich is the ip, does this mean php isnt executing the code or what am i missing here
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @21729179,
It’s possible you are missing some PHP packages/extensions. Can you list what PHP extensions you have installed on your server? Additionally, the version is of importance as well. To list the extensions type in
apt list --installed php*
Regards, KFSys
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.