PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, September 20, 2022

[FIXED] How can I fix a website which dosen't work with ubuntu?

 September 20, 2022     apache, php, ubuntu, virtualhost     No comments   

Issue

I want to make a website in a local environment, but I have a issue. I don't know why, but when I launch the website, I have the php code of the index.php file instead of having a view.

Here is what I did about the configuration:

I created a VirtualHost:

<VirtualHost *:80>
        ServerName dev.mywebsite.com
        ServerAlias www.dev.mywebsite.com
        DocumentRoot "/mnt/d/Websites/mywebsite"
        <Directory "/mnt/d/Websites/mywebsite">
                Options +FollowSymLinks
                AllowOverride all
                Require all granted
                Options Indexes
        </Directory>
        ErrorLog /var/log/apache2/error.dev.mywebsite.com.log
        CustomLog /var/log/apache2/access.dev.mywebsite.com.log combined
</VirtualHost>

I modified the 'hosts' file with this two lines:

127.0.0.1       dev.mywebsite.com
::1             dev.mywebsite.com

Then I reloaded the service apache2.

But I still have a problem. Indeed, when I go to 'dev.mywebsite.com', I have a page with the code of the index.php, and I don't know why. I thought it was because php, but I have the version php 7.4.3.

Can you help me?

Thanks by advance!


Solution

Make sure you have the PHP Apache mod installed and enabled by:

sudo apt install libapache2-mod-php
sudo a2enmod php7.4

Otherwise your web server knows nothing about php files and just shows them to the client.



Answered By - Tejes
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing