0

Total noob on Nginx, however I managed to have my website running with these instructions:

How To Install Nginx on Ubuntu 22.04.

How To Host a Website Using Cloudflare and Nginx on Ubuntu 22.04.

Also followed the instructions how to install wordpress on this blog, but at the end, visiting https://geniusatwork.cf/wp-admin/install.php still throws the error:

404 Not Found nginx/1.18.0

I contacted wordpress to know what I was doing wrong, and they mentioned what I'm having is a server configuration issue instead of wordpress, so I think my questions are more suited for StackOverflow.

According to their answer, wherever the index file with the text displayed on my website is, that's the root location where I should have the wordpress files.

The text they're referring to can be seen on my domain and I got that after configuring server blocks, so I'm retrieving those from:

/var/www/geniusatwork.cf/html/index.html

From my details, seems I got the wordpress files on two different locations since I also followed these instructions from step #4 trying to resolve the issue:

var/www/wordpress# ls -l
total 212
-rw-r-----  1 www-data www-data   405 Feb  6  2020 index.php
-rw-r-----  1 www-data www-data 19915 Jan  1  2022 license.txt
-rw-r-----  1 www-data www-data  7401 Mar 22  2022 readme.html
-rw-r-----  1 www-data www-data  7165 Jan 21  2021 wp-activate.php
drwxr-x---  9 www-data www-data  4096 Aug 30 17:40 wp-admin
-rw-r-----  1 www-data www-data   351 Feb  6  2020 wp-blog-header.php
-rw-r-----  1 www-data www-data  2338 Nov  9  2021 wp-comments-post.php
-rw-r-----  1 www-data www-data  3405 Sep 29 00:12 wp-config.php
drwxr-x---  5 www-data www-data  4096 Sep 28 20:36 wp-content
-rw-r-----  1 www-data www-data  3943 Apr 28 09:49 wp-cron.php
drwxr-x--- 26 www-data www-data 12288 Aug 30 17:40 wp-includes
-rw-r-----  1 www-data www-data  2494 Mar 19  2022 wp-links-opml.php
-rw-r-----  1 www-data www-data  3973 Apr 12 01:47 wp-load.php
-rw-r-----  1 www-data www-data 48498 Apr 29 14:36 wp-login.php
-rw-r-----  1 www-data www-data  8577 Mar 22  2022 wp-mail.php
-rw-r-----  1 www-data www-data 23706 Apr 12 09:26 wp-settings.php
-rw-r-----  1 www-data www-data 32051 Apr 11 11:42 wp-signup.php
-rw-r-----  1 www-data www-data  4748 Apr 11 11:42 wp-trackback.php
-rw-r-----  1 www-data www-data  3236 Jun  8  2020 xmlrpc.php

And

/var/www/html/wordpress# ls -l
total 216
-rw-r-----  1 www-data www-data   405 Feb  6  2020 index.php
-rw-r-----  1 www-data www-data 19915 Jan  1  2022 license.txt
-rw-r-----  1 www-data www-data  7401 Mar 22  2022 readme.html
-rw-r-----  1 www-data www-data  7165 Jan 21  2021 wp-activate.php
drwxr-x---  9 www-data www-data  4096 Aug 30 17:40 wp-admin
-rw-r-----  1 www-data www-data   351 Feb  6  2020 wp-blog-header.php
-rw-r-----  1 www-data www-data  2338 Nov  9  2021 wp-comments-post.php
-rw-r-----  1 www-data www-data  3001 Dec 14  2021 wp-config-sample.php
-rw-r-----  1 www-data www-data  3405 Sep 29 00:08 wp-config.php
drwxr-x---  5 www-data www-data  4096 Sep 28 20:36 wp-content
-rw-r-----  1 www-data www-data  3943 Apr 28 09:49 wp-cron.php
drwxr-x--- 26 www-data www-data 12288 Aug 30 17:40 wp-includes
-rw-r-----  1 www-data www-data  2494 Mar 19  2022 wp-links-opml.php
-rw-r-----  1 www-data www-data  3973 Apr 12 01:47 wp-load.php
-rw-r-----  1 www-data www-data 48498 Apr 29 14:36 wp-login.php
-rw-r-----  1 www-data www-data  8577 Mar 22  2022 wp-mail.php
-rw-r-----  1 www-data www-data 23706 Apr 12 09:26 wp-settings.php
-rw-r-----  1 www-data www-data 32051 Apr 11 11:42 wp-signup.php
-rw-r-----  1 www-data www-data  4748 Apr 11 11:42 wp-trackback.php
-rw-r-----  1 www-data www-data  3236 Jun  8  2020 xmlrpc.php

On both paths I have the wordpress wp-config.php file configured with database, user, password and salt keys.

The path where I have installed my server blocks, and also where I have the index file being displayed on my domain shows this:

/var/www/geniusatwork.cf/html# ls -l
total 4
-rw-r--r-- 1 root root 159 Sep 28 18:43 index.html

From the wordpress answer, I understood that I need to move my wordpress files here, or edit my Nginx config for the domain to point the root to /var/www/wordpress, however since I followed two instructions, I'm not sure where exactly resides the wordpress root file, here:

/var/www/html/wordpress

or here:

/var/www/wordpress

so with that being said, would this command help to fix this?

sudo cp -a /var/www/wordpress/. /var/www/geniusatwork.cf/html/

Or do I need to install wordpress files in the server blocks folder and create a new wp-config.php file?

Is there any issue or conflict if I have two wordpress installations on different paths?

Not sure how to modify the Nginx file to point to the root wordpress file.

Any help with this is greatly appreciated.

1 Answers1

0

Nginx will look wherever root is specified (from the tutorial that you have linked it will be specified in /etc/nginx/conf.d/wordpress.conf). First, check that the wordpress files are in the folder that root is pointed to. It might look something like this:

server {
    listen 80;
    root /var/www/html/wordpress;
    index  index.php

In which case, nginx will search for /var/www/html/wordpress/index.php.

Configuration files like the one above are usually located in /etc/nginx/sites-enabled which is why that path is most often mentioned in nginx tutorials. Your index.html is being served from the configuration file in the sites-enabled directory. Since the paths for root are different in each configuration, it is entirely possible that one can be successful and the other fail.

Apart from checking that root and your wordpress files have matching paths, try some simple fixes:

reload nginx (without errors):

systemctl reload nginx
  • `@tomh` `/etc/nginx/conf.d/wordpress.conf` points to `/var/www/geniusatwork.cf/html` as `root` I checked this folder and I can see all wordpress files there, I can see the `index.php`. When I go to `/etc/nginx/sites-enabled` I only see an symlink I created as per documentation: `lrwxrwxrwx 1 root root 42 Sep 28 18:46 geniusatwork.cf -> /etc/nginx/sites-available/geniusatwork.cf` Do I need to move all WP files to the `/etc/nginx/sites-enabled`? – GeniusAtWork Sep 30 '22 at 20:10
  • No, you shouldn't put website files inside `sites-enabled`. If you want wordpress to be served at `geniusatwork.cf`, I would delete the conf symlink in `sites-enabled` as this might be causing a conflict. I can see that index.php is being downloaded rather than served whenever you visit https://geniusatwork.cf/wp-admin/install.php. This suggests to me a problem with fastcgi, or the nginx conf in the tutorial. Try look at this and related questions: https://stackoverflow.com/questions/25591040/nginx-serves-php-files-as-downloads-instead-of-executing-them –  Oct 03 '22 at 07:08