Skip to content
Advertisement

You have chosen to open application/octet-stream – wordpress

I have set up nginx on Ubuntu 20.4 and installed PHP 7.4.3.

Here is the content of /etc/nginx/sites-available/default

server {
    listen 80;
    server_name  www.example.com;
    rewrite ^(.*) http://example.com$1 permanent;
}
server {
    listen 80;
    server_name  example.com;
    index index.html index.php;

    root /home/me/wp1/;
    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all; }
    location ~* .(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
    }
    location / {
        #try_files $uri $uri/ =404;
        try_files $uri $uri/ /home/me/wp1/index.php$is_args$args;
    }
}

when I type my domain in my firefox browser, I see this downloading page application/octet-stream

In addition to that, www did not redirect to the domain without it. I am not sure if this is a separate issue.

The downloaded file has a random name and its content is so scary (Direct PHP) file:

<?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define( 'WP_USE_THEMES', true );

/** Loads the WordPress Environment and Template */
require __DIR__ . '/wp-blog-header.php';

I also ran

sudo service php7.4-fpm start

But the result does not change.

Advertisement

Answer

These lines should be added to the nginx config

location ~ .php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement