Difference between revisions of "Create Site Copy From Dev55"

From GLMWiki
Jump to: navigation, search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
Copy the dev55 (web) folder over to your server directory
+
Copy the remote (web) folder over to your server directory
  rsync -av dev55:/var/www/server/(sitename)/web/ (sitename)
+
  rsync -av (remote):/var/www/server/(sitename)/web/ (sitename)
  
 
NOTE: in the following you'll see (user) (dbname) and (pword)
 
NOTE: in the following you'll see (user) (dbname) and (pword)
Line 7: Line 7:
 
Make sure permissions are good. Group writable
 
Make sure permissions are good. Group writable
  
copy the database (from dev55) [no space between -p and the password]
+
copy the database (from remote inside the web directory)  
mysqldump -u (user) -p(pword) (dbname) > fileName.sql
+
- wp-cli way (inside web directory)
+
 
  wp export db ~/(sitename).sql
 
  wp export db ~/(sitename).sql
  
Create the database on your localhost
+
Create the database on your localhost - wp-cli way (inside your copy)
mysql -u root -p
+
create database (dbname);
+
grant usage on *.* to (user)@localhost identified by '(pword)';
+
grant all privileges on (dbname).* to (user)@localhost;
+
- wp-cli way (inside your copy)
+
 
  wp db create  
 
  wp db create  
  
Rsync over the database
+
copy over the database
  rsync -av dev55:(dumplocation).sql .
+
  scp (remote):(dumplocation).sql .
  
Edit the file and replace the dev55 site url with your new localhost. In vim.
+
Import the database - use the same info as was used in the wp-config.php on remote - wp-cli way (inside web your copy)
:%s;mountpleasantwow.gaslightmedia.com;mountpleasantwow.localhost;g
+
- wp-cli way
+
wp search-replace 'mountpleasantwow.gaslightmedia.com' 'mountpleasantwow.localhost'
+
 
+
Import the database - use the same info as was used in the wp-config.php on dev55
+
mysql -u (user) -p(pword) (dbname) < (dumplocation).sql
+
- wp-cli way (inside web your copy)
+
 
  wp db import (dumplocation).sql
 
  wp db import (dumplocation).sql
 +
 +
Edit the file and replace the dev55 site url with your new localhost. In vim. - wp-cli way
 +
wp search-replace 'oldsite.gaslightmedia.com' 'newsite.localhost' --all-tables
 +
  
 
Add new site file for nginx.
 
Add new site file for nginx.
 +
  
 
If this is the first time you're creating site copies:
 
If this is the first time you're creating site copies:
 
  cd /etc/nginx/sites-available/
 
  cd /etc/nginx/sites-available/
  cp default mountpleasantwow
+
  cp default newsite
  sudo vim mountpleasantwow
+
  sudo vim newsite
 
  ## Comment out the two listen lines at the start of server {
 
  ## Comment out the two listen lines at the start of server {
  ## Change the 'root' line to suit the new location e.g. /var/www/server/mountpleasantwow
+
  ## Change the 'root' line to suit the new location e.g. /var/www/server/newsite
  ## Change the server_name to mountpleasantwow.localhost;
+
  ## Change the server_name to newsite.localhost;
 
  cd ../sites-enabled/
 
  cd ../sites-enabled/
  sudo ln -s ../sites-available/mountpleasantwow ./
+
  sudo ln -s ../sites-available/newsite ./
 
  sudo service nginx restart
 
  sudo service nginx restart
 +
 +
Should have a line for location
 +
<pre>
 +
location / {
 +
    # This is cool because no php is touched for static content.
 +
    # include the "?$args" part so non-default permalinks doesn't break when using query string
 +
    try_files $uri $uri/ /index.php?$args;
 +
}
 +
 +
</pre>
  
  
 
Edit your /etc/hosts file to use (sitename).localhost
 
Edit your /etc/hosts file to use (sitename).localhost
 
  sudo vim /etc/hosts
 
  sudo vim /etc/hosts
  ## add the line: 127.0.0.1 mountpleasantwow.localhost
+
  ## add the line: 127.0.0.1 newsite.localhost

Latest revision as of 16:49, 7 February 2019

Copy the remote (web) folder over to your server directory

rsync -av (remote):/var/www/server/(sitename)/web/ (sitename)

NOTE: in the following you'll see (user) (dbname) and (pword) These are found in the sites wp-config.php file. You will need to replace the (user) with user etc.

Make sure permissions are good. Group writable

copy the database (from remote inside the web directory)

wp export db ~/(sitename).sql

Create the database on your localhost - wp-cli way (inside your copy)

wp db create 

copy over the database

scp (remote):(dumplocation).sql .

Import the database - use the same info as was used in the wp-config.php on remote - wp-cli way (inside web your copy)

wp db import (dumplocation).sql

Edit the file and replace the dev55 site url with your new localhost. In vim. - wp-cli way

wp search-replace 'oldsite.gaslightmedia.com' 'newsite.localhost' --all-tables


Add new site file for nginx.


If this is the first time you're creating site copies:

cd /etc/nginx/sites-available/
cp default newsite
sudo vim newsite
## Comment out the two listen lines at the start of server {
## Change the 'root' line to suit the new location e.g. /var/www/server/newsite
## Change the server_name to newsite.localhost;
cd ../sites-enabled/
sudo ln -s ../sites-available/newsite ./
sudo service nginx restart

Should have a line for location

location / {
    # This is cool because no php is touched for static content.
    # include the "?$args" part so non-default permalinks doesn't break when using query string
    try_files $uri $uri/ /index.php?$args;
}


Edit your /etc/hosts file to use (sitename).localhost

sudo vim /etc/hosts
## add the line: 127.0.0.1 newsite.localhost