{"id":1586,"date":"2016-05-30T09:34:46","date_gmt":"2016-05-30T08:34:46","guid":{"rendered":"http:\/\/slave27.local\/kb\/?p=1586"},"modified":"2016-05-30T09:34:46","modified_gmt":"2016-05-30T08:34:46","slug":"setting-up-wordpress","status":"publish","type":"post","link":"https:\/\/andy.teknostatik.co.uk\/kb\/2016\/05\/30\/setting-up-wordpress\/","title":{"rendered":"Setting up WordPress"},"content":{"rendered":"<p>The following instructions describe how I install WordPress on Ubuntu. The instructions may differ slightly for other server environments, but the basic principles should be the same. This requires shell access to the server, but once it&#8217;s finished the WordPress instance(s) should be capable of being administered through a web browser.<\/p>\n<h3>Part 1 &#8211; Installing WordPress<\/h3>\n<p>Download WordPress and move it to <code>\/var\/www\/html\/<\/code> so it runs from the root directory of the web server.<\/p>\n<p><code>cd \/var\/www\/html<\/code><br \/>\n<code>sudo apt-get install unzip<\/code><br \/>\n<code>sudo wget http:\/\/wordpress.org\/latest.zip<\/code><br \/>\n<code>sudo unzip latest.zip<\/code><br \/>\n<code>cd wordpress<\/code><br \/>\n<code>sudo mv * \/var\/www\/html\/<\/code><br \/>\n<code>cd \/var\/www\/html<\/code><br \/>\n<code>sudo mv index.html index.html_old<\/code><\/p>\n<p>Log into mysql:<\/p>\n<p><code>mysql -u root -p<\/code><\/p>\n<p>Create a new database (calling it something different to the example below)<\/p>\n<p><code>mysql&gt; CREATE DATABASE wordpress;<\/code><br \/>\n<code>mysql&gt; GRANT ALL PRIVILEGES ON wordpress.* TO wp_user@localhost IDENTIFIED BY \"&lt;password&gt;\";<\/code><br \/>\n<code>mysql&gt; exit<\/code><\/p>\n<p>Navigate to <code>\/var\/www<\/code> and issue the following command:<\/p>\n<p><code>sudo chown -R www-data html<\/code><\/p>\n<p>Install WordPress, following the instructions at <a href=\"http:\/\/codex.wordpress.org\/Installing_WordPress\">http:\/\/codex.wordpress.org\/Installing_WordPress<\/a>. Remember to make a note of the username and password you set up for the admin account.<\/p>\n<hr \/>\n<h3>Part 2 &#8211; Configuring WordPress<\/h3>\n<p>Log in using the account you just created.<\/p>\n<p>Install and activate some plugins (Acunetix WP Security, Jetpack by WordPress.com, WP-Markdown and WordPress Importer), via the web interface in WordPress.<\/p>\n<p>Navigate to the left hand menu item for Acunetix WP Security, tick all boxes and click on &#8220;update settings&#8221;. This will apply all recommended security changes.<\/p>\n<p>Use WordPress Importer to import content (posts, tags, files) from other instances of WordPress.<\/p>\n<p>If you want to compose posts in markdown then you&#8217;ll need to navigate to Settings &#8211;&gt; Writing and tick the boxes for the interfaces you want to default to markdown.<\/p>\n<p><em>Note: you won&#8217;t be able to activate Jetpack unless the server is visible on the public internet.<\/em><\/p>\n<p>Remove the &#8220;Hello World!&#8221; post and the sample page (both should be obvious if they have not been removed!)<\/p>\n<hr \/>\n<h3>Part 3 &#8211; WordPress Multisite (optional)<\/h3>\n<p>This allows you to run more than one blog\/site in a single instance of WordPress. The instructions at <a href=\"http:\/\/codex.wordpress.org\/Create_A_Network\">http:\/\/codex.wordpress.org\/Create_A_Network<\/a> are good, and are mostly enough to get it up and running.<\/p>\n<p>There are two more things to do on Ubuntu servers:<\/p>\n<p>Enable <code>mod_rewrite<\/code><\/p>\n<pre><code> a2enmod rewrite\n<\/code><\/pre>\n<p>Open <code>\/etc\/apache2\/apache2.conf<\/code> and find the part that says:<\/p>\n<pre><code> &lt;Directory \/var\/www\/&gt;\n Options Indexes FollowSymLinks\n AllowOverride None\n Require all granted\n &lt;\/Directory&gt;\n<\/code><\/pre>\n<p>Replace <code>AllowOverride None<\/code> with <code>AllowOverride All<\/code><\/p>\n<hr \/>\n<h3>Part 4 &#8211; SSL (optional)<\/h3>\n<p>Enable <code>mod_rewrite<\/code> (if you&#8217;ve not already done it as part of step 3)<\/p>\n<p><code>sudo a2enmod rewrite<\/code><\/p>\n<p>Enable ssl<\/p>\n<p><code>sudo a2enmod ssl<\/code><br \/>\n<code>sudo a2ensite default-ssl.conf<\/code><\/p>\n<p>Amend your apache config to enable pages to be served on port 443<\/p>\n<p><code>sudo nano \/etc\/apache2\/sites-available\/default-ssl.conf<\/code><\/p>\n<pre><code>&lt;VirtualHost _default_:443&gt;\nServername yourdomain.com\nDocumentRoot \/var\/www\/html\n\n#Enable\/Disable SSL for this virtual host.\nSSLEngine on\nSSLProtocol all -SSLv2 -SSLv3\n<\/code><\/pre>\n<p>Amend 80 config (e.g. 000-default.conf), to redirect to 443<\/p>\n<p><code>sudo nano \/etc\/apache2\/sites-available\/000-default.conf<\/code><\/p>\n<pre><code>DocumentRoot \/var\/www\/html\nServerName yourdomain.com\nRedirect \"\/\" \"https:\/\/yourdomain.com\"\n<\/code><\/pre>\n<p>Restart apache<\/p>\n<p><code>sudo service apache2 restart<\/code><\/p>\n<p>Change domain in WordPress settings (through UI) to <code>yourdomain.com<\/code><\/p>\n<p>Create a certificate request (csr):<\/p>\n<p><code>sudo mkdir \/etc\/apache2\/ssl<\/code><br \/>\n<code>sudo openssl req -new -newkey rsa:2048 -nodes -keyout \/etc\/apache2\/ssl\/yourdomain.key -out \/etc\/apache2\/ssl\/yourdomain.csr<\/code><\/p>\n<pre><code>Country Name (2 letter code) [XX]:GB\nState or Province Name (full name) []:West Midlands\nLocality Name (eg, city) [Default City]:Your city\nOrganization Name (eg, company) [Default Company Ltd]:Your Company\nOrganizational Unit Name (eg, section) []:\nCommon Name (eg, your name or your server's hostname) []:yourdomain.com\n<\/code><\/pre>\n<p>Copy certificate somewhere sensible<\/p>\n<p><code>sudo cp \/etc\/apache2\/ssl\/yourdomain.csr \/home\/username\/yourdomain.csr<\/code><\/p>\n<p>What you&#8217;ll need to do then is grab the certificate from home directory, save it somewhere safe and then do whatever you do in your organisation\/environment to generate\/buy\/get a root certificate (there are so many different ways).<\/p>\n<p>Once you have a root certificate, follow instructions at http:\/\/askubuntu.com\/questions\/73287\/how-do-i-install-a-root-certificate<\/p>\n<p>Configure apache to use certificate<\/p>\n<p><code>sudo nano \/etc\/apache2\/sites-available\/default-ssl.conf<\/code><\/p>\n<p>Then add\/edit the following lines:<\/p>\n<pre><code>SSLEngine on\nSSLProtocol all -SSLv2 -SSLv3\nSSLCertificateFile  \/etc\/apache2\/ssl\/yourdomain.com.cer\nSSLCertificateKeyFile \/etc\/apache2\/ssl\/yourdomain.key\n<\/code><\/pre>\n<p>Restart apache<\/p>\n<p><code>sudo service apache2 restart<\/code><\/p>\n<p>At that point your site should serve web pages on https with no error messages.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following instructions describe how I install WordPress on Ubuntu. The instructions may differ slightly for other server environments, but the basic principles should be the same. This requires shell access to the server, but once it&#8217;s finished the WordPress instance(s) should be capable of being administered through a web browser. Part 1 &#8211; Installing &#8230; <a title=\"Setting up WordPress\" class=\"read-more\" href=\"https:\/\/andy.teknostatik.co.uk\/kb\/2016\/05\/30\/setting-up-wordpress\/\" aria-label=\"Read more about Setting up WordPress\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","_share_on_mastodon":"0"},"categories":[5,8,11],"tags":[],"class_list":["post-1586","post","type-post","status-publish","format-standard","hentry","category-linux","category-ubuntu","category-wordpress"],"share_on_mastodon":{"url":"","error":""},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/posts\/1586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/comments?post=1586"}],"version-history":[{"count":0,"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/posts\/1586\/revisions"}],"wp:attachment":[{"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/media?parent=1586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/categories?post=1586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/tags?post=1586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}