1

I really need help with Nginx on my Ubuntu Server. I set up Nginx normally and everything works so far. That means if I put an index.html into /var/www/mydomain.com/public_html it works just fine.

But now I wanted to install phpBB there. I followed the tutorial and extracted it in the public_html folder. I got a folder called "phpBB3" so I went to my browser to mydomain.com/phpBB3 as the tutorial said.

But the PHP did not execute. It tried to download an "application/octet-stream" file. I opened the file in notepad and it turned out to be the PHP script.

I have no idea what to do. Yes, PHP is installed and yes, I looked on google and StackOverflow and followed the instructions. But nothing seemed to help. So please don't just mark this as duplicate and post a link to another StackOverflow question. Because I already tried that and it won't really help me.

My configs are as follows:

/etc/nginx/sites-available/default http://pastebin.com/rUbHybDD

/etc/php5/fpm/php.ini http://pastebin.com/HeynV4Je

This is really important to me, thank you!

4
  • Really? No one can help me? Commented Nov 10, 2016 at 14:30
  • You throw in several different configs into one. How you think that works? In your php-fpm config, there is in the same file your nginx config. It won't work lol. php.ini, php-fpm config and nginx config must be 3 different files. Commented Nov 10, 2016 at 14:57
  • They are different files Commented Nov 13, 2016 at 16:02
  • You have nginx config in the php.ini file.. Commented Nov 14, 2016 at 8:30

2 Answers 2

1

Try replacing: (In /etc/nginx/sites-available/default)

location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/tmp/php.socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

By:

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}
Sign up to request clarification or add additional context in comments.

6 Comments

Doesn't work :/ Could it be that it has something to do with the line "root /usr/share/nginx/html;" since my real html root is /var/www/domain.com/public_html?
Yes, can be that, replace the route root /usr/share/nginx/html; by root /var/www/domain.com/public_html;
Nope, nothing changed. But I tried something: I opened the website (mydomain.com/phpBB3) in internet explorer in stead or firefox. Internet explorer doesnt download the file like firefox, but displays the php as plain text.
PHP is not loading, did you use the sudo service nginx restart command after modifying what I told you? If you did not use it, run it.
And check if php5-fpm.sock is in /var/run/php5-fpm.sock
|
0

Ok I found out why it didn't work. The thing is I have two configs in the sites-aviable directory. First one is "default" and second one is "mydomain.com". I appied all changes to the "default" config while I left the "mydomain.com" config untouched. And that was the problem. I had to apply all changes to the "mydomain.com" config aswell.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.