{"id":1505,"date":"2016-05-11T07:02:25","date_gmt":"2016-05-11T06:02:25","guid":{"rendered":"http:\/\/slave24.local\/wordpress\/?p=1505"},"modified":"2016-05-11T07:02:25","modified_gmt":"2016-05-11T06:02:25","slug":"installing-and-configuring-wordpress","status":"publish","type":"post","link":"https:\/\/andy.teknostatik.co.uk\/kb\/2016\/05\/11\/installing-and-configuring-wordpress\/","title":{"rendered":"Installing and configuring 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<\/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>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<p>At one point in the installation you will need to issue the following command to manually create a config file.<\/p>\n<p><code>sudo nano wp-config.php<\/code><\/p>\n<p>Once WordPress is installed, navigate to <code>\/var\/www<\/code> (<code>cd ..<\/code> or <code>cd \/var\/www\/<\/code>) and issue the following command:<\/p>\n<p><code>sudo chown -R www-data html<\/code><\/p>\n<p>This will ensure you can install plugins and themes through the WordPress web interface.<\/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 and WordPress Importer), via the web interface in WordPress (if you&#8217;ve not issued the command above then this won&#8217;t work).<\/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><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 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>Request Certificate<\/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>Grab the certificate from home directory and save somewhere safe.<\/p>\n<p>Do whatever you do in your organisation\/environment to generate\/buy\/get a root certificate.<\/p>\n<p>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<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>Browse to http:\/\/yoursite.com to check the certificate has been picked up.<\/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=\"Installing and configuring WordPress\" class=\"read-more\" href=\"https:\/\/andy.teknostatik.co.uk\/kb\/2016\/05\/11\/installing-and-configuring-wordpress\/\" aria-label=\"Read more about Installing and configuring WordPress\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","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],"tags":[],"class_list":["post-1505","post","type-post","status-publish","format-standard","hentry","category-linux","category-ubuntu"],"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\/1505","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=1505"}],"version-history":[{"count":0,"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/posts\/1505\/revisions"}],"wp:attachment":[{"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/media?parent=1505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/categories?post=1505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andy.teknostatik.co.uk\/kb\/wp-json\/wp\/v2\/tags?post=1505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}