IT/Procedures/Website Moving: Difference between revisions
Walttheboss (talk | contribs) No edit summary |
Walttheboss (talk | contribs) No edit summary |
||
(9 intermediate revisions by the same user not shown) | |||
Line 21: | Line 21: | ||
=== Files === | === Files === | ||
The files for the website have to be moved as well, which takes several steps. First of all, one has to create a new directory into which the files will be moved. This directory should normally be in <code>/var/www/html/</code>. To create this new directory use the command: | The files for the website have to be moved as well, which takes several steps. First of all, one has to create a new directory into which the files will be moved. This directory should normally be in <code>/var/www/html/</code>. To create this new directory use the command on the : | ||
<code>sudo mkdir FOLDERNAME</code> | <code>sudo mkdir FOLDERNAME</code> | ||
ytyrtuftjh | |||
To avoid permission problems, change the ownership of this directory to the user of the new server using the command: | |||
To | <code>sudo chown USER:USER FOLDERNAME</code> | ||
To move the files use the following comand on the old server: | |||
<code>sudo rsync -av --progress -e ssh /var/www/html/FOLDERNAMEO/ USERN@ADDRESSN:/var/www/html/FOLDERNAMEN</code> | |||
Make sure that all the permissions and the ownership is set up correctly by using three commands on the new server as follows: | |||
change the permissions for directories: | |||
<code>find FOLDERNAME/ -type d -exec chmod 755 {} \;</code> | |||
change the permissions for files: | |||
<code>find FOLDERNAME/ -type f -exec chmod 644 {} \;</code> | |||
change ownership(user:group): | |||
<code>sudo chown www-data:www-data -R FOLDERNAME</code> | |||
=== Vhost file === | |||
This section is done on the new server. One has to make changes to the two Vhost files wordpress.conf and wordpressSSL.conf. In wordpress.conf the only thing one has to do is to add the following "paragraph" to the file (if possible by copying from an existing entry of another website and changing the differences): | |||
<nowiki> | |||
<VirtualHost *:80> | |||
ServerName moodle.msgcgk.com | |||
ServerAlias www.moodle.msgcgk.com | |||
ServerAdmin it@moodle.msgcgk.com | |||
DocumentRoot /var/www/html/moodle.msgcgk/ | |||
<Directory /> | |||
Options Indexes FollowSymLinks MultiViews | |||
AllowOverride All | |||
Order allow,deny | |||
allow from all | |||
</Directory> | |||
RewriteEngine on | |||
RewriteCond %{SERVER_NAME} =www.moodle.msgcgk.com [OR] | |||
RewriteCond %{SERVER_NAME} =moodle.msgcgk.com | |||
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] | |||
</VirtualHost> | |||
</nowiki> | |||
In wordpressSSL.conf the first step is to add the following paragraph: | |||
<nowiki> | |||
<IfModule mod_ssl.c> | |||
<VirtualHost *:443> | |||
ServerName moodle.msgcgk.com | |||
ServerAlias www.moodle.msgcgk.com | |||
ServerAdmin it@moodle.msgcgk.com | |||
DocumentRoot /var/www/html/moodle.msgcgk/ | |||
<Directory /> | |||
Options Indexes FollowSymLinks MultiViews | |||
AllowOverride All | |||
Order allow,deny | |||
allow from all | |||
</Directory> | |||
</VirtualHost> | |||
</IfModule> | |||
</nowiki> | |||
Then restart apache: | |||
<code>sudo service apache2 restart</code> | |||
To check whether the syntax is allright: | |||
<code>sudo apache2ctl configtest</code> | |||
To add security certificates, use the following command: | |||
<code>sudo certbot</code> | |||
This will show a list of all the websites on the server and ask for which one a certificate should be produced. To select a website type the number of the website in the list. To select several websites separate the different numbers by commas or spaces. | |||
If certbot produces an error, restarting apache and trying again can help. | |||
Check whether the certificate has been added to wordpressSSL.conf. It should look like this: | |||
<nowiki> | |||
<IfModule mod_ssl.c> | |||
<VirtualHost *:443> | |||
ServerName moodle.msgcgk.com | |||
ServerAlias www.moodle.msgcgk.com | |||
ServerAdmin it@moodle.msgcgk.com | |||
DocumentRoot /var/www/html/moodle.msgcgk/ | |||
<Directory /> | |||
Options Indexes FollowSymLinks MultiViews | |||
AllowOverride All | |||
Order allow,deny | |||
allow from all | |||
</Directory> | |||
Include /etc/letsencrypt/options-ssl-apache.conf | |||
SSLCertificateFile /etc/letsencrypt/live/moodle.msgcgk.com/fullchain.pem | |||
SSLCertificateKeyFile /etc/letsencrypt/live/moodle.msgcgk.com/privkey.pem | |||
</VirtualHost> | |||
</IfModule> | |||
</nowiki> | |||
=== Moodle === | |||
When moving moodle one has to also move the moodle data. This is done the same way as moving the files, but with a different directory. | |||
Then one has to change the dataroot directory in the config.php file, which is located in <code>/var/www/html/FOLDERNAME/</code>, to wherever the moodle data was moved before. While in the config file also check the database user and password. | |||
This directory and files must also be owned by www-data:www-data. |
Latest revision as of 12:14, 27 September 2023
Moving a website from one server to another takes several steps which are listed here.
Zoneedit
Since the website will be moved from one server to another and these two servers do not have the same IP address, one has to change the IP address to which the domain name points to.
In Zoneedit this is done as follows:
- Go to Domains.
- Look for the websites domain in the list and click on 'dns'.
- Look for A Records and click 'edit'.
- Add the websites (sub)domain and/or point it to the IP address of the new server.
- Click 'next'.
- The changes will be shown. Click 'confirm'.
- Click done.
Database
In order for the website to run it needs its database. To move the database from the old server to the new one, use the following command on the old server (O:old server; N:new server):
mysqldump -v -uDBUSERO -pDBPASSWORDO DATABASENAMEO | ssh USERN@ADDRESSN mysql -uDBUSERN -pDBPASSWORDN DATABASENAMEN
Files
The files for the website have to be moved as well, which takes several steps. First of all, one has to create a new directory into which the files will be moved. This directory should normally be in /var/www/html/
. To create this new directory use the command on the :
sudo mkdir FOLDERNAME
ytyrtuftjh
To avoid permission problems, change the ownership of this directory to the user of the new server using the command:
sudo chown USER:USER FOLDERNAME
To move the files use the following comand on the old server:
sudo rsync -av --progress -e ssh /var/www/html/FOLDERNAMEO/ USERN@ADDRESSN:/var/www/html/FOLDERNAMEN
Make sure that all the permissions and the ownership is set up correctly by using three commands on the new server as follows:
change the permissions for directories:
find FOLDERNAME/ -type d -exec chmod 755 {} \;
change the permissions for files:
find FOLDERNAME/ -type f -exec chmod 644 {} \;
change ownership(user:group):
sudo chown www-data:www-data -R FOLDERNAME
Vhost file
This section is done on the new server. One has to make changes to the two Vhost files wordpress.conf and wordpressSSL.conf. In wordpress.conf the only thing one has to do is to add the following "paragraph" to the file (if possible by copying from an existing entry of another website and changing the differences):
<VirtualHost *:80> ServerName moodle.msgcgk.com ServerAlias www.moodle.msgcgk.com ServerAdmin it@moodle.msgcgk.com DocumentRoot /var/www/html/moodle.msgcgk/ <Directory /> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> RewriteEngine on RewriteCond %{SERVER_NAME} =www.moodle.msgcgk.com [OR] RewriteCond %{SERVER_NAME} =moodle.msgcgk.com RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] </VirtualHost>
In wordpressSSL.conf the first step is to add the following paragraph:
<IfModule mod_ssl.c> <VirtualHost *:443> ServerName moodle.msgcgk.com ServerAlias www.moodle.msgcgk.com ServerAdmin it@moodle.msgcgk.com DocumentRoot /var/www/html/moodle.msgcgk/ <Directory /> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost> </IfModule>
Then restart apache:
sudo service apache2 restart
To check whether the syntax is allright:
sudo apache2ctl configtest
To add security certificates, use the following command:
sudo certbot
This will show a list of all the websites on the server and ask for which one a certificate should be produced. To select a website type the number of the website in the list. To select several websites separate the different numbers by commas or spaces.
If certbot produces an error, restarting apache and trying again can help.
Check whether the certificate has been added to wordpressSSL.conf. It should look like this:
<IfModule mod_ssl.c> <VirtualHost *:443> ServerName moodle.msgcgk.com ServerAlias www.moodle.msgcgk.com ServerAdmin it@moodle.msgcgk.com DocumentRoot /var/www/html/moodle.msgcgk/ <Directory /> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> Include /etc/letsencrypt/options-ssl-apache.conf SSLCertificateFile /etc/letsencrypt/live/moodle.msgcgk.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/moodle.msgcgk.com/privkey.pem </VirtualHost> </IfModule>
Moodle
When moving moodle one has to also move the moodle data. This is done the same way as moving the files, but with a different directory.
Then one has to change the dataroot directory in the config.php file, which is located in /var/www/html/FOLDERNAME/
, to wherever the moodle data was moved before. While in the config file also check the database user and password.
This directory and files must also be owned by www-data:www-data.