Project

General

Profile

Set up a New Website » History » Version 5

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