Local Apache server doesn't run php file, instead the web browser downloads - apache

My local Apache server doesn't run my php file, instead the web browser downloads it when I try to view it. I'm using LAMP on Ubuntu. Would you help me how I can solve this problem? Thank!

Did you tell LAMP to handle .php files with the php5_module?
Check your current php setting by creating a new php file in the htdocs or www direectory with the following content:
<?php phpinfo(); ?>
This will show you if your webserver can process php files or not

Related

cakephp css/js not load

I am using cakephp 2.6.2 in ubuntu 16.04 . I enabled mod_rewrite in my system. I downgrade php 7 to php 5.6 .In my cakephp program css and js are not loading
<script src="/admin/plugins/jQuery/jQuery-2.1.4.min.js"></script>
it not take the project name along with the src
The project need index.php in the url
Sessions are not working.
I dont know any other configuration is needed in apache
$this->redirect('/notifications/index/');
returns localhost/notifications/index/ instead of localhost/projectfolder/notifications/index/
I got Solution
My .htaccess is not load by apache. I mention "AllowOverride All" in my virtual host configuration. now it is working fine

Does Apache create .htaccess file on startup

Working with Docker and a PHP application. Something (assuming Apache) is creating the following .htaccess file in webroot on container start up.
/var/www/html# cat .htaccess
Deny from all
I delete the .htaccess file and my application works properly. Then shows up again when I start the container. This is a basic Debian Stretch / Apache / PHP 7 image with my PHP code added to it.
Looking for reason or module that is doing this.
Edit: The Dockerfile https://pastebin.com/VDTFYJ0X
Apache is not automatically creating .htaccess files.
I highly assume that your problems is caused by docker.
Try checking your Dockerfile.
The program creating .htaccess file is Composer. Note this issue:
https://github.com/composer/composer/issues/5816
Best to set COMPOSER_HOME to something other than the web root.

laravel 5 ,requested url was not found on this server?

I am trying to upload my laravel 5 project on Apache/2.4.7 (Ubuntu) Server at xxx.xx.x.xx Port 80.
When i browse my site using xxx.xx.x.xx/project/public , landing page is working fine.
But when i tried to log in , it throws this error ,
The requested URL xxx.xx.x.xx/project/public/auth/login was not found on this server.
but when i tried this xxx.xx.x.xx/project/public/index.php/auth/login it throws View [app] not found.
I tried using RewriteBase on htaccess file also edited public/index.php file and changed these following lines...
require __DIR__.'/../bootstrap/autoload.php';
to require __DIR__.'/../project/public/bootstrap/autoload.php';
and
$app = require_once __DIR__.'/../bootstrap/app.php';
to $app = require_once __DIR__.'/../project/public/bootstrap/app.php';
nothing is working!!
I know this one is older topic but i didn't find solution.
Looking for your suggestions.
Which version of Laravel are you working on? I've got problem with auth on 5.1 LTS. No problem with standard configuration (never touched htaccess or config file).
I can suggest to try a new install with a new Laravel package on your server without modifications and see if it works.
This may help: Laravel 5.1 Authentication documentation
Try to enable Apache rewrite module. Run this in command line:
a2enmod rewrite
and don't forget to restart Apache after.
service apache2 restart

Where to put website files in Bitnami LAMP Ubuntu server

Wheres the default folder in Bitnami LAMP? The server is running but I dont know where to put my html files? I mean in comparison with XAMPP and WAMP, the default is you put it on xampp/htdocs/ or wamp/www/.
I've tried using the /opt/bitnami/apache2/htdocs/ and it works but I don't know if thats the default folder to put my website files in LAMP.
Yes, that is the default folder for your HTML or PHP files. You can also add applications on top of Bitnami LAMP and they will be installed at /opt/bitnami/apps/ folder.
HTML and php files, Bitnami on Google Cloud Platform server are in
/opt/bitnami/apache/htdocs
Config file httpd.conf in
/opt/bitnami/apache/conf
HTML and program files on my AWS Bitnami server are in:
/home/bitnami/apps/wordpress/htdocs
Config file httpd.conf it's in:
/opt/bitnami/apache/conf

How to run my html file with apache2

Maybe it is not a right channel to ask this question but I donot know where to ask.
I want to know how to run html file with apache on my ubuntu. I have written program with javascript and a html file and I want to run it via apache. I could not find htdocs folder in to copy my files there beside that I do not have permission to do that in ubuntu. My apache is installed in /usr/share/apache2.
When I write http://localhost it says:
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
but I do not know where to add the contents.
any help.
The default folder that it serves the HTML files from is /var/www.
For example, /var/www/test.html would be http://localhost/test.html.
In my case where I have installed and running the Apache 2 and if I type localhost/ into the browser it opens the Apache 2 Ubuntu default Page.
Now what I did was:
Suppose your HTML webpage Demo.html is located in the Website directory then copy the HTML page using one of the commands:
:~$ cp ~/Website/Demo.html /var/www/html
If this command does not work then try with the following command:
:~$ sudo cp ~/Website/Demo.html /var/www/html
And then open your browser and type this the browser search bar:
localhost/Demo.html
It will open the copied Demo.html.
Also if you want to access this hosted webpage from the outside of the machine where Apache 2 is running then use it's external IP address instead of localhost as follows:
ExternalIP/Demo.html