I have installed magento 2 in my ubuntu and I tried to run magento setup, it print the index.php code.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.Sign up to join this community
There are 3 possibilities:
1. You don't have PHP installed. In that case run:
sudo apt-get install php php-mysql
2. You have PHP installed but not enabled. You can try running:
sudo a2enmod php7 sudo service apache2 restart
3. You have PHP installed and enabled but you haven't restarted apache.
sudo service apache2 restart
if you have above answer, depending on which magento 2 version you are trying to install.
for e.g. if you are going with > 2.3 you must be needing php
if that's not the case with you, then coming towards your 500 error. which usually means something is not right with the code. the possible url might not exist.