Set up a New Website » History » Version 17
Jon Goldberg, 05/03/2022 11:45 PM
1 | 2 | Jon Goldberg | {{last_updated_at}} by {{last_updated_by}} |
---|---|---|---|
2 | 1 | Jon Goldberg | |
3 | 2 | Jon Goldberg | {{>toc}} |
4 | 17 | Jon Goldberg | # Set up a New Website - DEPRECATED |
5 | 1 | Jon Goldberg | |
6 | 17 | Jon Goldberg | **This is all handled by Ansible nowadays**. Keeping this up for non-Megaphone folks' benefit. |
7 | 2 | Jon Goldberg | |
8 | 1 | Jon Goldberg | - TODO: Let's Encrypt |
9 | |||
10 | 4 | Jon Goldberg | ## Overview |
11 | 1 | Jon Goldberg | |
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 | 10 | Jon Goldberg | If you don't have a git repo to store the site, you must first [[Create a Git Repo]]. |
15 | 1 | Jon Goldberg | |
16 | 4 | Jon Goldberg | ## Create DNS records |
17 | 1 | Jon Goldberg | |
18 | 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 |
||
19 | 5 | Jon Goldberg | have a domain name of "example.megaphonetech.com", where "example" is replaced by the shortname of the client (e.g. "nwu.megaphonetech.com"). |
20 | 1 | Jon Goldberg | |
21 | 4 | Jon Goldberg | ## Cloning an Existing Site |
22 | 1 | Jon Goldberg | |
23 | *Use these instructions if the site already has a git repo.* |
||
24 | |||
25 | 5 | Jon Goldberg | * Clone the existing git repo. |
26 | * Move to the newly created directory and initialize git. |
||
27 | * Add origin as a remote (substitute the correct repo name below). |
||
28 | 1 | Jon Goldberg | |
29 | 4 | Jon Goldberg | ~~~ shell |
30 | 1 | Jon Goldberg | # Could be /home, could be /var/www, check where other sites on the server are (if any). |
31 | cd /home |
||
32 | mkdir -p clone.example.org/htdocs |
||
33 | cd clone.example.org/htdocs |
||
34 | git init |
||
35 | 5 | Jon Goldberg | # substitute your own repo name for "example" |
36 | git remote add origin ssh://git@git.megaphonetech.com:10022/megaphone/example.git |
||
37 | 1 | Jon Goldberg | # Next line is optional, and shouldn't happen on local dev machines. It allows pushing when your git remote is read-only. |
38 | 5 | Jon Goldberg | git config remote.origin.pushurl https://git.megaphonetech.com/megaphone/example.git |
39 | 1 | Jon Goldberg | git pull origin master |
40 | git submodule update --init --recursive |
||
41 | git branch --set-upstream master origin/master |
||
42 | 4 | Jon Goldberg | ~~~ |
43 | 1 | Jon Goldberg | |
44 | ### Copy/edit settings.php/civicrm.settings.php/wp-config.php |
||
45 | 2 | Jon Goldberg | |
46 | 1 | Jon Goldberg | *Skip this step if this is a new site from scratch (i.e. not a clone ofan existing site). |
47 | |||
48 | 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. |
||
49 | |||
50 | Copy settings from an existing server: |
||
51 | |||
52 | 4 | Jon Goldberg | ~~~ shell |
53 | 1 | Jon Goldberg | # Copy settings.php (Drupal) file from the old server |
54 | scp curds:/var/www/staging/cpehn/sites/default/settings.php . |
||
55 | # For CiviCRM on Drupal: |
||
56 | scp curds:/var/www/staging/cpehn/sites/default/civicrm.settings.php . |
||
57 | # If WordPress: |
||
58 | scp curds:/var/www/staging/aclu/wp-config.php . |
||
59 | # For CiviCRM on WordPress: |
||
60 | scp curds:/var/www/staging/aclu/wp-content/plugins/civicrm/civicrm.settings.php . |
||
61 | |||
62 | # Copy those files to your local install: |
||
63 | # For example: cp ./settings.php /home/jon/local/cpehn/sites/default |
||
64 | 4 | Jon Goldberg | ~~~ |
65 | 1 | Jon Goldberg | |
66 | For Drupal, you must edit the file and change the database name, MySQL username, and MySQL password to match the new server's settings. |
||
67 | |||
68 | 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. |
||
69 | |||
70 | 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. |
||
71 | |||
72 | ### Disable forced SSL if applicable |
||
73 | |||
74 | TODO: Write this section. Or not, if we move to SSL everywhere using |
||
75 | Let's Encrypt. In that case, write a Let's Encrypt section. |
||
76 | |||
77 | 4 | Jon Goldberg | ## Create a New Site from Scratch |
78 | 1 | Jon Goldberg | |
79 | ### drush instructions (Drupal only) |
||
80 | |||
81 | *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).* |
||
82 | |||
83 | 4 | Jon Goldberg | * While in either `/var/www/dev/` or `/var/www/staging`, run the following command to download the latest version of Drupal 7 or 8: |
84 | 1 | Jon Goldberg | |
85 | 4 | Jon Goldberg | ~~~ shell |
86 | drush dl drupal-7 |
||
87 | drush dl drupal-8 |
||
88 | ~~~ |
||
89 | 1 | Jon Goldberg | |
90 | 4 | Jon Goldberg | * Rename the Drupal directory to something that makes sense for the new site |
91 | 1 | Jon Goldberg | |
92 | 4 | Jon Goldberg | ~~~ shell |
93 | mv drupal-7.34/ healtorture/ |
||
94 | ~~~ |
||
95 | 1 | Jon Goldberg | |
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 | 4 | Jon Goldberg | * While in `/home` (or `/var/www`), run the following command to download the latest version of WordPress: |
101 | 1 | Jon Goldberg | |
102 | 4 | Jon Goldberg | ~~~ shell |
103 | wp core download |
||
104 | ~~~ |
||
105 | 1 | Jon Goldberg | |
106 | 4 | Jon Goldberg | ## All Sites |
107 | 1 | Jon Goldberg | |
108 | ### MySQL instructions - all sites |
||
109 | 4 | Jon Goldberg | * Create the MySQL database and associated user as listed in settings.php/wp-config.php/civicrm.settings.php: |
110 | 1 | Jon Goldberg | |
111 | 4 | Jon Goldberg | ~~~ sql |
112 | 1 | Jon Goldberg | #Drupal example |
113 | 4 | Jon Goldberg | CREATE DATABASE nwu_drupal; |
114 | 1 | Jon Goldberg | #WordPress example |
115 | 4 | Jon Goldberg | CREATE DATABASE nwu_wp; |
116 | 1 | Jon Goldberg | #CiviCRM example |
117 | 4 | Jon Goldberg | CREATE DATABASE nwu_civi; |
118 | 1 | Jon Goldberg | |
119 | 4 | Jon Goldberg | CREATE USER 'nwu'@localhost IDENTIFIED BY 'blahblahblahsomepassword'; |
120 | 1 | Jon Goldberg | |
121 | #Drupal/Wordpress |
||
122 | 4 | Jon Goldberg | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES, CREATE VIEW ON nwu_wp.* TO 'nwu'@localhost; |
123 | 1 | Jon Goldberg | #CiviCRM |
124 | 4 | Jon Goldberg | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES, TRIGGER, CREATE ROUTINE, ALTER ROUTINE, CREATE VIEW, REFERENCES ON nwu_civi.* TO 'nwu'@localhost; |
125 | ~~~ |
||
126 | |||
127 | 1 | Jon Goldberg | ### MySQL instructions - cloned sites |
128 | |||
129 | *These instructions only apply to git cloned sites. Drupal/Civi/WordPress create a blank database on install for brand new sites.* |
||
130 | |||
131 | *TODO: Document use of "drush pipe" and similar commands* |
||
132 | |||
133 | 4 | Jon Goldberg | * On the OLD server, dump a copy of the database(s) you need: |
134 | 1 | Jon Goldberg | |
135 | 4 | Jon Goldberg | ~~~ shell |
136 | 1 | Jon Goldberg | #Drupal |
137 | drush sql-dump > ~/cpehn_drupal.sql |
||
138 | #CiviCRM with Drupal |
||
139 | drush civicrm-sql-dump > ~/cpehn_civi.sql |
||
140 | #WordPress (note - no ">" redirection) |
||
141 | wp db export ~/aclu_wp.sql |
||
142 | #CiviCRM with WordPress |
||
143 | 11 | Jon Goldberg | wp cv sql-dump > ~/aclu_civi.sql |
144 | 1 | Jon Goldberg | #Remove trigger definers from Civi dumps |
145 | 16 | Jon Goldberg | perl -pi -e 's#\/\*\!5001[7|3].*?`[^\*]*\*\/##g' aclu_civi.sql |
146 | 4 | Jon Goldberg | ~~~ |
147 | 1 | Jon Goldberg | |
148 | 4 | Jon Goldberg | * Copy the database(s) to your local machine (and then to another machine, if need be: |
149 | 1 | Jon Goldberg | |
150 | ~~~ shell |
||
151 | scp aclu:~/*sql . |
||
152 | ~~~ |
||
153 | |||
154 | * Import your database(s): |
||
155 | |||
156 | ~~~ shell |
||
157 | 5 | Jon Goldberg | #Drupal |
158 | drush sql-cli < ~/cpehn_drupal.sql |
||
159 | #CiviCRM with Drupal |
||
160 | drush civicrm-sql-cli < ~/cpehn_civi.sql |
||
161 | #WordPress (note - no "<" redirection) |
||
162 | wp db import ~/aclu_wp.sql |
||
163 | #CiviCRM with WordPress |
||
164 | 12 | Jon Goldberg | wp cv sql-cli < ~/aclu_civi.sql |
165 | 4 | Jon Goldberg | ~~~ |
166 | 1 | Jon Goldberg | |
167 | 4 | Jon Goldberg | * \[WordPress Only\] Run `wp search-replace` to change all instances |
168 | 1 | Jon Goldberg | of the old URL in the database to the new URL. E.g. |
169 | `wp search-replace nwu.org nwu.jmaconsulting.biz`. |
||
170 | |||
171 | ### Apache instructions |
||
172 | |||
173 | 4 | Jon Goldberg | * 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 |
174 | * In /etc/apache2/sites-enabled, enable the new site: |
||
175 | 6 | Jon Goldberg | |
176 | 4 | Jon Goldberg | ~~~ shell |
177 | a2ensite healtorture.palantetech.coop |
||
178 | ~~~ |
||
179 | 1 | Jon Goldberg | - Reload apache: `sudo service apache2 reload` |
180 | |||
181 | 7 | Jon Goldberg | ### php-fpm instructions |
182 | |||
183 | If your site is running php-fpm, you'll most likely need to create a new user to run the site as, with a corresponding php-fpm pool. |
||
184 | |||
185 | ~~~ shell |
||
186 | useradd <username> -s /bin/false |
||
187 | cd /etc/php/7.0/fpm/pool.d |
||
188 | #copy an existing pool |
||
189 | cp existing.conf new.conf |
||
190 | ~~~ |
||
191 | |||
192 | * In the new .conf file, change the pool name on the first line, as well as the user, group, listen and listen.owner values. |
||
193 | * Restart php-fpm: `systemctl restart php7.0-fpm.service` |
||
194 | |||
195 | 1 | Jon Goldberg | ### DNS instructions |
196 | |||
197 | 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 |
||
198 | ([https://members.mayfirst.org/cp](https://members.mayfirst.org/cp)), going to the "Palante Technology:[palantetech.com](http://palantetech.com)" \ |
||
199 | Live sites: Add the DNS entry using the client's DNS system. You'll need |
||
200 | the namehost password from the client. You can often figure out the |
||
201 | namehost with `whois example.org` and looking for the "Name Server" |
||
202 | listing. |
||
203 | |||
204 | 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. |
||
205 | Examples if the site is hosted on the same computer you use: |
||
206 | |||
207 | 127.0.0.1 ajla.local |
||
208 | |||
209 | Example if the site is on a virtual machine at IP address 192.168.1.6: |
||
210 | |||
211 | 192.168.1.6 ajla.local |
||
212 | |||
213 | ### Run the installer |
||
214 | |||
215 | 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. |
||
216 | |||
217 | ### Install CiviCRM |
||
218 | |||
219 | 4 | Jon Goldberg | Follow the [official CiviCRM installation instructions](https://docs.civicrm.org/sysadmin/en/latest/index.html) |
220 | 8 | Jon Goldberg | |
221 | 9 | Jon Goldberg | ## Special cases |
222 | 8 | Jon Goldberg | * [[Move WP multisite to dev or test site]] |