WordPress 4.1.1 installation on Ubuntu 14.04: Difference between revisions

From Han Wiki
Jump to navigation Jump to search
Line 135: Line 135:
== Correct the permissions ==
== Correct the permissions ==


<span class="shell">wp-content</span> folder needs to be writable by the web server.
Before the set up:


<div class="cli">
<syntaxhighlight lang="bash">
<span style="color:#00ff00;">mhan</span><span style="color:#444444;">@</span><span style="color:#00cccc;">brahms</span><span style="color:#999999">:</span><span style="color:blue;">/srv/www/blog</span><span style="color:#cccccc;">
chown -R www-data:www-data *  # Change ownership to web server
$ <b class="color:white;">chmod -R 777 wp-content</b>
find . -type d -exec chmod 755 {} \; # directory permissions = rwxr-xr-x
</span></div>
find . -type f -exec chmod 644 {} \; # file permissions = rw-r--r--
</syntaxhighlight>
 
<span class="shell">wp-content</span> folder needs to be writable by the web server after the setup.
 
<syntaxhighlight lang="bash">
chown -R mhan:mhan *
chown -R www-data:www-data wp-content
</syntaxhighlight>


== Complete the installation ==
== Complete the installation ==


This is the final step which doesn't involve any CLI commands. Go to the site URL and it should take you through the rest of the installation process. In the example I used above, it would be <nowiki>http://michael.blog.com</nowiki>. Enjoy.
This is the final step which doesn't involve any CLI commands. Go to the site URL and it should take you through the rest of the installation process. In the example I used above, it would be <nowiki>http://michael.blog.com</nowiki>. Enjoy.

Revision as of 22:39, 22 July 2016

  • Tested on Ubuntu 14.04.2 LTS, Apache/2.4.9, PHP 5.5.15RC1, git 2.0.2, MySQL 5.5.41-0ubuntu0.14.04.1 / easy / less than 10 minutes

There is the Famous 5-Minute Install instruction so these are just my personal notes if I have to install other instances on a similar environment.

Unpack the files

WordPress devs have decided on, what I consider as outdated, SVN, however they have been kind to put up a GitHub repo. This makes it easier to pull or merge latest updates even though the update is supposed to be much simpler.

mhan@brahms:/srv/www/blog $ git clone https://github.com/WordPress/WordPress.git .

Cloning into '.'...
remote: Counting objects: 196601, done.
remote: Compressing objects: 100% (43/43), done.
remote: Total 196601 (delta 28), reused 0 (delta 0), pack-reused 196558
Receiving objects: 100% (196601/196601), 116.49 MiB | 9.94 MiB/s, done.
Resolving deltas: 100% (154751/154751), done.
Checking connectivity... done.
Checking out files: 100% (1424/1424), done.<br>

Set up the database

I'm connecting to the local database.

mhan@brahms:/srv/www/blog $ mysql -uroot -p

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9234
Server version: 5.5.41-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database wp_michael;
Query OK, 1 row affected (0.02 sec)

mysql> grant all on wp_michael.* to 'webacc'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

Update the wp-config.php file

We'll use the default as a starting point. Let's first make a copy of the sample config file.

mhan@brahms:/srv/www/blog $ cp -p wp-config-sample.php wp-config.php

This doesn't add to the security, but I usually keep original files with an extension of .dist (short for distribution).

mhan@brahms:/srv/www/blog $ mv wp-config-sample.php wp-config-sample.php.dist

Make updates to the config file. The lines for salts can be obtained at https://api.wordpress.org/secret-key/1.1/salt/. The following diff shows you the changes I've made.

19c19
< define('DB_NAME', 'database_name_here');
---
> define('DB_NAME', 'wp_michael');
22c22
< define('DB_USER', 'username_here');
---
> define('DB_USER', 'webacc');
25c25
< define('DB_PASSWORD', 'password_here');
---
> define('DB_PASSWORD', 'password');
45,53c45,52
< define('AUTH_KEY',         'put your unique phrase here');
< define('SECURE_AUTH_KEY',  'put your unique phrase here');
< define('LOGGED_IN_KEY',    'put your unique phrase here');
< define('NONCE_KEY',        'put your unique phrase here');
< define('AUTH_SALT',        'put your unique phrase here');
< define('SECURE_AUTH_SALT', 'put your unique phrase here');
< define('LOGGED_IN_SALT',   'put your unique phrase here');
< define('NONCE_SALT',       'put your unique phrase here');
<
---
> define('AUTH_KEY',         'xSiS5fsJx&c6x-1Xd^xv8<IK|Fp2#]jjyxfH7|XRr -sRrH2O]&gS=U7jp:ikj$j');
> define('SECURE_AUTH_KEY',  ';)[9IiH)=]^ca[sYbSrSX!-8Ou?3_B7TN#47^tI#R/l8MaSnc^>|C]Yb9pJBoW/d');
> define('LOGGED_IN_KEY',    '9]&k)u#m;n#40-j4<~X*!}E`RjE]Se[nxa,D}+]b~zu`1+$*L7H4}&C]=4dr]+H8');
> define('NONCE_KEY',        'k3i|O O4 ls_lcaamI-aza)zp|/h4G-KAnOGlQD.Z1k0Pgjc!a fcOXs+B^?6Jus');
> define('AUTH_SALT',        ':SrSJn+FH2.K>udlBa+)a8|wt#l%P*#gQ{bv;{S*Sn+>-GUA~]re`BqL043j7Hlp');
> define('SECURE_AUTH_SALT', 'GpRr[xCm:ECIo$z+-<S{)>W*[QnWagNyD.z|1(6)-+v{5z4GiK7}4Co03,W]Htr~');
> define('LOGGED_IN_SALT',   '_jbNqHC(GT=i|!T?+KFRL>4|S|d:-<..#@NnCb9@m e_nKZomo>W-Da&UEnr)w`j');
> define('NONCE_SALT',       'Sq+|7M++P>BFh6]-aw ja/aRlf(v0!<Q#7DIiun|)G0yJ$0&LknmTVAAY?~-tDon');

Set up the web services

I'm using Apache here, and this is how my config file looks like.

<VirtualHost *:80>
        ServerName michael.blog.com
        ServerAdmin webmaster@server.com
        ServerSignature off
        DocumentRoot /srv/www/blog
        <Directory /srv/www/blog>
                Options -Indexes +FollowSymLinks -MultiViews
                AllowOverride All
                Require all granted

                <IfModule mod_rewrite.c>
                        RewriteEngine On
                        RewriteBase /
                        RewriteRule ^index\.php$ - [L]
                        RewriteCond %{REQUEST_FILENAME} !-f
                        RewriteCond %{REQUEST_FILENAME} !-d
                        RewriteRule . /index.php [L]
                </IfModule>
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>d

Correct the permissions

Before the set up:

chown -R www-data:www-data *  # Change ownership to web server
find . -type d -exec chmod 755 {} \;  # directory permissions = rwxr-xr-x
find . -type f -exec chmod 644 {} \;  # file permissions = rw-r--r--

wp-content folder needs to be writable by the web server after the setup.

chown -R mhan:mhan *
chown -R www-data:www-data wp-content

Complete the installation

This is the final step which doesn't involve any CLI commands. Go to the site URL and it should take you through the rest of the installation process. In the example I used above, it would be http://michael.blog.com. Enjoy.