Difference between revisions of "WordPress"

From Earlham CS Department
Jump to navigation Jump to search
(Created page with "This is how to create a WordPress site. Assumes you have permissions on the CS web server (see admins if not). === WordPress Setup === 1. Unzip the file and name it “ word...")
 
m
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
This is how to create a WordPress site. Assumes you have permissions on the CS web server (see admins if not).
 
This is how to create a WordPress site. Assumes you have permissions on the CS web server (see admins if not).
  
=== WordPress Setup ===
+
=== Add a site to the multisite instance ===
1. Unzip the file and name it “ wordpress-site  name”
 
  
* tar -xvzf wp_download.tar.gz // This file lies in /var/www b. mv wordpress/  wordpress-sitename
+
This is the simplest way to make a new site that is easily maintained.
  
2. Create a mysql database with the name “w  p_  sitename”
+
Much of this requires admin permissions at either the WordPress level or the system level.
  
* mysql -u root -p // You will need the password
+
Note: where you see "sitename", substitute your site's name, which should be one token with letters and numbers only if possible.
* MariaDB [(none)]> create database w p  _sitename;
+
 
* MariaDB [(none)]> exit
+
# Add your chosen domain name as a CNAME for web dot cs dot earlham dot edu in DNS.
 +
# As a Network Admin, go to Sites > Add New.
 +
## It will default to cs.earlham.edu/sitename rather than sitename.cs.earlham.edu. Leave it that way for now.
 +
## Use the email address associated with your CS user account as the admin address.
 +
## After the site is created, click "Edit".
 +
## Now use the sitename.cs.earlham.edu pattern as the "Site Address (URL)".
 +
# Visit sitename.cs.earlham.edu to see if you can access the page.
 +
 
 +
===  Single-site WordPress Setup ===
 +
1. cd to /var/www/ and unzip the file and name it “wordpress-sitename”
 +
 
 +
  >> cd /var/www/
 +
  >> tar -xvzf wp_download.tar.gz
 +
  >> mv wordpress/  wordpress-sitename
 +
 
 +
2. Create a mysql database with the name “wp_sitename” and give “wpadmin” access to it:
 +
 
 +
  >> mysql -u root -p   // You will need the password
 +
  MariaDB [(none)]> create database wp_sitename;
 +
  // '''you will need to enter the wordpress username and password in place of <user> and <pass>'''
 +
  MariaDB [(none)]> grant all privileges on wp_sitename.* to '<user>'@'localhost' identified by '<pass>';  
 +
  MariaDB [(none)]> flush privileges;  
 +
  MariaDB [(none)]> exit
  
 
3. Rename the config file and edit it
 
3. Rename the config file and edit it
* cd wordpress-sitename/
 
* mv wp-config-sample.php wp-config.php
 
* vi wp-config.php // Here you will be editing the Mysql settings
 
  
You will need the name of the database, username (root or wpadmin should work) and the corresponding password:
+
  >> cd wordpress-sitename/
 +
  >> mv wp-config-sample.php wp-config.php
 +
  >> vi wp-config.php // Here you will be editing the Mysql settings
 +
 
 +
You will need the name of the database, username (use wpadmin as you have already granted it privileges) and the corresponding password:
  
 
The edited version should look like:
 
The edited version should look like:
  
* // ** MySQL settings - You can get this info from your web host ** //
+
  // ** MySQL settings - You can get this info from your web host ** //
* /** The name of the database for WordPress */
+
  /** The name of the database for WordPress */
* define('DB_NAME', 'wp_sitename');
+
  define('DB_NAME', 'wp_sitename');
* /** MySQL database username */
+
  /** MySQL database username */
* define('DB_USER', username);
+
  define('DB_USER', username);
* /** MySQL database password */
+
  /** MySQL database password */
* define('DB_PASSWORD', password);
+
  define('DB_PASSWORD', password);
* /** MySQL hostname */
+
  /** MySQL hostname */
* define('DB_HOST', 'localhost');
+
  define('DB_HOST', 'localhost');
* /** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8');
+
  /** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8');
* /** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', '');
+
  /** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', '');
  
 
Everything else in this file should remain the same.
 
Everything else in this file should remain the same.
  
 
* You can also view similar files to make sure the config file is setup properly, and copy the username and password for database from there.
 
* You can also view similar files to make sure the config file is setup properly, and copy the username and password for database from there.
* view ../wordpress-datascience/wp-config.php
+
  >> view ../wordpress-datascience/wp-config.php
  
 
4. Change owner and permissions
 
4. Change owner and permissions
* chown -R www-data:www-data wordpress-sitename/
+
 
* chmod -R 755 wordpress-sitename/
+
  >> chown -R www-data:www-data wordpress-sitename/
* mkdir -p /var/www/wordpress-sitename/wp-content/uploads
+
  >> chmod -R 755 wordpress-sitename/
* chown -R :www-data /var/www/wordpress-sitename/wp-content/uploads/
+
  >> mkdir -p /var/www/wordpress-sitename/wp-content/uploads
 +
  >> chown -R :www-data /var/www/wordpress-sitename/wp-content/uploads/
  
 
5. Setting up the website and ssl cert
 
5. Setting up the website and ssl cert
* cd /etc/apache2/sites-available/
+
 
* cp datascience.cs.earlham.edu-ssl.conf sitename.cs.earlham.edu-ssl.conf
+
  >> cd /etc/apache2/sites-available/
 +
  >> cp datascience.cs.earlham.edu-ssl.conf sitename.cs.earlham.edu-ssl.conf
 
* Edit the .conf file and change the word datascience to your sitename
 
* Edit the .conf file and change the word datascience to your sitename
vi sitename.cs.earlham.edu-ssl.conf
+
  >> vi sitename.cs.earlham.edu-ssl.conf
 
* Create a link from sites-available to sites-enabled
 
* Create a link from sites-available to sites-enabled
- ln -s sitename.cs.earlham.edu-ssl.conf /etc/apache2/sites-enabled/sitename.cs.earlham.edu-ssl.conf
+
  >> ln -s sitename.cs.earlham.edu-ssl.conf /etc/apache2/sites-enabled/sitename.cs.earlham.edu-ssl.conf
  
 
6. Enable the site
 
6. Enable the site
* a2ensite sitename.cs.earlham.edu-ssl.conf b. service apache2 reload
+
 
* service apache2 restart
+
  >> a2ensite sitename.cs.earlham.edu-ssl.conf   // If this doesn't work, please talk to a sys-admin 
This will enable the website - ask admins to create DNS entry
+
  >> service apache2 reload
 +
  >> service apache2 restart
 +
 
 +
'''This will enable the website - ask admins to create DNS entry'''
  
 
7. Install WordPress and enjoy!
 
7. Install WordPress and enjoy!
 
* https://sitename.cs.earlham.edu/wp-admin/install.php
 
* https://sitename.cs.earlham.edu/wp-admin/install.php
 +
 +
8. Changing the settings of the page:
 +
* Go to Settings > Permalinks, and choose the format you would like // For e.g. I chose Post Name as the setting.
 +
* Click on the Custom setting, and add "/index.php/" before the name setting, such that the setting changes from "/%postname%/" to "/index.php/%postname%/" // for Post Name setting.
 +
 +
9. If you're unable to create a page/post, or upload media, you need to change the permissions again. Repeat step 4 for changing permissions and owners.
 +
 +
= Misc notes =
 +
 +
As of Jan 2021 we use PHP 7.2 for WordPress. The correct php.ini file is: <code>/etc/php/7.2/apache2/php.ini</code>

Revision as of 10:58, 23 March 2021

This is how to create a WordPress site. Assumes you have permissions on the CS web server (see admins if not).

Add a site to the multisite instance

This is the simplest way to make a new site that is easily maintained.

Much of this requires admin permissions at either the WordPress level or the system level.

Note: where you see "sitename", substitute your site's name, which should be one token with letters and numbers only if possible.

  1. Add your chosen domain name as a CNAME for web dot cs dot earlham dot edu in DNS.
  2. As a Network Admin, go to Sites > Add New.
    1. It will default to cs.earlham.edu/sitename rather than sitename.cs.earlham.edu. Leave it that way for now.
    2. Use the email address associated with your CS user account as the admin address.
    3. After the site is created, click "Edit".
    4. Now use the sitename.cs.earlham.edu pattern as the "Site Address (URL)".
  3. Visit sitename.cs.earlham.edu to see if you can access the page.

Single-site WordPress Setup

1. cd to /var/www/ and unzip the file and name it “wordpress-sitename”

 >> cd /var/www/
 >> tar -xvzf wp_download.tar.gz
 >> mv wordpress/  wordpress-sitename

2. Create a mysql database with the name “wp_sitename” and give “wpadmin” access to it:

 >> mysql -u root -p    // You will need the password
 MariaDB [(none)]> create database wp_sitename;
 // you will need to enter the wordpress username and password in place of <user> and <pass>
 MariaDB [(none)]> grant all privileges on wp_sitename.* to '<user>'@'localhost' identified by '<pass>';  
 MariaDB [(none)]> flush privileges; 
 MariaDB [(none)]> exit

3. Rename the config file and edit it

 >> cd wordpress-sitename/
 >> mv wp-config-sample.php wp-config.php
 >> vi wp-config.php // Here you will be editing the Mysql settings

You will need the name of the database, username (use wpadmin as you have already granted it privileges) and the corresponding password:

The edited version should look like:

 // ** MySQL settings - You can get this info from your web host ** //
 /** The name of the database for WordPress */
 define('DB_NAME', 'wp_sitename');
 /** MySQL database username */
 define('DB_USER', username);
 /** MySQL database password */
 define('DB_PASSWORD', password);
 /** MySQL hostname */
 define('DB_HOST', 'localhost');
 /** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8');
 /** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', );

Everything else in this file should remain the same.

  • You can also view similar files to make sure the config file is setup properly, and copy the username and password for database from there.
 >> view ../wordpress-datascience/wp-config.php

4. Change owner and permissions

 >> chown -R www-data:www-data wordpress-sitename/
 >> chmod -R 755 wordpress-sitename/
 >> mkdir -p /var/www/wordpress-sitename/wp-content/uploads
 >> chown -R :www-data /var/www/wordpress-sitename/wp-content/uploads/

5. Setting up the website and ssl cert

 >> cd /etc/apache2/sites-available/
 >> cp datascience.cs.earlham.edu-ssl.conf sitename.cs.earlham.edu-ssl.conf
  • Edit the .conf file and change the word datascience to your sitename
 >> vi sitename.cs.earlham.edu-ssl.conf
  • Create a link from sites-available to sites-enabled
 >> ln -s sitename.cs.earlham.edu-ssl.conf /etc/apache2/sites-enabled/sitename.cs.earlham.edu-ssl.conf

6. Enable the site

 >> a2ensite sitename.cs.earlham.edu-ssl.conf   // If this doesn't work, please talk to a sys-admin  
 >> service apache2 reload
 >> service apache2 restart

This will enable the website - ask admins to create DNS entry

7. Install WordPress and enjoy!

8. Changing the settings of the page:

  • Go to Settings > Permalinks, and choose the format you would like // For e.g. I chose Post Name as the setting.
  • Click on the Custom setting, and add "/index.php/" before the name setting, such that the setting changes from "/%postname%/" to "/index.php/%postname%/" // for Post Name setting.

9. If you're unable to create a page/post, or upload media, you need to change the permissions again. Repeat step 4 for changing permissions and owners.

Misc notes

As of Jan 2021 we use PHP 7.2 for WordPress. The correct php.ini file is: /etc/php/7.2/apache2/php.ini