Hello, This is what I've done in order to create a staging environment which is a copy for the live website. Please, assume that the configuration of the web server is correct (out of scope). The operative system utilized is VzLinux
# Remove current data
rm -rf /var/www/staging.domain.tld/html
# Copy the live website files to the staging domain
cp -R /var/www/domain.tld/html /var/www/staging.domain.tld
chown -R apache:apache /var/www/staging.domain.tld/html
# Backup the database of the live website
mysqldump livedb > domain.tld.backup.sql
# Create the database
mysql
DROP DATABASE stagingdb; # Unnecessary if the database does not exist already
CREATE DATABASE stagingdb; # For staging.domain.tld
CREATE USER 'stagingdbuser'@'localhost' IDENTIFIED BY 'my-very-secret-password'; # Unnecessary if the user already exists
GRANT ALL ON stagingdb.* TO 'stagingdbuser'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
# Import the backup of the live website's database
mysql stagingdb < domain.tld.backup.sql
# Change domain to utilize from domain.tld to staging.domain.tld
mysql -D stagingdb -e "UPDATE tb_configuration SET value='staging.domain.tld' WHERE name='PS_SHOP_DOMAIN';"
mysql -D stagingdb -e "UPDATE tb_configuration SET value='staging.domain.tld' WHERE name='PS_SHOP_DOMAIN_SSL';"
mysql -D stagingdb -e "UPDATE tb_shop_url SET domain='staging.domain.tld' WHERE id_shop='1';"
mysql -D stagingdb -e "UPDATE tb_shop_url SET domain_ssl='staging.domain.tld' WHERE id_shop='1';"
# Edit configuration file to use the new database
vim /var/www/staging.domain.tld/html/config/settings.inc.php
define('_DB_SERVER_', 'localhost');
define('_DB_NAME_', 'stagingdb');
define('_DB_USER_', 'stagingdbuser');
define('_DB_PASSWD_', 'my-very-secret-password');
# Remove cache files, do not delete index.php files
rm -rf /var/www/staging.domain.tld/html/cache/smarty/compile/*
rm -rf /var/www/staging.domain.tld/html/cache/smarty/cache/*
After this process it is possible to log to the backoffice with the same credentials as the live website.
I have run into a problem: I have noticed that the .htaccess file contains domain.tld instead of staging.domain.tld. So I went in the Preferences -> SEO & URLs menu and tried to regenerate the .htaccess file by, for example, pressing on the save button in the SET SHOP URL section. It is at this point that I get the following error
Before being able to use this tool, you need to
- Create a blank .htaccess in your root directory.
- Give it write permissions (CHMOD 666 on Unix system).
The /var/www/staging.domain.tld/html/.htaccess file already exists with the default 644 permissions and the correct owner (apache:apache). I tried changing permissions to 666 but it does not make any difference. Removing the file seems to make the content of it disappear from the .HTACCESS FILE section below, so thirty bees seems to be looking at the correct file.
What do you think is happening?
EDIT: solution
It was SELinux. I forgot to do the following:
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/staging.domain.tld/html(/.*)?"
restorecon -R -v /var/www/
Question
Jeffrey de Bruijn
Hello, This is what I've done in order to create a staging environment which is a copy for the live website. Please, assume that the configuration of the web server is correct (out of scope). The operative system utilized is VzLinux
# Remove current data rm -rf /var/www/staging.domain.tld/html # Copy the live website files to the staging domain cp -R /var/www/domain.tld/html /var/www/staging.domain.tld chown -R apache:apache /var/www/staging.domain.tld/html # Backup the database of the live website mysqldump livedb > domain.tld.backup.sql # Create the database mysql DROP DATABASE stagingdb; # Unnecessary if the database does not exist already CREATE DATABASE stagingdb; # For staging.domain.tld CREATE USER 'stagingdbuser'@'localhost' IDENTIFIED BY 'my-very-secret-password'; # Unnecessary if the user already exists GRANT ALL ON stagingdb.* TO 'stagingdbuser'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES; EXIT; # Import the backup of the live website's database mysql stagingdb < domain.tld.backup.sql # Change domain to utilize from domain.tld to staging.domain.tld mysql -D stagingdb -e "UPDATE tb_configuration SET value='staging.domain.tld' WHERE name='PS_SHOP_DOMAIN';" mysql -D stagingdb -e "UPDATE tb_configuration SET value='staging.domain.tld' WHERE name='PS_SHOP_DOMAIN_SSL';" mysql -D stagingdb -e "UPDATE tb_shop_url SET domain='staging.domain.tld' WHERE id_shop='1';" mysql -D stagingdb -e "UPDATE tb_shop_url SET domain_ssl='staging.domain.tld' WHERE id_shop='1';" # Edit configuration file to use the new database vim /var/www/staging.domain.tld/html/config/settings.inc.php define('_DB_SERVER_', 'localhost'); define('_DB_NAME_', 'stagingdb'); define('_DB_USER_', 'stagingdbuser'); define('_DB_PASSWD_', 'my-very-secret-password'); # Remove cache files, do not delete index.php files rm -rf /var/www/staging.domain.tld/html/cache/smarty/compile/* rm -rf /var/www/staging.domain.tld/html/cache/smarty/cache/*
After this process it is possible to log to the backoffice with the same credentials as the live website.
I have run into a problem: I have noticed that the .htaccess file contains domain.tld instead of staging.domain.tld. So I went in the Preferences -> SEO & URLs menu and tried to regenerate the .htaccess file by, for example, pressing on the save button in the SET SHOP URL section. It is at this point that I get the following error
Before being able to use this tool, you need to - Create a blank .htaccess in your root directory. - Give it write permissions (CHMOD 666 on Unix system).
The /var/www/staging.domain.tld/html/.htaccess file already exists with the default 644 permissions and the correct owner (apache:apache). I tried changing permissions to 666 but it does not make any difference. Removing the file seems to make the content of it disappear from the .HTACCESS FILE section below, so thirty bees seems to be looking at the correct file.
What do you think is happening?
EDIT: solution
It was SELinux. I forgot to do the following:
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/staging.domain.tld/html(/.*)?" restorecon -R -v /var/www/
Solution
0 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now