Install and configure WordPress

@karye what is it you want changed, and why? the text you wrote above is a direct one-for-one identical copy of what is already in the document.

In the guide CLI commands are shown in separate grey boxes.
It would enhance readability for beginners to split this paragraph and use
```sudo 2ensite wordpress```
not `sudo a2ensite wordpress` etc…

Hello all. I’ve reviewed this post several times in the past over the years, as well as have tried to make corrections and pass on any information that I think would be helpful to first time or amateur WordPress on Ubuntu installers. I was a bit dismayed when the original author made the decision to use the ‘upstream WordPress recommended installation’ instead of the original way it was written, what I believe is the Ubuntu way, but the author has the discretion to write the article in any way he feels necessary.

apt install wordpress

That should be the start for anyone installing WordPress on current versions of Ubuntu. Should also be the way this article should start, however the author has opted for ‘upstream Recommended installation’ which I completely understand. However it does get away from the ‘Ubuntu’ way.

I’m fully aware of the issues to install Wordpress the recommended way versus the apt install wordpress way and it comes down to configuration. There’s still lots of assumptions being made in this new revamped article. Though the idea is correct and in some instances I would use that option, I like having the control and security of the database details being set up in /etc/wordpress/config-hostname.php. Additionally with the Apache integration I also like to setup virtual hosts for each and every host on an Apache web server because it’s just the right way to do it. By default the Ubuntu Apache 2 configuration wants separate files for ssl and non-ssl web sites, which not only do I think is stupid but it makes things complicated. I create the virtual hosts file as a single file for each host, virtual or otherwise and put both the non-ssl (port 80) and ssl (port 443) apache configuration in each of the vhosts into a single file for /etc/apache2/sites-available. At this point new and amateur Linux/Apache/Wordpress users should be thoroughly confused and veteran sysadmins are following me along and hopefully agreeing.

All of the issues usually have to do with either something in the initial configuration and where those configuration files are, or have to do with subsystem upgrades where the command usage is slightly different, as evidenced by some of the confusion above in the MySQL statements, the create user/password issue repetitively occurs. I won’t go into the details of changing MySQL user passwords with the ALTER SQL syntax because again, I think it just makes things more complicated.

With the default installation of Apache 2 and Wordpress on Ubuntu it’s my opinion that this article should reflect that and either have WordPress installed into the default ‘html’ (/var/www/html) directories and NOT removing the 000-default* files, which are the default vhost config files for the web server operation on ports 80 and 443 (ssl) OR deleting all the 000-default* files and spell out in the tutorial how to create the vhost file for both port 80 and 443 in a single file.

Yes, I’m a bit of an expert not only of Linux, but of Apache 2 (and 1) and Wordpress as I have been using all those products for 15-40 years, depending. Regardless of how your installing your Ubuntu or Wordpress I’m open to personally help anyone having issues and get their web site up and running. Just look up my profile and send me an email.

I additionally have several web servers up and running (azure.zettabytes.org, weeklynewsworld.com) which is but a short collection of sites I’ve been working on lately. I can setup shell accounts and give some visibility on how a ‘production’ sites run with visibility into the actual configuration files.

It’s always just the initial setup and configuration which give the most headaches as there are many many ways a site might be configured but once a WordPress is finally up and running, I’ve found it to be very reliable.

If anyone wants some help with their setup drop me a line.

Ron

1 Like

The “Ubuntu way” that you mention is explicitly unsupported by WordPress. The method I chose for the update to a very out of date document is the most likely to be able to be supported; not just by Ubuntu people who understand the hosting stack, but also by WordPress support volunteers at the WordPress Support Forums and IRC (#WordPress on LiberaChat).

It’s also worth mentioning that WordPress in the Ubuntu archive is under the auspices of the MOTU, which means that security patching is on a “best effort”, volunteer, basis and means that security patches are often missed or not deployed in a timely manner - the WordPress way in this document means that security patches issued by WordPress.org are installed as soon as they are available.

While I agree that merging port 80 and 443 configuration into the same file is expedient, this tutorial doesn’t mention TLS in any way so including that information is superfluous.

1 Like

Ah I see what you mean. Thanks for the tip, I’ve updated the document to put the commands in that paragraph to separate blocks.

Just a suggestion, as the audience is clearly command line capable, would it not be to first install WP CLI, then downloading core, setting up wp_config.php and the initial build of WordPress can be distilled into simple command lines

Not sure if you understood me, but I support the official Ubuntu release (well, amalgamation of) which you get by:

apt install ubuntu.

I personally use latest.tar and do build all my Wordpress sites (I have about 72 I’m the admin for currently) by hand using the ‘upstream’ method.

However, for people that know little very Linux, the upstream method tends to be more difficult, in my opinion.

Anyways, just wanted to clear that up. I’ve been helping out in this thread for years now and was probably the reason the original editor came back to clean things up.

Thanks to all the people I have helped over the years. I can see your Wordpress sites are still up, and being managed now by yourself!

Ron

So for the person’s and or people having that MySQL password issue, use this syntax:

alter ‘user’@‘localhost’ identified with caching_sha2_password by ‘password’;

Now obviously if that user entry has password options set to set to something other than sha2, for example like the default root user on mysql for ubuntu, it won’t work, but you just created the user, didn’t you? So it will work :wink:

Obviously update user, localhost and password to whatever is appropriate for your environment.

Ron

Add: apt install curl
because it is used on the next step

This isn’t needed. curl is installed by default.

I’ve tried following this guide - and when GRANTING permissions to my wordpress database, MYSQL returns 0 rows updated. Which isn’t great.

  • create user ‘user’@’localhost’ identified by ‘password’;
  • create database appdb;
  • grant all privileges on appdb.* to ‘user’@’localhost’;
  • flush privileges;

And to get rid of of your prior tries just in case they exist:

  • drop user;
  • drop database;

Use the first set of commands and see if that clears up your issues. Use the drop commands to clear out earlier attempts that didn’t work.

Let me know how it went and whether you need further help.

Ron
PS: Remember to update ‘user’, ‘localhost’ and ‘password’ to whatever is correct for your setup.

sudo systemctl start mysql[quote=“system, post:1, topic:13959”]
Enable MySQL with sudo service mysql start.
[/quote]

Enable MySQL with sudo systemctl enable mysql.

Making my first post, and I’m new to WordPress! My apologies if I’m doing this wrong.

Let’s add a suggestion to have users add 198.143.164.251 api.wordpress.org to /etc/hosts. I recently installed WordPress.org on my Ubuntu Server 20.04 VM. I got the sample site running, and I was able to access wp-admin too. But I encountered errors when trying to add plugins or themes.

I resolved my errors by making the above changes.

Thanks so much for all that y’all do! I couldn’t do my thang without y’all!

If your server is configured to resolve DNS queries this is not needed. The vast majority of installations don’t need this.

I’ve got another suggestion too – the Ubuntu tutorial doesn’t say to download the following php packages – php-gd php-xmlrpc php-soap.

I didn’t install these because this Ubuntu tutorial didn’t say we had to. I was unable to install plugins and themes. Once I installed these other php packages, I was able to install themes and plugins without issue.

In the page Configure WordPress, the user is instructed to "Open http://localhost/". This applies only if the user has installed Apache and WordPress on their local machine. In the more frequent case in which they’re being installed on a separate server (with no web browser), the more useful instruction would be to tell the user to open http://{address or domain} where {address or domain} is either an IP address by which the server can be reached or its domain name. This is the one point that briefly threw me in going through an otherwise excellent tutorial.

New to this. This tutorial contains the following in step 3:

sudo mkdir -p /srv/www
sudo chown www-data: /srv/www
curl https://wordpress.org/latest.tar.gz | sudo -u www-data tar zx -C /srv/www

Note that this sets the ownership to the user www-data, which is potentially insecure, such as when your server hosts multiple sites with different maintainers. You should investigate using a user per website in such scenarios and make the files readable and writable to only those users. This will require configuring PHP-FPM to launch a separate instance per site each running as the site’s user account. In such setup the wp-config.php should (read: if you do it differently you need a good reason) be readonly to the site owner and group and other permissions set to no-access (chmod 400). This is beyond the scope of this guide, however.<

If one were to use this guide then later added an additional site, both sites would be vulnerable. I have researched quite a bit but not able to find one for ubuntu and Apache2 (without Nginx)
Would anyone know of such a guide?

Perhaps the author could add such a guide to link to?

Forgive me if I am a bit of a newbie on this.

Thanks all.

GRANT is no longer supported in MYSQL 8.x
grant alter,create,delete,drop,index,insert,select,update,trigger,alter routine,
-> create routine, execute, create temporary tables on wordpressusr.* to ‘wordpressusr’;

will work. some od the privileges shown above may be unnecessary.

Note FLUSH PRIVILEGES has never been required after GRANT/CREATE USER or any user SQL (excluding direct hacks of underlying tables which is not encouraged).