Set up a New Website » History » Version 2
Jon Goldberg, 07/05/2017 05:31 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 | *Skip this step *if this is a new site from scratch (i.e. not a clone of |
||
49 | an existing site).** |
||
50 | |||
51 | 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. |
||
52 | |||
53 | Copy settings from an existing server: |
||
54 | |||
55 | ``` |
||
56 | # Copy settings.php (Drupal) file from the old server |
||
57 | scp curds:/var/www/staging/cpehn/sites/default/settings.php . |
||
58 | # For CiviCRM on Drupal: |
||
59 | scp curds:/var/www/staging/cpehn/sites/default/civicrm.settings.php . |
||
60 | # If WordPress: |
||
61 | scp curds:/var/www/staging/aclu/wp-config.php . |
||
62 | # For CiviCRM on WordPress: |
||
63 | scp curds:/var/www/staging/aclu/wp-content/plugins/civicrm/civicrm.settings.php . |
||
64 | |||
65 | # Copy those files to your local install: |
||
66 | # For example: cp ./settings.php /home/jon/local/cpehn/sites/default |
||
67 | ``` |
||
68 | |||
69 | For Drupal, you must edit the file and change the database name, MySQL username, and MySQL password to match the new server's settings. |
||
70 | |||
71 | 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. |
||
72 | |||
73 | 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. |
||
74 | |||
75 | ### Disable forced SSL if applicable |
||
76 | |||
77 | TODO: Write this section. Or not, if we move to SSL everywhere using |
||
78 | Let's Encrypt. In that case, write a Let's Encrypt section. |
||
79 | |||
80 | Create a New Site from Scratch |
||
81 | ------------------------------ |
||
82 | |||
83 | ### drush instructions (Drupal only) |
||
84 | |||
85 | *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).* |
||
86 | |||
87 | - While in either `/var/www/dev/` or `/var/www/staging`, run the following command to download the latest version of Drupal 7 or 8: |
||
88 | |||
89 | drush dl drupal-7 |
||
90 | drush dl drupal-8 |
||
91 | |||
92 | - Rename the Drupal directory to something that makes sense for the new site |
||
93 | |||
94 | mv drupal-7.34/ healtorture/ |
||
95 | |||
96 | ### wp instructions (WordPress only) |
||
97 | |||
98 | *Skip wp instructions if you're cloning an existing site (e.g. creating a test server from an existing dev/live server).* |
||
99 | |||
100 | - While in `/home` (or `/var/www`), run the following command to download the latest version of WordPress: |
||
101 | |||
102 | wp core download |
||
103 | |||
104 | All Sites |
||
105 | --------- |
||
106 | |||
107 | ### MySQL instructions - all sites |
||
108 | - Create the MySQL database and associated user as listed in settings.php/wp-config.php/civicrm.settings.php: |
||
109 | |||
110 | ``` |
||
111 | #Drupal example |
||
112 | CREATE DATABASE nwu_test_dru; |
||
113 | #WordPress example |
||
114 | CREATE DATABASE nwu_test_wp; |
||
115 | #CiviCRM example |
||
116 | CREATE DATABASE nwu_test_civ; |
||
117 | |||
118 | CREATE USER 'nwu_test'@localhost IDENTIFIED BY 'blahblahblahsomepassword'; |
||
119 | |||
120 | #Drupal/Wordpress |
||
121 | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES, CREATE VIEW ON nwu_test_wp.* TO 'nwu_test'@localhost; |
||
122 | #CiviCRM |
||
123 | 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; |
||
124 | ``` |
||
125 | ### MySQL instructions - cloned sites |
||
126 | |||
127 | *These instructions only apply to git cloned sites. Drupal/Civi/WordPress create a blank database on install for brand new sites.* |
||
128 | |||
129 | *TODO: Document use of "drush pipe" and similar commands* |
||
130 | |||
131 | - On the OLD server, dump a copy of the database(s) you need: |
||
132 | |||
133 | ``` |
||
134 | #Drupal |
||
135 | drush sql-dump > ~/cpehn_drupal.sql |
||
136 | #CiviCRM with Drupal |
||
137 | drush civicrm-sql-dump > ~/cpehn_civi.sql |
||
138 | #WordPress (note - no ">" redirection) |
||
139 | wp db export ~/aclu_wp.sql |
||
140 | #CiviCRM with WordPress |
||
141 | wp civicrm-sql-dump > ~/aclu_civi.sql |
||
142 | #Remove trigger definers from Civi dumps |
||
143 | perl -pi -e 's#\/\*\!5001[7|3].*?`[^\*]*\*\/##g' aclu_civi.sql |
||
144 | ``` |
||
145 | |||
146 | - Copy the database(s) to your local machine (and then to another machine, if need be: |
||
147 | |||
148 | scp aclu:~/*sql . |
||
149 | |||
150 | Import your database(s): |
||
151 | |||
152 | #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 |
||
153 | |||
154 | - \[WordPress Only\] Run `wp search-replace` to change all instances |
||
155 | of the old URL in the database to the new URL. E.g. |
||
156 | `wp search-replace nwu.org nwu.jmaconsulting.biz`. |
||
157 | |||
158 | ### Apache instructions |
||
159 | |||
160 | - 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 |
||
161 | - In /etc/apache2/sites-enabled, enable the new site:\ |
||
162 | |||
163 | a2ensite healtorture.palantetech.coop |
||
164 | |||
165 | - Reload apache: `sudo service apache2 reload` |
||
166 | |||
167 | ### DNS instructions |
||
168 | |||
169 | 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 |
||
170 | ([https://members.mayfirst.org/cp](https://members.mayfirst.org/cp)), going to the "Palante Technology:[palantetech.com](http://palantetech.com)" \ |
||
171 | Live sites: Add the DNS entry using the client's DNS system. You'll need |
||
172 | the namehost password from the client. You can often figure out the |
||
173 | namehost with `whois example.org` and looking for the "Name Server" |
||
174 | listing. |
||
175 | |||
176 | 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. |
||
177 | Examples if the site is hosted on the same computer you use: |
||
178 | |||
179 | 127.0.0.1 ajla.local |
||
180 | |||
181 | Example if the site is on a virtual machine at IP address 192.168.1.6: |
||
182 | |||
183 | 192.168.1.6 ajla.local |
||
184 | |||
185 | ### Run the installer |
||
186 | |||
187 | 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. |
||
188 | |||
189 | ### Install CiviCRM |
||
190 | |||
191 | Follow the [official CiviCRM installation instructions](https://wiki.civicrm.org/confluence/display/CRMDOC/Installation+and+Upgrades) |