Is there a way to rename a site?

So @komsel2228, nothing is stored in the database about the site name?

you may try this
bench setup nginx
sudo service nginx reload

That did not work either @lukptr. I tried adding "site_name" to site_config.json and then doing the bench setup nginx command. What I am noticing is these settings in the config/nginx.conf file

 location /socket.io {
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header X-Frappe-Site-Name site1.local;
                proxy_set_header Origin $scheme://$http_host;
                proxy_set_header Host $host;
                proxy_pass http://frappe-bench-socketio-server;
        }
 location @webserver {
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Frappe-Site-Name site1.local;
                proxy_set_header Host $host;
                proxy_set_header X-Use-X-Accel-Redirect True;
                proxy_read_timeout 120;
                proxy_redirect off;
                proxy_pass  http://frappe-bench-frappe;
        }

Notice the proxy header of X-Frappe-Site-Name in there is not changed. I tried to change it by hand, reload and restart and it somehow puts the site into maintenance mode. Probably because frappe does not see the header it expects from the http server in the header. I was hoping the addition of the same parameter in the site_config.json file would do the trick.

maybe by renaming the site folder under
/home/frappe/frappe-bench/sites[your site]
as well? and then setup nginx?
only guessing since the basepath is /home/frappe/frappe-bench/sites

Is solution identified for this, facing same problem?

I eventually figured this out. It is a multi-step process

  1. use bench stop to stop the sites
  2. rename the site folder (e.g. site1.local) to what you want it to be (e.g. erp.domain.com)
  3. edit the config/nginx.conf file (as noted above) and search on site1.local or whatever the folder name was and then replace the value with new folder name
  4. run bench start to start up things.

That should do it.

6 Likes

Is there alternative command for stop ?

$ bench stop
Usage: bench [OPTIONS] COMMAND [ARGS]...

Error: No such command "stop".

You are right. I thought there was a stop and start command. It’s just a restart command. I would use sudo service nginx stop to stop the front end web server to prevent new connections. Once you edit the nginx.conf file you will want to do a sudo service nginx reload and then sudo service nginx start. Change step 4 to bench restart to clean up and get everything running right.

2 Likes

Don’t you also have to rename the database schema? The database schema will also be site1.local.

I don’t think it matters. I did nothing with my schema and everything is working fine.

didnt renamed schema and it works. If renamed then it needs to be changed in configuration file

Also didn’t rename schema and it works.

This method doesn’t work any more.

And looks like many other things have changed. Kindly correct me if I am wrong

“bench setup nginx” fails with an error “directory doesn’t exist /home/frappe/sites”
But as I know sites folder to be located in “/home/frappe/frappe-bench/sites”

Same error is thrown with "bench setup add-domain [Domain].

I have successfully used the said method in this post with the previous version of ERPNext.

Can anyone guide me what works now to rename the site.

Try this Raghuzor -

  1. use bench stop to stop the sites
  2. bench set-url-root site1.local http://erp.example.com
  3. rename site folder (e.g. site1.local) to what you want it to be (e.g. erp.domain.com)
    mv sites/site1.local sites/erp.example.com
  4. edit config/nginx.conf file (as noted above) and search on ‘server_name’ key and replace the 'site1.local` value with new folder name ‘erp.example.com
  5. run bench start to start up things.

This worked for me when I switched from v9 32-bit to v10 x86_64

9 Likes

Thanks @clarkej

I am running production version so Bench stop will not work.

I was wrong, the solution mentioned in this post still works.

I had fresh installed erp production and without logging in, I was trying to change the site name. Apparently that doesn’t work. Once I logged in and finished initial setup, I just followed the same procedure and it works.

Thankss

yes in production instead use these -

sudo supervisorctl stop all
sudo supervisorctl start all
3 Likes

@clarkej thank you for that info. New learning for me.

ah yes this question here was my learning moment Breaking down Environment and branch (develop, master) - #5 by clarkej

thank u brother

Just tried this on V11 but after restarting supervisorctl I can’t access erpnext. I’m seeing a ‘Sorry we will back soon’ page. What did I miss?