Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

First, sorry for my English and asking something that it's quite answered all over the web. I've read a lot of post about this problem but I still can't find the solution.

I'm a web developer who recently moved to Ubuntu from Windows 7. I had a website done (it's online and working) and I set up LAMP to keep working with it. I made a test.php file with: <?php phpinfo(); ?> and put it on /var/www/html directory, it shows all the information about the php and I was really happy: "Ok, it's all done, tomorrow I will work hard"

But I placed my whole web into /var/www/html , not in a folder, the index.php is in /var/www/html but guess what: doesn't load any of my .php files, the browser just keep thinking.

What I did:

  1. I rebooted Apache: /etc/init.d/apache2 restart
  2. I tried again with the test.php file and it works fine
  3. I put in /var/www/html a .html file and works fine.
  4. I looked for /etc/apache2/sites-enable/000-default.conf and it says: DocumentRoot /var/www/html

  5. I looked for /etc/apache2/mods-enabled/dir.conf and it says: DirectoryIndex index.html index.cgi index.pl index.php ...

Edit*

I think it's something related to phpmyadmin, like if I'm not able to connect with the database. But I got nothing on the screen when trying to load the page so...I'm not sure.

I can access to the url localhost/phpmyadmin and I edited the connection.php file like this:

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_rakstadconnection = "localhost";
$database_rakstadconnection = "rakstadclandb";
$username_rakstadconnection = "root";
$password_rakstadconnection = "admin";
$rakstadconnection = mysql_connect($hostname_rakstadconnection, $username_rakstadconnection, $password_rakstadconnection) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_query("SET NAMES 'utf8'"); 
?>

The name of the database is correct, like the user and password.

http://i89.photobucket.com/albums/k220/Haddex/Capturadepantallade2014-06-09112609_zpsc45ddb72.png

http://i89.photobucket.com/albums/k220/Haddex/Capturadepantallade2014-06-09112120_zps0b9e15f7.png

*Edit2: could this be because it's a website that I brought to Linux from Windows? I used Dreamweaver.

Edit3: I changed the # to /*/, nothing. The error.log file says:

[Mon Jun 09 17:08:13.627881 2014] [:error] [pid 1517] [client 127.0.0.1:46663] PHP Warning:  require_once(/var/www/html/Connections/rakstadconnection.php): failed to open stream: Permission denied in /var/www/html/index.php on line 1
[Mon Jun 09 17:08:13.627933 2014] [:error] [pid 1517] [client 127.0.0.1:46663] PHP Fatal error:  require_once(): Failed opening required 'Connections/rakstadconnection.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/index.php on line 1

I'm reading error log but...should I add a linux path into a my index.php file? Don't think so.

Thanks.

share|improve this question
    
What does your error log say? Also, '#' for comments in php is now deprecated I believe. use /* This */ or //This works too –  Duncubuntu Jun 8 at 22:27
    
That's mostly the problem, that I don't get any error (at least on the browser screen). When not able to connect or syntax error I always see some php error message on the browser on WINDOWS, but here I don't see anything. Testphp.php (phpinfo()) works perfect, but my .php files return an empty webpage. I always use /**/ for comments, but thanks anyway. –  Haddex Jun 9 at 9:10
    
You are probably getting a php error in /var/log/apache2/error.log –  Shutupsquare Jun 9 at 9:49
    
like @Duncubuntu says try using the // or /* */ for comments, you say you always do but your not in this case you have # I didn't even know that was ever an acceptable comment marker. –  Shutupsquare Jun 9 at 9:53
    
I added the error.log in the Edit3 at the end of the question, thanks guys, hope to fix it. I don't like to boot Windows just to do some web development. –  Haddex Jun 9 at 15:18

1 Answer 1

up vote 0 down vote accepted

There may be a problem with the permission of the files. If apache (or www-data) does not have read permission the pages will not show.

this error seems to indicate that:

`[Mon Jun 09 17:08:13.627881 2014] [:error] [pid 1517] [client 127.0.0.1:46663] PHP Warning:  require_once(/var/www/html/Connections/rakstadconnection.php): failed to open stream: Permission denied in /var/www/html/index.php on line 1`

Make www-data the owner of the directory and everything in it. sudo chown -R www-dat:www-data /var/www/html/<siteFolder>.

Then set the privileges to give the owner and group read and write and execute privileges and everyone else just read privileges sudo chmod -R 774 /var/www/html/<siteFolder>.

share|improve this answer
    
Thank you dan08, you just made my day. It was the chmod. –  Haddex Jun 9 at 17:25
    
I would suggest reading up on Unix permissions, because it will be important to get them right if your running a public web server on a Linux box. Here's a good start: tutorialspoint.com/unix/unix-file-permission.htm –  dan08 Jun 9 at 17:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.