Differences between revisions 2 and 32 (spanning 30 versions)
Revision 2 as of 2013-11-26 10:11:43
Size: 2959
Comment:
Revision 32 as of 2021-12-10 07:03:23
Size: 9573
Editor: ?MarkusBrummer
Comment: Fixed codename numbering typo
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
[[http://wordpress.org/|Home Page]]

WordPress is a free and open source (GNU GPLv2 or later) blogging tool and a content management system (CMS) based on PHP and MySQL.Features include a plug-in architecture and a template system.

== Basic Installation guide for Wheezy ==

{{{# apt-get install wordpress curl apache2 mysql-server}}}

Set the mysql admin root user password when prompted
#language en
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: none-~
----
WordPress is a free and open source (GNU GPLv2 or later) blogging tool and a content management system (CMS) based on PHP and MySQL. Features include a plug-in architecture and a template system.

WordPress versions for different Debian version (updated December 2021):
 * Debian 10 (Buster): 5.0.14
 * Debian 11 (Bullseye): 5.7.1
 * Debian 12 (Bookworm): 5.8.1

<<TableOfContents(3)>>

== Packages Installation ==

=== Installation ===

{{{
apt update
apt install wordpress curl apache2 mariadb-server
}}}

Secure your MySQL installation with this command:

{{{
mysql_secure_installation
}}}

== Basic Installation guide ==
Line 13: Line 32:
{{{# nano /etc/apache2/sites-available/wp}}}

Add this content:-
{{{
        Alias /wp /usr/share/wordpress
        Alias /wp/wp-content /var/lib/wordpress/wp-content
{{{
nano /etc/apache2/sites-available/wp.conf
}}}

Add this content, and replace '''example.com''' by your own domain:

{{{
<VirtualHost *:80>
 ServerName myblog.example.com

 ServerAdmin webmaster@example.com
 DocumentRoot /usr/share/wordpress

        Alias /wp-content /var/lib/wordpress/wp-content
Line 23: Line 50:
            Order allow,deny
            Allow from all
            Require all granted
Line 28: Line 54:
            Order allow,deny
            Allow from all
            Require all granted
Line 31: Line 56:
}}}

=== Enable the site ===

{{{# a2ensite wp}}}

=== Restart the webserver ===

{{{# service apache2 reload}}}

Create `/etc/wordpress/config-$DM.php` (where `$DM` is the domain name e.g. if the fully qualified domain name is `debianwordpress.dev` create `/etc/wordpress/config-dev.php`)

{{{# nano /etc/wordpress/config-dev.php}}}

Add this content:-

 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
}}}

=== Disable default Virtual Host, and enable the site ===

{{{
a2dissite 000-default
a2ensite wp
}}}

=== Reload the webserver ===

{{{
service apache2 reload
}}}

Create `/etc/wordpress/config-$DM.php`. `$DM` is the domain name e.g. if the fully qualified domain name is `myblog.example.com`, create one of the following files:
 * `/etc/wordpress/config-myblog.example.com.php` (this is the default, use it if you are unsure)
 * `/etc/wordpress/config-example.com.php` (this is used for multisite with subdomains)
 * `/etc/wordpress/config-default.php` (this is used as a fallback if no other file matches your domain name)
WordPress searches in the above order and uses the first configuration file it can find. The domain name is taken from the HTTP-Request of your browser. That way you may be able to define different configuration files for different domains you are hosting.

{{{
nano /etc/wordpress/config-myblog.example.com.php
}}}

Add this content:
Line 56: Line 98:
<!> replace `password` with a suitably secure password
Line 58: Line 102:
{{{# nano ~/wp.sql}}}

Add this content:-
{{{
nano ~/wp.sql
}}}

Add this content: <!> replace `password` with your "suitably secure password"
Line 70: Line 117:
'''NOTE:''' replace `password` with a suitably secure password

Create the database:-

{{{# cat ~/wp.sql | mysql --defaults-extra-file=/etc/mysql/debian.cnf}}}

Navigate to the wordpress directory in browser e.g.:-
`http://debianwordpress.dev/wp` which redirects to `http://debianwordpress.dev/wp/wp-admin/install.php` where you'll see the "classic" wordpress 5 minute install page (actually a 5 second install thanks to the Debian packagers [[http://packages.qa.debian.org/w/wordpress.html|Giuseppe Iuculano and Raphaël Hertzog]])

At time of writing this provides WordPress v3.6.1
Upgrading WordPress, plugins and themes, as well as installing them is the same process with the Debian package as with the upstream installer.

 ----

See also:-
 * [[LaMp]]

 ----

Additional references:-
 * [[http://codex.wordpress.org/Main_Page|WordPress Online Documentation]]
Create the database:

{{{
cat ~/wp.sql | mysql --defaults-extra-file=/etc/mysql/debian.cnf
}}}

Navigate to the wordpress directory in browser e.g. `http://myblog.example.com/wp` which redirects to `http://myblog.example.com/wp/wp-admin/install.php` where you'll see the "classic" wordpress 5 minute install page (actually a 5 second install thanks to the Debian packaging)

<!> replace `myblog.example.com` with your domain name (or `localhost` if running on the same box as your browser).

== Upgrading the installed WordPress version ==

For keeping your WordPress up to date and receiving security fixes use Debian package manager:

{{{
apt update && apt upgrade
}}}

If you would like to use a more recent version of WordPress, consider using [[Backports]] or [[DebianTesting|Debian testing]].

== An alternate installation method ==

I believe this method conforms more with how the maintainer recommends it should be done. Various sources are drawn upon using this method, and it is also affected by a few bugs as of this writing. It is basically centered around a "kind of" multi-site install, but I recommend this method even for a single blog, otherwise when you decide down the road to have more than one and share the packages' codebase, you'll have a fair bit of work on your hands.

The key useful script here is `/usr/share/doc/wordpress/examples/setup-mysql`. This gem does a few things:

 * Creates a WordPress config file under `/etc/wordpress`
 * Creates the WordPress database and user
 * Sets up a `wp-content` structure under `/srv/www/wp-content/DOMAIN` (this is key for a non-WordPress multi-site install, which is covered more below)

=== Run the helper script ===

Now run `/usr/share/doc/wordpress/examples/setup-mysql`, passing an argument of your site name; eg. `myblog.com`. You will most probably need other arguments too -- just try an initial `-h` to get help.

{{{
# Required package
apt install iputils-ping

# Unzip the file
gzip -d /usr/share/doc/wordpress/examples/setup-mysql.gz
# Set as executable
chmod +x /usr/share/doc/wordpress/examples/setup-mysql

# Run the setup, change myblog.example.com to your FQDN
/usr/share/doc/wordpress/examples/setup-mysql myblog.example.com
}}}

At this point, as per above, you should have a database created for you, and the `/etc/wordpress/config-myblog.com.php` config file. Peruse that and sanity check it.

=== Create the Apache site ===

Quoting `/usr/share/doc/wordpress/examples/apache.conf`:

There are several ways to setup Wordpress & Apache in Debian. However the maintainer's recommended way with the helper script `setup-mysql` uses:

{{{
## Virtual host VirtualDocumentRoot

        NameVirtualHost *:80

        <VirtualHost *:80>
        UseCanonicalName Off
        VirtualDocumentRoot /usr/share/wordpress
        Options All

        # wp-content in /srv/www/wp-content/$0
        RewriteEngine On
        RewriteRule ^/wp-content/(.*)$ /srv/www/wp-content/%{HTTP_HOST}/$1
        </VirtualHost>
}}}

For this configuration to work you'll also need to have `mod_rewrite` and `mod_vhost_alias` loaded and working in Apache. To enable these modules run

{{{
a2enmod rewrite
a2enmod vhost_alias
service apache2 restart
}}}

Place this config into something like `/etc/apache2/sites-available/myblog.com` and modify according to your needs (IP-based virtual host, name-based, logging, etc.)

If you're using any Wordpress functionality that requires URL rewriting (such as permalinks), then you will also need something like this in your Apache config:

{{{
    RewriteRule ^index\.php$ - [L]
    RewriteCond /usr/share/wordpress%{REQUEST_URI} !-f
    RewriteCond /usr/share/wordpress%{REQUEST_URI} !-d
    RewriteRule . /usr/share/wordpress/index.php [L]
    # Also needed if using PHP-FPM / Fast-CGI
    RewriteCond %{REQUEST_URI} !^/php5-fcgi/*
}}}

The above rewrite conditions rely on Apache finding the required files in /usr/share/wordpress for non-permalinks (such as wp-admin). This may require the following line to ensure it finds the index file when requesting /wp-admin/

{{{
    DirectoryIndex index.php
}}}

=== Final reading before actual configuration ===

Now would be a great time to read `/usr/share/doc/wordpress/README.Debian` if you haven't already. All the rest of the pieces should fall into place once you do.

Amongst other things, it explains the great way that the Debian WordPress package utilises the WordPress `wp-config.php` framework, and more importantly, how to handle the infamous "themes" and "plugins" directories in a WordPress install. The key point is that by symlinking under `/var/lib/wordpress`, users better abide by the [[FilesystemHierarchyStandard]], and can use the in-app upgrade mechanisms of WordPress to upgrade plugins and themes, without clobbering the package, and risking server security.

It also discusses the two choices regarding multi-site installs, of which this here describes the non-WordPress version.

=== Enable the Apache site ===

Now we enable the Apache site config made earlier using `a2ensite`, which basically just creates a symlink in `/etc/apache2/sites-enabled` from `sites-available`, then reload Apache:

{{{
a2ensite myblog.com
service apache2 reload
}}}

=== Configure WordPress ===

Now, browse to your new domain, and follow the normal WP configuration process, and you should be done.

=== Issues ===

Sadly at this point, there may be some issues with symlinking, and messing around generally with `WP_CONTENT_DIR`.

The main bug was being tracked at https://core.trac.wordpress.org/ticket/16953. Most issues should be fixed but some things may break, especially if plugin or theme authors don't do things right when determining correct filesystem and URI paths to use.

== See also ==
Line 93: Line 245:
 * [[LaMp|LAMP]]

== External links ==
 * [[https://wordpress.org/|Home Page]]
 * [[https://codex.wordpress.org/|WordPress Online Documentation]]
 * [[https://wordpress.org/support/article/updating-wordpress/#manual-update|WordPress Manual Update Guide]]

---------------------
CategoryNetwork CategorySoftware

Translation(s): none


WordPress is a free and open source (GNU GPLv2 or later) blogging tool and a content management system (CMS) based on PHP and MySQL. Features include a plug-in architecture and a template system.

WordPress versions for different Debian version (updated December 2021):

  • Debian 10 (Buster): 5.0.14
  • Debian 11 (Bullseye): 5.7.1
  • Debian 12 (Bookworm): 5.8.1

Packages Installation

Installation

apt update
apt install wordpress curl apache2 mariadb-server

Secure your MySQL installation with this command:

mysql_secure_installation

Basic Installation guide

Create a site

nano /etc/apache2/sites-available/wp.conf

Add this content, and replace example.com by your own domain:

<VirtualHost *:80>
        ServerName myblog.example.com

        ServerAdmin webmaster@example.com
        DocumentRoot /usr/share/wordpress

        Alias /wp-content /var/lib/wordpress/wp-content
        <Directory /usr/share/wordpress>
            Options FollowSymLinks
            AllowOverride Limit Options FileInfo
            DirectoryIndex index.php
            Require all granted
        </Directory>
        <Directory /var/lib/wordpress/wp-content>
            Options FollowSymLinks
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Disable default Virtual Host, and enable the site

a2dissite 000-default
a2ensite wp

Reload the webserver

service apache2 reload

Create /etc/wordpress/config-$DM.php. $DM is the domain name e.g. if the fully qualified domain name is myblog.example.com, create one of the following files:

  • /etc/wordpress/config-myblog.example.com.php (this is the default, use it if you are unsure)

  • /etc/wordpress/config-example.com.php (this is used for multisite with subdomains)

  • /etc/wordpress/config-default.php (this is used as a fallback if no other file matches your domain name)

WordPress searches in the above order and uses the first configuration file it can find. The domain name is taken from the HTTP-Request of your browser. That way you may be able to define different configuration files for different domains you are hosting.

nano /etc/wordpress/config-myblog.example.com.php

Add this content:

   1 <?php
   2 define('DB_NAME', 'wordpress');
   3 define('DB_USER', 'wordpress');
   4 define('DB_PASSWORD', 'password');
   5 define('DB_HOST', 'localhost');
   6 define('WP_CONTENT_DIR', '/var/lib/wordpress/wp-content');
   7 ?>

<!> replace password with a suitably secure password

Create a file to hold the database creation instructions

nano ~/wp.sql

Add this content: <!> replace password with your "suitably secure password"

   1 CREATE DATABASE wordpress;
   2 GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER
   3 ON wordpress.*
   4 TO wordpress@localhost
   5 IDENTIFIED BY 'password';
   6 FLUSH PRIVILEGES;

Create the database:

cat ~/wp.sql | mysql --defaults-extra-file=/etc/mysql/debian.cnf

Navigate to the wordpress directory in browser e.g. http://myblog.example.com/wp which redirects to http://myblog.example.com/wp/wp-admin/install.php where you'll see the "classic" wordpress 5 minute install page (actually a 5 second install thanks to the Debian packaging)

<!> replace myblog.example.com with your domain name (or localhost if running on the same box as your browser).

Upgrading the installed WordPress version

For keeping your WordPress up to date and receiving security fixes use Debian package manager:

apt update && apt upgrade

If you would like to use a more recent version of WordPress, consider using Backports or Debian testing.

An alternate installation method

I believe this method conforms more with how the maintainer recommends it should be done. Various sources are drawn upon using this method, and it is also affected by a few bugs as of this writing. It is basically centered around a "kind of" multi-site install, but I recommend this method even for a single blog, otherwise when you decide down the road to have more than one and share the packages' codebase, you'll have a fair bit of work on your hands.

The key useful script here is /usr/share/doc/wordpress/examples/setup-mysql. This gem does a few things:

  • Creates a WordPress config file under /etc/wordpress

  • Creates the WordPress database and user

  • Sets up a wp-content structure under /srv/www/wp-content/DOMAIN (this is key for a non-WordPress multi-site install, which is covered more below)

Run the helper script

Now run /usr/share/doc/wordpress/examples/setup-mysql, passing an argument of your site name; eg. myblog.com. You will most probably need other arguments too -- just try an initial -h to get help.

# Required package
apt install iputils-ping

# Unzip the file
gzip -d /usr/share/doc/wordpress/examples/setup-mysql.gz
# Set as executable
chmod +x /usr/share/doc/wordpress/examples/setup-mysql

# Run the setup, change myblog.example.com to your FQDN
/usr/share/doc/wordpress/examples/setup-mysql myblog.example.com

At this point, as per above, you should have a database created for you, and the /etc/wordpress/config-myblog.com.php config file. Peruse that and sanity check it.

Create the Apache site

Quoting /usr/share/doc/wordpress/examples/apache.conf:

There are several ways to setup Wordpress & Apache in Debian. However the maintainer's recommended way with the helper script setup-mysql uses:

## Virtual host VirtualDocumentRoot

        NameVirtualHost *:80

        <VirtualHost *:80>
        UseCanonicalName Off
        VirtualDocumentRoot /usr/share/wordpress
        Options All

        # wp-content in /srv/www/wp-content/$0
        RewriteEngine On
        RewriteRule ^/wp-content/(.*)$ /srv/www/wp-content/%{HTTP_HOST}/$1
        </VirtualHost>

For this configuration to work you'll also need to have mod_rewrite and mod_vhost_alias loaded and working in Apache. To enable these modules run

a2enmod rewrite
a2enmod vhost_alias
service apache2 restart

Place this config into something like /etc/apache2/sites-available/myblog.com and modify according to your needs (IP-based virtual host, name-based, logging, etc.)

If you're using any Wordpress functionality that requires URL rewriting (such as permalinks), then you will also need something like this in your Apache config:

    RewriteRule ^index\.php$ - [L]
    RewriteCond /usr/share/wordpress%{REQUEST_URI} !-f
    RewriteCond /usr/share/wordpress%{REQUEST_URI} !-d
    RewriteRule . /usr/share/wordpress/index.php [L]
    # Also needed if using PHP-FPM / Fast-CGI
    RewriteCond %{REQUEST_URI} !^/php5-fcgi/*

The above rewrite conditions rely on Apache finding the required files in /usr/share/wordpress for non-permalinks (such as wp-admin). This may require the following line to ensure it finds the index file when requesting /wp-admin/

    DirectoryIndex index.php

Final reading before actual configuration

Now would be a great time to read /usr/share/doc/wordpress/README.Debian if you haven't already. All the rest of the pieces should fall into place once you do.

Amongst other things, it explains the great way that the Debian WordPress package utilises the WordPress wp-config.php framework, and more importantly, how to handle the infamous "themes" and "plugins" directories in a WordPress install. The key point is that by symlinking under /var/lib/wordpress, users better abide by the FilesystemHierarchyStandard, and can use the in-app upgrade mechanisms of WordPress to upgrade plugins and themes, without clobbering the package, and risking server security.

It also discusses the two choices regarding multi-site installs, of which this here describes the non-WordPress version.

Enable the Apache site

Now we enable the Apache site config made earlier using a2ensite, which basically just creates a symlink in /etc/apache2/sites-enabled from sites-available, then reload Apache:

a2ensite myblog.com
service apache2 reload

Configure WordPress

Now, browse to your new domain, and follow the normal WP configuration process, and you should be done.

Issues

Sadly at this point, there may be some issues with symlinking, and messing around generally with WP_CONTENT_DIR.

The main bug was being tracked at https://core.trac.wordpress.org/ticket/16953. Most issues should be fixed but some things may break, especially if plugin or theme authors don't do things right when determining correct filesystem and URI paths to use.

See also

  • Sample configurations can be found in /usr/share/doc/wordpress/examples/

  • Debian specific instructions are /usr/share/doc/wordpress/README.Debian

  • LAMP


CategoryNetwork CategorySoftware