Monday, August 18, 2014

linux - nginx, web page degraded when root path is changed



I'm setting a wordpress up with nginx.
Everything's seems ok :





  • server is up

  • phpinfo() test is ok

  • the worpress install routine is showing up



The only trouble is the root statement in the web server conf file.
If I use :




[/etc/nginx/sites-available/wordpress]
server{
root /var/www;
index index.php
server_name example.com
...
}


I can reach the service using http://example.com/wordpress, now I want wordpress to be designated as the root folder.

Here's the change :



[/etc/nginx/sites-available/wordpress]
server{
root /var/www/wordpress;
index index.php
server_name example.com
...
}



Broken! The web page http://example.com is only displaying basic html data, no pics, no css, ... ugly.
No errors reported in /var/log/nginx/access.log



nginx version: nginx/1.2.1



What's wrong?


Answer



You should also update the wordpress configuration. Without that, wordpress still links the static content to subdirectory. Step taken from Moving your Wordpress from a subfolder to the root directory





  1. From the main dashboard, go to Administration -> Settings -> General.

  2. Next, look for the WordPress address (URI): and change it from (example.com/wordpress to example.com)

  3. Lastly, look for the Site Address address (URL): and change it from (example.com/wordpress to example.com)


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...