Unable to install Wordpress on Ubuntu 15.04

April 29, 2015 2.2k views
Nginx WordPress PHP LEMP Ubuntu

Okay, so the title is a little misleading.

I have fully installed WP on my server, but when I try to connect to it, it just downloads the index.php file, and doesn't actually run the website. I have ensured that it is executable.

server {
        listen   80 default_server; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default_server ipv6only=on; ## listen for ipv6

        root /var/www/html;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name localhost;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.php?q=$uri&$args;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules

This is the only thing I have changed, the rest is default nginx config.

One thing at a time, I'll be asking further questions soon.

P.S. there is no errors in the log.

3 Answers

It appears you are missing the FastCGI section of the nginx configuration file. Adding this:

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;

and restarting nginx with

service nginx restart

Should have your PHP files being executed properly rather than displayed as plain text.

  • Thanks for your quick feedback! I'm trying to get this done as soon as possible, I'm not sure what I'm doing different, as I have done this in the past before :/

    But... One more question, I now have a 502 bad gateway..

    If it helps the address is "adminpanels.us.to"

    And the only other thing I've installed is Ajenti and the tuxlite setup.

    Which now that I'm checking it, ajenti seems to not be working either. :/

A 502 on a LEMP setup usually indicates that php5-fpm is not running. Try restarting the php5-fpm service with the command:

service php5-fpm restart
  • Unfortunately I did already try this, and still get a bad gateway :(

    • just to be sure, yes I did check that it was installed and running.

I just got a new server and it is working fine. I wish I could've found out what the issue was but I havn't seen it since.

Have another answer? Share your knowledge.