Hi guys,
I install wordpress on Lemp on 16.04 ( this was installed using the via DO droplet) following this tutorial https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lemp-on-ubuntu-16-04 everything went well, but when I changed the permalinks to post-name since then apart from the home page anything else returns with this error ( 404 Not Found nginx/1.10.0 (Ubuntu) ) now I did of course followed the instruction for making changes in the /etc/nginx/sites-available/default take a look at my file below
GNU nano 2.5.3 File: /etc/nginx/sites-available/default
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
http {
index index.html index.htm index.php index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php$is_args$args;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
# fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
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;
}
I didn’t follow the instructions for installing ssl because this is test and I m did made another user with sudo privileges but there was nothing in the tutorial about switching to non root user at any point, so I continued using the root user for all the process. I m completely new to this so can someone please help me with this. Also I have a sub domain that has it’s own WordPress installation but would be placed in the same dictionary and I m also planing on installing Vanilla forum as a subdomain or example.com/forum. For now I m just doing this on test environment using DO droplet and the ip address as the domain. Thanks in advance for any help.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Make sure you have your WordPress site stored in
/var/www/html
and set correct permissions on/var/www/html
and it’s content. To check, the following simplels
command will do the job:Also, for content:
Recommended permissions are
sammy:www-data
, wheresammy
is your non-root user. If it’s not like that, you can set them by running:Also, make sure you have WordPress unpacked in
/var/www/html
and not in/var/www/html/wordpress
or anything similar. You can also post result ofls -l /var/www/html
, so we’re sure you did it right.If nothing helps, best bet are to check logs. Check for latest entries in
/var/log/nginx/error.log
and/var/log/nginx/access.log
. The first one is the most relevant and will probably tell you the reason of error. If you’re not sure how to debug it, you can post it here (make sure to redact any sensible information).As of forum and another WP site. You can’t do it like you explained. First, you can’t have two WP sites in one directory. The best way would be to create appropriate directories in
/var/www
for each site. For example in/var/www/example.com
store WordPress site running on main domain -example.com
, and in/var/www/subdomain.example.com
store site running on the subdomain. As for forum, I wouldn’t recommend usingexample.com/forum
as it can break WordPress permalinks. Do it with subdomains, on the same way I explained above - create directory for it, e.g./var/www/forum.example.com
and store it there. All this would require you to create appropriate Nginx server blocks and the How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu 16.04 will show you how to do it.Thanks to all, adding this > try_files $uri $uri/ /index.php?$args; to sites available worked for me.
I had the same issue after I installed the nginx on my server. The error was caused by some bad statements in my conf file. I just had to add this to the conf file:
I used this tutorial, check maybe it will help.