Set up a New Website » History » Version 3
Jon Goldberg, 07/05/2017 05:32 PM
1 | 2 | Jon Goldberg | {{last_updated_at}} by {{last_updated_by}} |
---|---|---|---|
2 | 1 | Jon Goldberg | |
3 | 2 | Jon Goldberg | {{>toc}} |
4 | 1 | Jon Goldberg | |
5 | 2 | Jon Goldberg | # Set up a New Website |
6 | |||
7 | 1 | Jon Goldberg | - TODO: Let's Encrypt |
8 | |||
9 | Overview |
||
10 | -------- |
||
11 | |||
12 | Use this document when a) creating a new Drupal/WordPress site, or b) when you need to clone an existing site (create a live or test site from a local dev or existing live site). |
||
13 | |||
14 | If you don't have a Bitbucket repo to store the site, you must first [Create a Site Repo](Create-a-Site-Repo_88002545.html). |
||
15 | |||
16 | Create DNS records |
||
17 | ------------------ |
||
18 | |||
19 | If this is a live site, obtain the namehost credentials from the client. If this is a test site, use the [DNS Management](DNS-Management_88003176.html) documentation. Test sites |
||
20 | have a domain name of "example.jmaconsulting.biz", where "example" is replaced by the shortname of the client (e.g. "nwu.jmaconsulting.biz"). |
||
21 | |||
22 | Cloning an Existing Site |
||
23 | ------------------------ |
||
24 | |||
25 | *Use these instructions if the site already has a git repo.* |
||
26 | |||
27 | - Clone the existing git repo. |
||
28 | - Move to the newly created directory and initialize git. |
||
29 | - Add origin as a remote (substitute the correct repo name below). |
||
30 | |||
31 | ``` |
||
32 | # Could be /home, could be /var/www, check where other sites on the server are (if any). |
||
33 | cd /home |
||
34 | mkdir -p clone.example.org/htdocs |
||
35 | cd clone.example.org/htdocs |
||
36 | git init |
||
37 | # substitute "example" for your own repo |
||
38 | git remote add origin git@bitbucket.org:jmaconsulting/example.git |
||
39 | # Next line is optional, and shouldn't happen on local dev machines. It allows pushing when your git remote is read-only. |
||
40 | git config remote.origin.pushurl https://bitbucket.org/jmaconsulting/example.git |
||
41 | git pull origin master |
||
42 | git submodule update --init --recursive |
||
43 | git branch --set-upstream master origin/master |
||
44 | ``` |
||
45 | |||
46 | 2 | Jon Goldberg | ### Copy/edit settings.php/civicrm.settings.php/wp-config.php |
47 | 1 | Jon Goldberg | |
48 | 3 | Jon Goldberg | *Skip this step if this is a new site from scratch (i.e. not a clone ofan existing site). |
49 | 1 | Jon Goldberg | |
50 | The git repo does NOT include settings.php or civicrm.settings.php. These files contain the server-specific settings - so we don't want to accidentally overwrite them with settings from another server. Instead, copy the settings from the server you just cloned. |
||
51 | |||
52 | Copy settings from an existing server: |
||
53 | |||
54 | ``` |
||
55 | # Copy settings.php (Drupal) file from the old server |
||
56 | scp curds:/var/www/staging/cpehn/sites/default/settings.php . |
||
57 | # For CiviCRM on Drupal: |
||
58 | scp curds:/var/www/staging/cpehn/sites/default/civicrm.settings.php . |
||
59 | # If WordPress: |
||
60 | scp curds:/var/www/staging/aclu/wp-config.php . |
||
61 | # For CiviCRM on WordPress: |
||
62 | scp curds:/var/www/staging/aclu/wp-content/plugins/civicrm/civicrm.settings.php . |
||
63 | |||
64 | # Copy those files to your local install: |
||
65 | # For example: cp ./settings.php /home/jon/local/cpehn/sites/default |
||
66 | ``` |
||
67 | |||
68 | For Drupal, you must edit the file and change the database name, MySQL username, and MySQL password to match the new server's settings. |
||
69 | |||
70 | For Wordpress, you must change the database name, MySQL username, MySQL password, and WP\_HOME and WP\_SITEURL if defined. You must also run `wp search-replace www.oldsitename.org www.newsitename.org` after the database is loaded. |
||
71 | |||
72 | For CiviCRM, you must do edit the same settings twice (once for the CMS, once for CiviCRM), plus change the \$BASE\_URL and all file paths for cache files, overrides, etc. For non-live states, you should also uncomment the `CIVICRM_MAIL_LOG` definition. |
||
73 | |||
74 | ### Disable forced SSL if applicable |
||
75 | |||
76 | TODO: Write this section. Or not, if we move to SSL everywhere using |
||
77 | Let's Encrypt. In that case, write a Let's Encrypt section. |
||
78 | |||
79 | Create a New Site from Scratch |
||
80 | ------------------------------ |
||
81 | |||
82 | ### drush instructions (Drupal only) |
||
83 | |||
84 | *Skip drush instructions if a) you're cloning an existing site (e.g. creating a test server from an existing dev/live server) AND b) the site isn't hosted on a server with a shared Drupal install (i.e. on May First).* |
||
85 | |||
86 | - While in either `/var/www/dev/` or `/var/www/staging`, run the following command to download the latest version of Drupal 7 or 8: |
||
87 | |||
88 | drush dl drupal-7 |
||
89 | drush dl drupal-8 |
||
90 | |||
91 | - Rename the Drupal directory to something that makes sense for the new site |
||
92 | |||
93 | mv drupal-7.34/ healtorture/ |
||
94 | |||
95 | ### wp instructions (WordPress only) |
||
96 | |||
97 | *Skip wp instructions if you're cloning an existing site (e.g. creating a test server from an existing dev/live server).* |
||
98 | |||
99 | - While in `/home` (or `/var/www`), run the following command to download the latest version of WordPress: |
||
100 | |||
101 | wp core download |
||
102 | |||
103 | All Sites |
||
104 | --------- |
||
105 | |||
106 | ### MySQL instructions - all sites |
||
107 | - Create the MySQL database and associated user as listed in settings.php/wp-config.php/civicrm.settings.php: |
||
108 | |||
109 | ``` |
||
110 | #Drupal example |
||
111 | CREATE DATABASE nwu_test_dru; |
||
112 | #WordPress example |
||
113 | CREATE DATABASE nwu_test_wp; |
||
114 | #CiviCRM example |
||
115 | CREATE DATABASE nwu_test_civ; |
||
116 | |||
117 | CREATE USER 'nwu_test'@localhost IDENTIFIED BY 'blahblahblahsomepassword'; |
||
118 | |||
119 | #Drupal/Wordpress |
||
120 | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES, CREATE VIEW ON nwu_test_wp.* TO 'nwu_test'@localhost; |
||
121 | #CiviCRM |
||
122 | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES, TRIGGER, CREATE ROUTINE, ALTER ROUTINE, CREATE VIEW, REFERENCES ON nwu_test_civ.* TO 'nwu_test'@localhost; |
||
123 | ``` |
||
124 | ### MySQL instructions - cloned sites |
||
125 | |||
126 | *These instructions only apply to git cloned sites. Drupal/Civi/WordPress create a blank database on install for brand new sites.* |
||
127 | |||
128 | *TODO: Document use of "drush pipe" and similar commands* |
||
129 | |||
130 | - On the OLD server, dump a copy of the database(s) you need: |
||
131 | |||
132 | ``` |
||
133 | #Drupal |
||
134 | drush sql-dump > ~/cpehn_drupal.sql |
||
135 | #CiviCRM with Drupal |
||
136 | drush civicrm-sql-dump > ~/cpehn_civi.sql |
||
137 | #WordPress (note - no ">" redirection) |
||
138 | wp db export ~/aclu_wp.sql |
||
139 | #CiviCRM with WordPress |
||
140 | wp civicrm-sql-dump > ~/aclu_civi.sql |
||
141 | #Remove trigger definers from Civi dumps |
||
142 | perl -pi -e 's#\/\*\!5001[7|3].*?`[^\*]*\*\/##g' aclu_civi.sql |
||
143 | ``` |
||
144 | |||
145 | - Copy the database(s) to your local machine (and then to another machine, if need be: |
||
146 | |||
147 | scp aclu:~/*sql . |
||
148 | |||
149 | Import your database(s): |
||
150 | |||
151 | #Drupal drush sql-cli < ~/cpehn_drupal.sql #CiviCRM with Drupal drush civicrm-sql-cli < ~/cpehn_civi.sql #WordPress (note - no "<" redirection) wp db import ~/aclu_wp.sql #CiviCRM with WordPress wp civicrm-sql-cli < ~/aclu_civi.sql |
||
152 | |||
153 | - \[WordPress Only\] Run `wp search-replace` to change all instances |
||
154 | of the old URL in the database to the new URL. E.g. |
||
155 | `wp search-replace nwu.org nwu.jmaconsulting.biz`. |
||
156 | |||
157 | ### Apache instructions |
||
158 | |||
159 | - Create an entry in /etc/apache2/sites-available for this site by copying a previous entry, then editing that entry to reflect the new site |
||
160 | - In /etc/apache2/sites-enabled, enable the new site:\ |
||
161 | |||
162 | a2ensite healtorture.palantetech.coop |
||
163 | |||
164 | - Reload apache: `sudo service apache2 reload` |
||
165 | |||
166 | ### DNS instructions |
||
167 | |||
168 | If this is a site on the public Internet, create a DNS entry for it. Test sites: Add a CNAME DNS entry by logging into the MFPL control panel |
||
169 | ([https://members.mayfirst.org/cp](https://members.mayfirst.org/cp)), going to the "Palante Technology:[palantetech.com](http://palantetech.com)" \ |
||
170 | Live sites: Add the DNS entry using the client's DNS system. You'll need |
||
171 | the namehost password from the client. You can often figure out the |
||
172 | namehost with `whois example.org` and looking for the "Name Server" |
||
173 | listing. |
||
174 | |||
175 | Local dev sites: You don't create a public DNS entry if the site isn't publicly accessible. Edit the `/etc/hosts` file on any machine that can see the site. |
||
176 | Examples if the site is hosted on the same computer you use: |
||
177 | |||
178 | 127.0.0.1 ajla.local |
||
179 | |||
180 | Example if the site is on a virtual machine at IP address 192.168.1.6: |
||
181 | |||
182 | 192.168.1.6 ajla.local |
||
183 | |||
184 | ### Run the installer |
||
185 | |||
186 | If this is a new site (not cloned), you can visit the site now to run the installer. You'll need the MySQL database name, MySQL username, and MySQL password. |
||
187 | |||
188 | ### Install CiviCRM |
||
189 | |||
190 | Follow the [official CiviCRM installation instructions](https://wiki.civicrm.org/confluence/display/CRMDOC/Installation+and+Upgrades) |