0

I want to set up the PHP server on local Fedora 30. I have installed php7.0-fpm. So when if run command PHP -S localhost:8800 it's run the folder on this port.

Now I Installed Apache2 and start the server so in the localhost:80 it's working fine. When I tried to put the PHP file in the /var/www/html/ folder it's echo the code not executing the PHP file. Like

<?php echo "Test"; ?>

So I tried to install Nginx and when I run the PHP file with Nginx it's downloading the file PHP file.

I have followed the instruction Click it's not resolved yet.

I want to run PHP with Apache2 or Nginx on Fedora 30. Can anyone help me with this?

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index  index.html index.htm index.nginx-debian.html;

    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/ =404;
    }

    # pass PHP scripts to FastCGI server
    #
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
    #       # With php-fpm (or other unix sockets):
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    # With php-cgi (or other tcp sockets):
    #       fastcgi_pass 127.0.0.1:9000;
    #}

}

Puneet Sharma
  • 305
  • 3
  • 14
  • Please share your configs. For apache2 failing, you probably missed the mod_php or any php handler (suexec, suphp, etc). As far nginx goes, i have a feeling your php-fpm service was not running, or a misconfiguration. But, without seeing any configs, we can't help you – Raul Oct 11 '19 at 06:04
  • Hi, I have edited my question and provide the nginx.conf file. PHP file is still downloading with nginx and I have set `cgi.fix_pathinfo` to `0` in php.ini. Please let me know If anything needed. – Puneet Sharma Oct 15 '19 at 06:35
  • Is your php-fpm server running? Also, your try_files should be: `try_files $uri $uri/ /index.php?$query_string` – Raul Oct 15 '19 at 06:36
  • yes, my php-fpm is running – Puneet Sharma Oct 15 '19 at 06:38
  • `index index.php index.html` i would change that too. But other than that, your config seems fine. Please make the changes i've asked and restart nginx. Also, paste the contents of `snippets/fastcgi-php.conf`. I am very tired and going to bed, but maybe someone else can see an error, if my suggested changes don't work. – Raul Oct 15 '19 at 06:41
  • Hi, `snippets/fastcgi-php.conf` file is not present in nginx server – Puneet Sharma Oct 18 '19 at 05:30
  • did you change the try_files directive? – Raul Oct 18 '19 at 05:34
  • No, I did not change anything. Is there any installation issue? – Puneet Sharma Oct 18 '19 at 05:37
  • can you please change it to what i posted a few comments up? – Raul Oct 18 '19 at 05:37

0 Answers0