I am trying to install WordPress on Lubuntu. I followed the instructions here. Including PHP Apache and MySQL setups. Apache and MySQL appear to be running fine.
However, when I go to http://localhost/blog/
, I get the following error:
Neither /etc/wordpress/config-localhost.php nor /etc/wordpress/config-localhost.php could be found.
Ensure one of them exists, is readable by the webserver and contains the right password/username.
Best Answer
I have played that guide step by step. And I think in your case something went wrong and the file
/etc/wordpress/config-localhost.php
actually missing. But this isn't the worst thing. In the manual is missing a step, that describes how to create MySQL database and user for WordPress - the final result. How to do that, under consideration scenario, is described in the article WordPress from the Official Ubuntu Documentation. Another approach is shown under the step 1 below.However, in my opinion the approach, described into the already mentioned manuals, makes the things more complicated as they actually are. Additionally, both manuals doesn't provides enough explanations to be understand what is happen. Here's a guide for you:
How to install the latest WordPress on Ubuntu 16.04 with LAMP
Pre-Requirements
The standard Ubuntu LAMP stack, that means we have working Apache2, MySQL, PHP. Refs:
What's the easiest way to set up a LAMP stack?
Ubuntu Community Help Wiki: Apache MySQL PHP
Linode: How to Install a LAMP Stack on Ubuntu 16.04.
WordPress: Required PHP Extensions
Along with next additional PHP extensions, also
mod_rewrite
for Apache2 must be enabled:1. Create MySQL Database
The steps are:
The commands are:
Where
DatabaseName
,DatabaseUser
andDatabaseUserPassword
are subject of your decision.According to the example the User will be allowed to access the Database only from the localhost, this is enough (and safety) when Apache and MySQL servers are allocated on the same 'physical' machine.
Don't miss the semicolon (
;
) at the end of each sentence. If you are on Ubuntu 18.04+, where the socket authentication is the default authentication method for MySQL, usesudo mysql
to login as root.2.A. Download the latest WordPress release
The steps are:
Go to the directory where WordPress will be stored.
The directory used here is
/var/www
- this is the default directory where the web content should be stored within nowadays Ubuntu versions.Download the latest release.
'UnZip' and 'UnTar' the package, then remove it.
Rename the folder. This step is not mandatory.
I'm usually using the same name for the installation directory, the name of the data base and the name of the virtual host config file. Also these names are based on the Domain Name if there is dedicated one.
Create
upload
directory.Create empty
.htaccess
file.WordPress will write some rewrite riles inside, depending on your preferences. For this purpose this file must be writable (or owned) by
www-data
, alsomod_rewrite
must be enabled and the usage of the.htaccess
file must be allowed by the virtual host configuration - the directiveAllowOverride All
.Change the WordPress directory ownership.
WordPress has mechanisms for auto update and automatic installation of plugins, and I found that, play with permissions and ownership here is complicated task. Into the most manuals as owner of WordPress's content is suggested
www-data
.The commands are:
2.B. Install WordPress from Ubuntu repositories
Another way to install WordPress is through Ubuntu repositories, like it is described here and here. But (within Ubuntu 16.04) the command
apt show wordpress
shows that the version into the repo is 4.4.2 while the current version is 4.8.1. Because WP has an mechanism for automatic update it will force you to update this outdated version to the latest one. So you will end up with 4.8, but after few steps of updates where something could go wrong.The main advantage in this approach is that the installation process of WordPress will involve and some dependencies, as these, mentioned at the top of this post.
3.A. Setup Apache2: Create Virtual Host, dedicated to the particular WordPress
Follow this section if there is dedicated domain or sub-domain name and the WordPress site will be accessible via URL as:
http://my-domain.com
orhttp://someprefix.my-domain.com
.If you don't intend to run other sites in the near future, just edit
000-default.conf
instead of new Virtual Host creation.If you don't have an registered domain name, but you want to access your WP site via domain name instead of IP address (or localhost), you can add line as next somewhere within the
/etc/hosts
file (more details are provided in this answer):Create and edit a new Virtual Host configuration file:
wordpress.
- is subjects of your decision.The content of the file should look as this:
nano
: Shift+Insert for paste; Ctrl+O and Enter for save; Ctrl+X for exit.Enable the configuration and restart Apache2:
3.B. Setup Apache2: Append WordPress to an existing Virtual Host
Follow this section if there is not dedicated domain or sub-domain name and the WP site will be accessible via URL as:
http://my-domain.com/my-blog
orhttp://localhost/my-blog
, etc.Within the two mentioned manuals (this and this) WP is appended to all enabled Virtual Hosts.
Edit the existing Virtual Host configuration file in this way:
Explanation about the directive Alias. Let's assume that
DocumentRoot
is/var/www/html
. In this case the directiveAlias /my-blog /var/www/wordpress-custom-folder
will serve as this symbolic link:Enable the configuration (if it is not enabled) and restart Apache2:
4. Proceed to the web installation of WordPress
Go to the URL
http://someprefix.my-domain.com
orhttp://localhost/my-blog/
in your web browser. The WordPress installer will show up. The data about MySQL data base, created in step 1, must be provided there.That's it.
Setup another instance
To run another instance of WP, just do the steps one more time and use unique data according to the new instance:
Create new Database. You can create and new MySQL User.
Download WP in new directory within
/var/www
.Create new Virtual Host if you using approach 3.A, or, if you using 3.B, setup new
Alias
path and new<Directory>
definitions.Proceed to the web installation of the new WP.
References
How To Install WordPress with LAMP on Ubuntu 16.04 (DigitalOcean)
How to install Wordpress 4.5 on Ubuntu 16.04 LAMP (HowtoForge)
WordPress (Ubuntu documentation: Community Help)
Ubuntu 16.04 + PHP7 + Apache2 + MySQL + WordPress under 10 min (Rene Fürst: YouTube)
Further Reading
Upgrade to the latest PHP version in ubuntu 16.04
WP-CLI: The command line interface for WordPress | WP-CLI on WordPress.org
Installing/Updating WordPress with Subversion (codex.WordPress.org)
Git mirrors for WordPress (make.WordPress.org)
Speed Up Your WordPress Development Cycle With Git (ClintBerry.com)
Managing Your WordPress Site with Git and Composer (DeliciousBrains.com)