By John Kotuby
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!
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:
- sudo ps aux | grep apache
The output would looks omething like this:
- ps aux | grep apache
- www-data 5131 0.0 1.1 1063424 11428 ? Sl 00:00 0:02 /usr/sbin/apache2 -k start
sudo chown -R www-data:www-data /var/www/example.com/html
tail -100 /var/log/apache2/error.log
There you should be able to get more information for further troubleshooting.
Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.