Wordpress: Difference between revisions

From ArchWiki
(go on)
m (→‎Plugins are unable to install: Could not create directory: - chown needs to be run as root usually)
 
(50 intermediate revisions by 22 users not shown)
Line 1: Line 1:
[[Category:Web server]]
[[Category:Content management systems]]
[[ja:Wordpress]]
[[ja:Wordpress]]
[[zh-hans:Wordpress]]
[[zh-hans:Wordpress]]
Line 5: Line 5:
{{Related|Apache HTTP Server}}
{{Related|Apache HTTP Server}}
{{Related|PHP}}
{{Related|PHP}}
{{Related|MySQL}}
{{Related|MariaDB}}
{{Related|phpMyAdmin}}
{{Related|phpMyAdmin}}
{{Related articles end}}
{{Related articles end}}


[http://wordpress.org WordPress] is a free and open source content management system ([[Wikipedia:Content management system|CMS]]) created by [[Wikipedia:Matt Mullenweg|Matt Mullenweg]] and first released in 2003. WordPress has a vast and vibrant community that provides tens of thousands of free plugins and themes to allow the user to easily customize the appearance and function of their WordPress CMS. WordPress is licensed under the GPLv2.
[https://wordpress.org WordPress] is a free and open source content management system ([[Wikipedia:Content management system|CMS]]) created by [[Wikipedia:Matt Mullenweg|Matt Mullenweg]] and first released in 2003. WordPress has a vast and vibrant community that provides tens of thousands of free plugins and themes to allow the user to easily customize the appearance and function of their WordPress CMS. WordPress is licensed under the GPLv2.


The biggest feature of WordPress is its ease in configuration and administration. [http://codex.wordpress.org/Installing_WordPress Setting up a WordPress site takes five minutes]. The WordPress administration panel allows users to easily configure almost every aspect of their website including fetching and installing plugins and themes. WordPress provides effortless automatic updates.
The biggest feature of WordPress is its ease in configuration and administration. [https://wordpress.org/support/article/how-to-install-wordpress/ Setting up a WordPress site takes five minutes]. The WordPress administration panel allows users to easily configure almost every aspect of their website including fetching and installing plugins and themes. WordPress provides effortless automatic updates.


== Installation ==
== Installation ==


WordPress requires [[PHP]] and [[MySQL]] to be installed and configured. See the [[LAMP]] wiki article for more information. During configuration, be aware that some WordPress features require [http://wordpress.stackexchange.com/questions/42098/what-are-php-extensions-and-libraries-wp-needs-and-or-uses PHP extensions] that may not be turned on by default.
WordPress requires [[Apache HTTP Server]], [[PHP]] and [[MariaDB]] to be installed and configured. See the respective pages for information. During PHP configuration, be aware that some WordPress features require [https://wordpress.stackexchange.com/questions/42098/what-are-php-extensions-and-libraries-wp-needs-and-or-uses PHP extensions] that may not be turned on by default.


=== Installation using pacman ===
=== Installation using pacman ===
Line 21: Line 21:
[[Install]] the {{pkg|wordpress}} package.
[[Install]] the {{pkg|wordpress}} package.


{{warning|While it is easier to let pacman manage updating your WordPress install, this is not necessary. WordPress has functionality built-in for managing updates, themes, and plugins. If you decide to install the official community package, you will not be able to install plugins and themes using the WordPress admin panel without a needlessly complex permissions setup, or logging into FTP as root. pacman does not delete the WordPress install directory when uninstalling it from your system regardless of whether or not you have added data to the directory manually or otherwise.}}
{{warning|While it is easier to let pacman manage updating your WordPress install, this is not necessary. WordPress has functionality built-in for managing updates, themes, and plugins. If you decide to install the official package, you will not be able to install plugins and themes using the WordPress admin panel without a needlessly complex permissions setup, or logging into FTP as root. pacman does not delete the WordPress install directory when uninstalling it from your system regardless of whether or not you have added data to the directory manually or otherwise.}}


=== Manual install ===
=== Manual install ===


Go to [http://wordpress.org/download/ wordpress.org] and download the latest version of WordPress and extract it to your webserver directory. Give the directory enough permissions to allow your FTP user to write to the directory (used by WordPress).
Go to [https://wordpress.org/download/ wordpress.org] and download the latest version of WordPress and extract it to your webserver directory. Give the directory enough permissions to allow your FTP user to write to the directory (used by WordPress).


  cd /srv/http/''whatever''
  $ cd /srv/http/''whatever''
  wget <nowiki>https://wordpress.org/latest.tar.gz</nowiki>
  $ wget <nowiki>https://wordpress.org/latest.tar.gz</nowiki>
  tar xvzf latest.tar.gz
  $ tar xvzf latest.tar.gz


== Configuration ==
== Configuration ==
Line 45: Line 45:
{{note|You will need to use a proxy server to access your WordPress installation from mobile devices if you plan on using hostnames to install WordPress, otherwise your website will appear broken [[#Appearance is broken (no styling)]].}}
{{note|You will need to use a proxy server to access your WordPress installation from mobile devices if you plan on using hostnames to install WordPress, otherwise your website will appear broken [[#Appearance is broken (no styling)]].}}


=== Configure apache ===
=== Configure Apache ===


{{note|You will need [[Apache]] configured to run with [[PHP]] and [[MySQL]]. Check [[LAMP#PHP]] and [[LAMP#MySQL.2FMariaDB|LAMP#MySQL/MariaDB]] sections for instructions.}}
{{note|You will need [[Apache HTTP Server]] configured to run with [[PHP]] and [[MariaDB]], as well as have the {{ic|mod_rewrite}} module enabled by uncommenting {{ic|LoadModule rewrite_module modules/mod_rewrite.so}} in {{ic|/etc/httpd/conf/httpd.conf}}.}}


You will need to create a config file for apache to find your WordPress install. Create the following file and edit it your favorite text editor:
You will need to create a configuration file for Apache to find your WordPress install. Create the following file and edit it your favorite text editor:


{{hc|# /etc/httpd/conf/extra/httpd-wordpress.conf|
{{hc|# /etc/httpd/conf/extra/httpd-wordpress.conf|
Line 71: Line 71:
</Directory>}}
</Directory>}}


Next edit the [[Apache]] configuration file and add the following:
Next edit the [[Apache HTTP Server]] configuration file and add the following:


{{hc|# /etc/httpd/conf/httpd.conf|
{{hc|# /etc/httpd/conf/httpd.conf|
Line 77: Line 77:
}}
}}


Now restart {{ic|httpd.service}} (Apache) using [[systemd#Using units|systemd]].
Since the WordPress index is written in PHP add the following line within the {{ic|<IfModule dir_module>}} block:


=== Configure MySQL ===
{{hc|# /etc/httpd/conf/httpd.conf|
<IfModule dir_module>
    DirectoryIndex index.php
</IfModule>
}}
 
Now [[restart]] {{ic|httpd.service}} (Apache).
 
=== Configure Nginx ===
 
{{note|You will need [[nginx]] configured to run with [[PHP]] and [[MariaDB]].}}
 
Example server block configuration from https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/:


MySQL can be configured using a plethora of tools, but the most common are the command-line or [http://www.phpmyadmin.net/home_page/index.php phpMyAdmin].
# Upstream to abstract backend connection(s) for php
upstream php {
        server unix:/tmp/php-cgi.socket;
        server 127.0.0.1:9000;
}
server {
        ## Your website name goes here.
        server_name domain.tld;
        ## Your only path reference.
        root /var/www/wordpress;
        ## This should be in your http block and if it is, it's not needed here.
        index index.php;
        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }
        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
        location / {
                # This is cool because no php is touched for static content.
                # include the "?$args" part so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php?$args;
        }
        location ~ \.php$ {
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi_params;
                fastcgi_intercept_errors on;
                fastcgi_pass php;
                #The following parameter can be also included in fastcgi_params file
                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
}


{{Tip|Make sure MariaDB is installed and configured correctly. At a minimum, follow the [[MySQL#Installation|installation instructions]] for Arch Linux.}}
=== Configure MariaDB ===
 
MariaDB can be configured using a plethora of tools, but the most common are the command-line or [https://www.phpmyadmin.net/home_page/index.php phpMyAdmin].
 
{{Tip|Make sure [[MariaDB]] is installed and configured correctly. At a minimum, follow the [[MariaDB#Installation|installation instructions]] for Arch Linux.}}


==== Using MariaDB command-line tool ====
==== Using MariaDB command-line tool ====
Line 99: Line 159:
MariaDB> EXIT}}
MariaDB> EXIT}}


See WordPress.org [https://codex.wordpress.org/Installing_WordPress#Using_the_MySQL_Client official instructions] for details.
See WordPress.org [https://wordpress.org/support/article/how-to-install-wordpress/#step-2-create-the-database-and-a-user] for details.


==== Using phpMyAdmin ====
==== Using phpMyAdmin ====
Line 114: Line 174:
# Click the "Add user" button to create the user.
# Click the "Add user" button to create the user.


== WordPress Installation ==
== WordPress installation ==


Once you have spent a couple of hours setting up your http server, php, and mysql, it is finally time to let WordPress have its five minutes and install itself. So let us begin.
Once you have set up your http server, php, and mariadb, it is time to install and configure WordPress itself.


The WordPress installation procedure will use the URL in the address field of your web browser as the default website URL. If you have navigated to http://localhost/wordpress, your website will be accessible from your local network, but it will be broken in appearance and function.
The WordPress installation procedure will use the URL in the address field of your web browser as the default website URL. If you have navigated to http://localhost/wordpress, your website will be accessible from your local network, but it will be broken in appearance and function.
Line 126: Line 186:
# Click "Submit".
# Click "Submit".


If you installed WordPress from the Official repository, then this setup procedure will not have the correct permissions to create the wp-config.php file used by WordPress. You will have to do this step yourself as root using information WordPress will provide.
If you installed {{Pkg|wordpress}}, then this setup procedure will not have the correct permissions to create the {{ic|wp-config.php}} file used by WordPress. You will have to do this step yourself as root using information WordPress will provide.


A page will appear saying WordPress can not write the wp-config.php file. Copy the text in the edit box and open {{ic|/usr/share/webapps/wordpress/wp-config.php}} as root in your text editor. Paste the copied text into the editor and save the file.
A page will appear saying WordPress can not write the {{ic|wp-config.php}} file. Copy the text in the edit box and open {{ic|/usr/share/webapps/wordpress/wp-config.php}} as {{ic|root}} in your text editor. Paste the copied text into the editor and save the file.


After that, you will have to change permissions of the /usr/share/webapps/wordpress/ and all the files inside it to user {{ic|http}} and group {{ic|http}} by using chown so that the webserver can access it.
After that, you will have to change permissions of the {{ic|/usr/share/webapps/wordpress/}} and all the files inside it to user {{ic|http}} and group {{ic|http}} by using chown so that the webserver can access it:
 
# chown http:http -R /usr/share/webapps/wordpress/


Finally, Click "Run the install" and WordPress will populate the database with your information. Once complete, you will be shown "Success!" page. Click the login button to finish your installation.
Finally, Click "Run the install" and WordPress will populate the database with your information. Once complete, you will be shown "Success!" page. Click the login button to finish your installation.
Line 145: Line 207:


* [https://wordpress.org/themes/ Official WordPress theme website]
* [https://wordpress.org/themes/ Official WordPress theme website]
* [http://www.smashingmagazine.com/ Smashing Magazine]
* [https://www.smashingmagazine.com/ Smashing Magazine]
* [http://thethemefoundry.com/ The Theme Factory]
* [https://thethemefoundry.com/ The Theme Factory]
* [http://www.woothemes.com/ Woo Themes]
* [https://www.woothemes.com/ Woo Themes]


{{Tip|One can use WordPress' admin interface to install plugins and themes. To do this, make the user that serves WordPress the [[File_permissions_and_attributes#Changing_permissions|owner]] of your WordPress directory. For [[Apache_HTTP_Server#Advanced_options|Apache]] this user is normally http.}}
{{Tip|One can use WordPress' admin interface to install plugins and themes. To do this, make the user that serves WordPress the [[File permissions and attributes#Changing permissions|owner]] of your WordPress directory. For [[Apache HTTP Server#Advanced options|Apache]] this user is normally http.}}


==== Install using the admin panel ====
==== Install using the admin panel ====


Before installing a theme using the admin panel, you will need to setup an [[Very_Secure_FTP_Daemon|FTP]] server on your WordPress host. To maintain a high level of protection, you might set up a [[user]] on your system specifically for WordPress, give it the home directory of {{ic|<path to your WordPress install>/wp-content}}, disallow anonymous login, and allow no more users to log in than for WordPress (and obviously others as required by your setup).
Before installing a theme using the admin panel, you will need to setup an [[Very Secure FTP Daemon|FTP]] server on your WordPress host. To maintain a high level of protection, you might set up a [[user]] on your system specifically for WordPress, give it the home directory of {{ic|<path to your WordPress install>/wp-content}}, disallow anonymous login, and allow no more users to log in than for WordPress (and obviously others as required by your setup).


Once the FTP server is setup, login to your WordPress installation and click <nowiki>"Appearance->Install Themes->Upload"</nowiki>. From there select your zip file that contains your theme and click "Install Now". You will be presented with a box asking for FTP information, enter it and click "Proceed".  You might need to update [[chown|file ownership]] and [[chmod|rights]] if WordPress reports that it is unable to write to the directory. If you have been following along closely, you should now have an installed theme. Activate it if you wish.
Once the FTP server is setup, login to your WordPress installation and click <nowiki>"Appearance->Install Themes->Upload"</nowiki>. From there select your zip file that contains your theme and click "Install Now". You will be presented with a box asking for FTP information, enter it and click "Proceed".  You might need to update [[chown|file ownership]] and [[chmod|rights]] if WordPress reports that it is unable to write to the directory. If you have been following along closely, you should now have an installed theme. Activate it if you wish.
Line 159: Line 221:
==== Install manually ====
==== Install manually ====


Download the archive and extract into the '''wp-content/themes''' folder
Download the archive and extract into the {{ic|wp-content/themes}} folder:


  # Example for a theme named "MyTheme"
  $ cd ''/path/to/wordpress/root/directory''
cd /path/to/wordpress/root/directory
  $ cd wp-content/themes
  cd wp-content/themes


# get the theme archive and extract
Get the theme archive and extract:
wget <nowiki>http://www.example.com/MyTheme.zip</nowiki>
unzip MyTheme.zip


  # remove the archive (optional)
  $ wget ''<nowiki>http://www.example.com/MyTheme</nowiki>''.zip
  rm MyTheme.zip
$ unzip ''MyTheme''.zip
 
Remove the archive (optional):
 
  $ rm ''MyTheme''.zip


Be sure to follow any additional instructions as provided by the theme author.
Be sure to follow any additional instructions as provided by the theme author.


Select your new theme from the theme chooser (<nowiki>"Appearance->Themes"</nowiki>)
Select your new theme from the theme chooser (''Appearance > Themes'').


=== Installing a plugin ===
=== Installing a plugin ===
Line 194: Line 257:
This occurs because you used a url with the hostname of your server, instead of an ip address, when doing the initial setup and WordPress has used this as the default website URL.
This occurs because you used a url with the hostname of your server, instead of an ip address, when doing the initial setup and WordPress has used this as the default website URL.


To fix this, you will either need to edit your /etc/hosts file or setup a proxy server. For an easy to setup proxy server, see [[Polipo]], or if you want something with a little more configuration, see [[Squid]].
To fix this, you will either need to edit your /etc/hosts file or setup a proxy server. See [[Squid]].


Another option is changing a value in the database table of your WordPress, specifically the wp_options table. The fix is to change the siteurl option to point directly to the domain name and not "localhost".
Another option is changing a value in the database table of your WordPress, specifically the wp_options table. The fix is to change the siteurl option to point directly to the domain name and not "localhost".
=== Plugins are unable to install: Could not create directory ===
Your WordPress site need appropriate permissions to your local files. It does not have the permissions to create files/directory. Apache with Arch uses the user `http`.
To give the appropriate permissions run the following command:
# chown -R http:http your-wordpress-directory/wp-content
In addition, if you use an nginx setup with php-fpm (as of version 7.4), you need to override the php-fpm systemd unit file, as php-fpm is hardened, making /usr read-only. [[Edit]] {{ic|php-fpm.service}} and add the following lines to the file:
{{hc|1=override.conf|2=
[Service]
ReadWritePaths=/usr/share/webapps/wordpress
}}
=== Cannot save plugins to localhost ===
WordPress uses by default only a ftp server to download plugins. In order to also download them locally append the following config:
{{hc|# ''wordpress_root_location''/wp-config.php|
define('FS_METHOD', 'direct');
}}
=== There has been an error cropping your image. ===
Wordpress needs `php-gd` to modify images. [[Install]] {{pkg|php-gd}}, then enable the extension by uncommenting the following line in {{ic|/etc/php/php.ini}}:
extension=gd
=== Call to undefined function mysql_connect() ===
You can usually see this error if you are using mysql/mariadb with php>=7.0.0 and have debug enabled in wordpress config.
This issue can be solved by uncommenting the following line in {{ic|/etc/php/php.ini}}:
  extension=mysqli
 
=== 502 Gateway Error after starting nginx ===
This can be caused due to the php upstream defined as {{ic|server 127.0.0.1:9000;}} in the nginx configuration file not being installed and configured.
[[Install]] the {{pkg|php-fpm}} package. Open the following file and go to the line:
{{hc|# /etc/php/php-fpm.d/www.conf|<nowiki>
listen = /run/php-fpm/php-fpm.sock
</nowiki>}}
Change it to:
{{hc|# /etc/php/php-fpm.d/www.conf|<nowiki>
listen = '127.0.0.1:9000'
</nowiki>}}
[[Enable]] and [[Restart]] {{pkg|php-fpm}}.
[[Restart]] {{pkg|nginx}}.


== Tips and tricks ==
== Tips and tricks ==
=== WP-CLI ===
[https://wp-cli.org/ WP-CLI] is the command-line interface for WordPress. You can update plugins, configure multisite installations and much more, without using a web browser.


== See also ==
== See also ==
* [[Wikipedia:WordPress|WordPress]]
* [[Wikipedia:WordPress|WordPress]]
* [[Wikipedia:Content management system|Content management system]]
* [[Wikipedia:Content management system|Content management system]]

Latest revision as of 17:53, 16 November 2023

WordPress is a free and open source content management system (CMS) created by Matt Mullenweg and first released in 2003. WordPress has a vast and vibrant community that provides tens of thousands of free plugins and themes to allow the user to easily customize the appearance and function of their WordPress CMS. WordPress is licensed under the GPLv2.

The biggest feature of WordPress is its ease in configuration and administration. Setting up a WordPress site takes five minutes. The WordPress administration panel allows users to easily configure almost every aspect of their website including fetching and installing plugins and themes. WordPress provides effortless automatic updates.

Installation

WordPress requires Apache HTTP Server, PHP and MariaDB to be installed and configured. See the respective pages for information. During PHP configuration, be aware that some WordPress features require PHP extensions that may not be turned on by default.

Installation using pacman

Install the wordpress package.

Warning: While it is easier to let pacman manage updating your WordPress install, this is not necessary. WordPress has functionality built-in for managing updates, themes, and plugins. If you decide to install the official package, you will not be able to install plugins and themes using the WordPress admin panel without a needlessly complex permissions setup, or logging into FTP as root. pacman does not delete the WordPress install directory when uninstalling it from your system regardless of whether or not you have added data to the directory manually or otherwise.

Manual install

Go to wordpress.org and download the latest version of WordPress and extract it to your webserver directory. Give the directory enough permissions to allow your FTP user to write to the directory (used by WordPress).

$ cd /srv/http/whatever
$ wget https://wordpress.org/latest.tar.gz
$ tar xvzf latest.tar.gz

Configuration

The configuration method used here assumes you are using WordPress on a local network.

Host config

Make sure your /etc/hosts file is setup correctly. This will be important when accessing your WordPress CMS from a local network. Your /etc/hosts file should look something like the following,

#<ip-address>   <hostname.domain.org>   <hostname>
127.0.0.1       lithium.kaboodle.net    localhost lithium
::1             lithium.kaboodle.net    localhost lithium
Note: You will need to use a proxy server to access your WordPress installation from mobile devices if you plan on using hostnames to install WordPress, otherwise your website will appear broken #Appearance is broken (no styling).

Configure Apache

Note: You will need Apache HTTP Server configured to run with PHP and MariaDB, as well as have the mod_rewrite module enabled by uncommenting LoadModule rewrite_module modules/mod_rewrite.so in /etc/httpd/conf/httpd.conf.

You will need to create a configuration file for Apache to find your WordPress install. Create the following file and edit it your favorite text editor:

# /etc/httpd/conf/extra/httpd-wordpress.conf
Alias /wordpress "/usr/share/webapps/wordpress"
<Directory "/usr/share/webapps/wordpress">
	AllowOverride All
	Options FollowSymlinks
	Require all granted
</Directory>

Change /wordpress in the first line to whatever you want. For example, /myblog would require that you navigate to http://hostname/myblog to see your WordPress website.

Also change the paths to your WordPress install folder in case you did a manual install. Do not forget to append the parent directory to the php_admin_value variable as well as shown below.

# /etc/httpd/conf/extra/httpd-wordpress.conf
Alias /myblog "/mnt/data/srv/wordpress"
<Directory "/mnt/data/srv/wordpress">
	AllowOverride All
	Options FollowSymlinks
	Require all granted
</Directory>

Next edit the Apache HTTP Server configuration file and add the following:

# /etc/httpd/conf/httpd.conf
Include conf/extra/httpd-wordpress.conf

Since the WordPress index is written in PHP add the following line within the <IfModule dir_module> block:

# /etc/httpd/conf/httpd.conf
<IfModule dir_module>
    DirectoryIndex index.php
</IfModule>

Now restart httpd.service (Apache).

Configure Nginx

Note: You will need nginx configured to run with PHP and MariaDB.

Example server block configuration from https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/:

# Upstream to abstract backend connection(s) for php
upstream php {
       server unix:/tmp/php-cgi.socket;
       server 127.0.0.1:9000;
}

server {
       ## Your website name goes here.
       server_name domain.tld;
       ## Your only path reference.
       root /var/www/wordpress;
       ## This should be in your http block and if it is, it's not needed here.
       index index.php;

       location = /favicon.ico {
               log_not_found off;
               access_log off;
       }

       location = /robots.txt {
               allow all;
               log_not_found off;
               access_log off;
       }

       location / {
               # This is cool because no php is touched for static content.
               # include the "?$args" part so non-default permalinks doesn't break when using query string
               try_files $uri $uri/ /index.php?$args;
       }

       location ~ \.php$ {
               #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
               include fastcgi_params;
               fastcgi_intercept_errors on;
               fastcgi_pass php;
               #The following parameter can be also included in fastcgi_params file
               fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
       }

       location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
               expires max;
               log_not_found off;
       }
}

Configure MariaDB

MariaDB can be configured using a plethora of tools, but the most common are the command-line or phpMyAdmin.

Tip: Make sure MariaDB is installed and configured correctly. At a minimum, follow the installation instructions for Arch Linux.

Using MariaDB command-line tool

First, login as root. You will be asked for your MariaDB root password:

$ mysql -u root -p

Then create a user and database:

Note: wordpress is your Database Name and wp-user is your User Name. You can change them if you wish. Also replace choose_db_password with your new Password for this database. You will be asked for these values along with localhost in the next section.
MariaDB> CREATE DATABASE wordpress;
MariaDB> GRANT ALL PRIVILEGES ON wordpress.* TO "wp-user"@"localhost" IDENTIFIED BY "choose_db_password";
MariaDB> FLUSH PRIVILEGES;
MariaDB> EXIT

See WordPress.org [1] for details.

Using phpMyAdmin

See phpMyAdmin to install and configure phpMyAdmin.

In your web browser, navigate to your phpMyAdmin host and perform the following steps:

  1. Login to phpMyAdmin.
  2. Click "user" and then click "Add user".
  3. Give the pop up window a name and a password.
  4. Select "Create database with same name and grant all privileges".
  5. Click the "Add user" button to create the user.

WordPress installation

Once you have set up your http server, php, and mariadb, it is time to install and configure WordPress itself.

The WordPress installation procedure will use the URL in the address field of your web browser as the default website URL. If you have navigated to http://localhost/wordpress, your website will be accessible from your local network, but it will be broken in appearance and function.

  1. Navigate to http://hostname/wordpress.
  2. Click the "Create a Configuration File" button.
  3. Click the "Let's go!" button.
  4. Fill in you database information created in the previous section
  5. Click "Submit".

If you installed wordpress, then this setup procedure will not have the correct permissions to create the wp-config.php file used by WordPress. You will have to do this step yourself as root using information WordPress will provide.

A page will appear saying WordPress can not write the wp-config.php file. Copy the text in the edit box and open /usr/share/webapps/wordpress/wp-config.php as root in your text editor. Paste the copied text into the editor and save the file.

After that, you will have to change permissions of the /usr/share/webapps/wordpress/ and all the files inside it to user http and group http by using chown so that the webserver can access it:

# chown http:http -R /usr/share/webapps/wordpress/

Finally, Click "Run the install" and WordPress will populate the database with your information. Once complete, you will be shown "Success!" page. Click the login button to finish your installation.

Now would be a good time to access your website from all your devices to be sure your WordPress installation is setup correctly.

Usage

Installing a theme

Finding new themes

There are tens of thousands of themes available for WordPress. Searching on google for a good theme can be like wading through a river filled with trash. Good places for looking for themes include:

Tip: One can use WordPress' admin interface to install plugins and themes. To do this, make the user that serves WordPress the owner of your WordPress directory. For Apache this user is normally http.

Install using the admin panel

Before installing a theme using the admin panel, you will need to setup an FTP server on your WordPress host. To maintain a high level of protection, you might set up a user on your system specifically for WordPress, give it the home directory of <path to your WordPress install>/wp-content, disallow anonymous login, and allow no more users to log in than for WordPress (and obviously others as required by your setup).

Once the FTP server is setup, login to your WordPress installation and click "Appearance->Install Themes->Upload". From there select your zip file that contains your theme and click "Install Now". You will be presented with a box asking for FTP information, enter it and click "Proceed". You might need to update file ownership and rights if WordPress reports that it is unable to write to the directory. If you have been following along closely, you should now have an installed theme. Activate it if you wish.

Install manually

Download the archive and extract into the wp-content/themes folder:

$ cd /path/to/wordpress/root/directory
$ cd wp-content/themes

Get the theme archive and extract:

$ wget http://www.example.com/MyTheme.zip
$ unzip MyTheme.zip

Remove the archive (optional):

$ rm MyTheme.zip

Be sure to follow any additional instructions as provided by the theme author.

Select your new theme from the theme chooser (Appearance > Themes).

Installing a plugin

The steps for installing a plugin are the same as they are for installing a theme. Just click the "Plugins" link in the left navigation bar and follow the steps.

Updating

Every now and then when you log into wordpress there will be a notification informing you of updates. If you have correctly installed and configured an FTP client, and have the correct filesystem permissions to write in the WordPress install path then you should be able to perform updates at the click of a button. Just follow the steps.

Alternatively, you can use SSH to update your installation with the SSH SFTP Updater Support plugin.

Troubleshooting

Appearance is broken (no styling)

Your WordPress website will appear to have no styling to it when viewing it in a web browser (desktop or mobile) that does not have its hostnames mapped to ip addresses correctly.

This occurs because you used a url with the hostname of your server, instead of an ip address, when doing the initial setup and WordPress has used this as the default website URL.

To fix this, you will either need to edit your /etc/hosts file or setup a proxy server. See Squid.

Another option is changing a value in the database table of your WordPress, specifically the wp_options table. The fix is to change the siteurl option to point directly to the domain name and not "localhost".

Plugins are unable to install: Could not create directory

Your WordPress site need appropriate permissions to your local files. It does not have the permissions to create files/directory. Apache with Arch uses the user `http`.

To give the appropriate permissions run the following command:

# chown -R http:http your-wordpress-directory/wp-content

In addition, if you use an nginx setup with php-fpm (as of version 7.4), you need to override the php-fpm systemd unit file, as php-fpm is hardened, making /usr read-only. Edit php-fpm.service and add the following lines to the file:

override.conf
[Service]
ReadWritePaths=/usr/share/webapps/wordpress

Cannot save plugins to localhost

WordPress uses by default only a ftp server to download plugins. In order to also download them locally append the following config:

# wordpress_root_location/wp-config.php
define('FS_METHOD', 'direct');

There has been an error cropping your image.

Wordpress needs `php-gd` to modify images. Install php-gd, then enable the extension by uncommenting the following line in /etc/php/php.ini:

extension=gd

Call to undefined function mysql_connect()

You can usually see this error if you are using mysql/mariadb with php>=7.0.0 and have debug enabled in wordpress config.

This issue can be solved by uncommenting the following line in /etc/php/php.ini:

 extension=mysqli
 

502 Gateway Error after starting nginx

This can be caused due to the php upstream defined as server 127.0.0.1:9000; in the nginx configuration file not being installed and configured.

Install the php-fpm package. Open the following file and go to the line:

# /etc/php/php-fpm.d/www.conf
listen = /run/php-fpm/php-fpm.sock

Change it to:

# /etc/php/php-fpm.d/www.conf
listen = '127.0.0.1:9000'

Enable and Restart php-fpm.

Restart nginx.

Tips and tricks

WP-CLI

WP-CLI is the command-line interface for WordPress. You can update plugins, configure multisite installations and much more, without using a web browser.

See also