I’m having trouble moving a wordpress website to a new LEMP server. lets use “example.com” as the example. I successfully copied the PHP files and the database to the new server and temporarily set it up as “example.org” so the “live” example.com would keep functioning while I worked on the new server. I created a server block for it and example.org was working just fine. Here is the partial server block code that was working with the .ORG site.
server {
listen 80;
listen [::]:80;
root /var/www/example.com/html;
index index.php index.html index.htm;
server_name example.org www.example.org;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
}
PLEASE NOTE: We already had a very busy production web site on the LEMP server at “email.example.com”, a sub-domain we use for our email campaigns. That site has been working very well for 6 months. It was using the DEFAULT server block and still is. Here is the code for that site.
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name email.example.com mailer.example.com;
try_files $uri $uri/ =404;
}
}
Since everything was working great with “email.example.com” the default site, and “example.org” the new site, I decided to point “example.com” to the IP address of the new LEMP server. I edited the Server block for the new site to reflect the server names “example.com www.example.com” as below. I included some redirects, which I hope are correct, so that “example.org” and “example.net” also, hopefully, resolve to “example.com”.
server {
listen 80;
listen [::]:80;
root /var/www/example.com/html;
index index.php index.html index.htm;
server_name example.com www.example.com;
rewrite ^/(.*)$ http://example.org/$1 permanent;
rewrite ^/(.*)$ http://example.net/$1 permanent;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
}
And YES I also changed the entries in the wp_options wordpress table for “siteurl” and “home” to “http://example.com”.
BUT now when I enter example.com or example.org or example.net into my browser the DEFAULT website **http://email.example.com ** appears instead of the new site! But the URL displayed in the Browser is example.com. Right URL but Wrong website.
Please help if anyone can tell me what I may have done wrong.
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.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Hello,
As you have already done most of the required steps, this sounds like that the permissions for the
/var/www/example.com/html
directory are not correct and Apache is unable to read the files in that directory.What you could do is:
The output would looks omething like this:
There you should be able to get more information for further troubleshooting.
Regards, Bobby