Ubuntu 14.04 apache2 configuration problems - php

yesterday i've setted up an Ubuntu 14.04 with php5, Apache2, mysql / mysql-php
Now i try to access my pages - first i've owned all files in my var/ww-directiory, the mainpage of my page worked.
Iǘe logged in in the page (self written cms), nothing working now.Chrome tells me an Internal Server-Error (500). but they are no errors displayed.
I've tried to change the php.ini to display errors, but the changes will be ignored.
With service apache2 stop
i have stopped the server, but the server is running...
What i have to do to see my errors and top stop the server?
In xampp (windows xp / windows 7, booth) the page workes fine. The page is in use on a real server, there it works fine too.
My .htaccess seems to be ignored (routing engine).
If i fill my index.php with "Hello World" (and nothing other) it doesnt work too.
But it seems that php is loading my application correctly, it started the session (seen at the cookies) which is started in other file, which is included from index.php.

An Internal Server Error is probably due to some mistake in your configuration files. That could be either apache2.conf (or any other apache configuration files that get loaded) or php.ini (or any of the additional config files that php loads).
By the way, .htaccess files are disabled by default, and you need to explicitly enable them using apache directive AllowOverride.
Another thing to notice is that, in ubuntu 14.04, you're probably using apache 2.4. There's some slight differences. The first one I've noticed is that site definition files inside sites-available need to end in .conf now.
You can test you config for errors using apachectl configtest (on linux).

Related

PHP not working after changing apache DocumentRoot

I have just setup the LAMP server on Debian. The initial tests were fine. After that, I've decided to change the home directory from "/var/www/" to something like "/home/user/public_html/". I did this changes in "/etc/apache2/sites-available/default".
The problem I am facing now is, that the PHP does not work in the new home folder. PHP sites are now parsed as text files and I can see the full source in browser (when clicking on view page source).
What can I do, that the PHP will also work under that path (and not only under /var/www)?
Look in php.ini in your php folder. There should be entries to change to 'doc_root' as well as 'extension_dir'. Make sure these are set, then restart Apache and it should work.

iis7 serving .php file

I have a old php applications which was earlier hosted on Apache 2.2. Now I am trying to host it on IIS 7.5. I installed php with WebPlatform installer. Then copied directory to inetpub\wwwroot folder. Added this directory as application in IIS. But when I browse search.php, it pops up save as file dialog in the browser - asking to save the file. Instead should return the html response which browser can show.
If put sample index.php with phpInfo() in it. It works properly but not the acutal PHP files. Have I missed any steps?
Any php guys out there? I tried reinstalling, even with xampp, but no luck :(
You have installed it but might not be configured properly. You should follow instructions over here

php files downloading instead of opening

I have a Windows 7 laptop. I downloaded PHP 5.2.8. I downloaded Apache 2.2.
I ran the MSI for PHP install, which i know is not recommended but I tried multiple times the normal route without success.
I have apache running and it shows "Running all apache services". When i did the install i set it up for "localhost".
I checked the CGI checkbox in my control panel.
I placed a simple file, test.php , in C:\inetpub\wwwroot ... but when the file is double-clicked, it tries to download the file instead of opening it as a webpage.
I've been googling this for a couple of hours and cant find a suitable fix. I have cleared my cache, and still no luck.
I also set apache to listen on port 8080 just to be certain nothing else was using port 80 before hand.
Any Ideas??
Thanks!
update -- i was missing the php5apache2.dll ... i placed this in the PHP directory but still the same results. i have also tried browsing to the file location through IE which didnt change anything either unfortunately.
update again, - - DOH! - - didnt realize it was localhost/test.php or what the answer below was. when i do that, i get a server error page.. which is better than before i guess :)
Server Error in Application "DEFAULT WEB SITE"
HTTP Error 500.0 - Internal Server Error
An unknown FastCGI error occured
Module FastCgiModule
Notification ExecuteRequestHandler
Handler PHP
Error Code 0x8007010b
Requested URL http://localhost:80/test.php
Physical Path C:\inetpub\wwwroot\test.php
Logon Method Anonymous
Logon User Anonymous
Most likely causes:
•IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.
•IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.
•IIS was not able to process configuration for the Web site or application.
•The authenticated user does not have permission to use this DLL.
•The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.
when i try to start/run apache, it errors out. so when i run apache test configuration i get the following message:
httpd.exe: Syntax error on line 1 of C:/Apache/conf/httpd.conf: Cannot load C:/php/php5apache2_2.dll into server: The specified module could not be found.
However when i browse to that director, i do see that dll file there!! ugh...
ideas?
If you placed a file called test.php in C:\inetpub\wwwroot, then you would open your browser to http://localhost/test.php to try to execute the file.
The php5apache2.dll file needs to go in your module directory for apache, and you would need to add the appropriate apache config lines such as those below:
LoadModule php5_module "c:/path/to/php5apache2.dll"
AddHandler application/x-httpd-php .php
SetHandler application/x-httpd-php
After making those changes, you will need to restart apache.
Assuming you have PHP installed in Apache properly as mentioned in the other answers, it is possible the .php page is not sending the correct header. I have a .php file that emits a header with Content-Type: text/json, this is commonly used to provide a service for an Ajax client. The .php page should be sending Context-Type: text/html.
To determine if this is indeed the problem you can use wget with the -S option, or use developer tools in your browser. Take a look at this answer: Tool to view response headers
Double clicked? As in within explorer? If so, this won't open the page. You need to browse to the page. If you're within the directory listing for apache double clicking is not necessary.
As for setting up, if you're new your best bet is to use iis, easyphp, xampp, or some other variation
EasyPHP: http://www.easyphp.org/
Xampp: http://www.apachefriends.org/en/xampp.html
They'll get you running without the hassle

No www folder is found in apache 2.2

I want to start learning php, I install apache 2.2 and I want to run my first.php file, I look for www folder in the installation folder of ApacheSoftwareFoundation but I couldn't find it.
here's the files in the apache
I tried to put my php file in htdocs but it doesn't work , can some one help ?
Edit
Doesn't work means when I make http:localhost/first.php , returns Unable to connect
Now the apache is running, when I open htt'://localhost/
returns "it works"
but when I open any php file, it opens as-is ?!
You'll need to check a couple of things...
Make sure the Web Server is running ,either the service
or the program, is running and that you have the correctly configured the Virtual Directories.
If the web server just outputs the
content of the .php file, it could
mean that you don't have mod_php
installed. Meaning the server does
not have the Mime type registered so
it will just try to treat it as a
text file ...
And as your on windows you might consider using something like XAMPP. It gives you a Full Working AMP (Apache Mysql Php) Stack with one install and a easy control manager to start/stop the servers. Other wise do a couple of Google searches on how to install the php module for your Web Server on Windows
Update
To start the server try executing the executable bin/httpd.exe .
Now the apache is running, when I open
http://localhost/ returns "it works"
but when I open any php file, it opens
as-is ?!
A default installation of Apache on windows does not include the necessary modules to run PHP. After installing Apache, you must either:
Install PHP separately and follow the instructions described here to configure Apache to use the installed version of PHP to serve .php files. I've been through this and took me hours to get every thing to work.
Recommended for you: uninstall Apache; install WAMP instead.
if you look in your httpd.conf file you will find the default root directory, it doesnt have to be called www. It is the htdocs by default.
error 500 covers a whole host of things. from compile error, to permissions.
Have you put a simple file of
<?php
echo "test";
?>
As your test php page to rule out other issues?
You need to:
Construct your URI correctly: http://localhost/first.php (with the //)
Ensure that Apache is running
all files in htdocs can be referenced from outside
Just put a basic file named index.php
and visit site http://localhost/
In general type in http://localhost/filename
You say that you get a connection error when you try to go to your webpage. Since it looks like you're using Windows Vista or 7, make sure you're running Apache as an administrator; it can't bind to port 80 otherwise. Also check that other programs like Skype aren't binding to port 80. If you still can't find the problem, check the error log. (logs/error.log by default I think)
The problem is that Apache was installed but not started
If you are using xampp start it and then start apache through control panel
for others look for similar instruction

Apache doesn't execute my copied PHP files, but testing.php works

I've just installed LAMP on my Ubuntu 9.10 machine, and everything works fine except when I copy my PHP files from another computer.
The LAMP guides I've followed also made me create a phpinfo() test file, which works, but when I try to type in e.g. index.php absolutely nothing happens - just a blank page in FireFox. :(
The files are in the exact same directory.
I'm thinking it's probably something with permissions and so on, but since I'm new to both PHP and Ubuntu, I'm kind of lost. It's like I can't create a PHP file with my file browser, but only by using the terminal - like when I created the testing.php from the LAMP guide.
Whaddayaknow... I made an error, tried to:
echo "Hello" world
which, even though I'm a PHP noob, I clearly know is wrong.
I think I'll have to figure out how to enable some sort of error reporting, a blank page is clearly not good enough.
You mean you have a index.php (copied from another computer) and a test.php (edited by hand, with a call to phpinfo()) in the same apache directory, the second works from your browser and the first doesnt ?
That can be a permission issue, or some compilation error in your php.
About permissions, for files should be readable from the apache server (more precisely, form the user that runs the apache server). You can type chmod a+r index.php.
YOu can also check your apache error logs (location dependent on installation). In any case it's vital to know where the error logs are if your are developing a web site.

Categories