{"id":41,"date":"2023-12-24T08:04:44","date_gmt":"2023-12-24T08:04:44","guid":{"rendered":"http:\/\/192.168.40.2\/?p=41"},"modified":"2025-07-24T08:50:44","modified_gmt":"2025-07-24T08:50:44","slug":"install-wordpress-on-ubuntu-with-apache2-mariadb-and-php","status":"publish","type":"post","link":"https:\/\/allogman.com\/?p=41","title":{"rendered":"Install WordPress on Ubuntu with Apache2, MariaDB and PHP"},"content":{"rendered":"\n<p>This article shows how to install&nbsp;<code>WordPress<\/code>&nbsp;on Ubuntu with&nbsp;<code>Apache2, MariaDB and PHP<\/code>&nbsp;support.<\/p>\n\n\n\n<p>This setup will probably be how all WordPress sites will be configured going forward, for more ways to install WordPress check the&nbsp;<a href=\"https:\/\/wordpress.org\/support\/article\/how-to-install-wordpress\/\">documentation website<\/a>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-apache2-http-server-on-ubuntu\">Install Apache2 HTTP Server on Ubuntu<\/h4>\n\n\n\n<p>To install&nbsp;<code>Apache2<\/code>&nbsp;HTTP on Ubuntu server, run the following commands:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Update packages:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo apt update\n<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Install Apache2:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo apt install apache2\n<\/code><\/pre>\n\n\n\n<p>Now, we will use the commands below to stop, start and enable&nbsp;<code>Apache2<\/code>.<\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Start and enable Apache2 service:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl stop apache2.service\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl start apache2.service\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl enable apache2.service\n<\/code><\/pre>\n\n\n\n<p>To test&nbsp;<code>Apache2<\/code>&nbsp;setup, open your browser and write the&nbsp;<code>server hostname or IP address<\/code>, and you should see&nbsp;<code>Apache2<\/code>&nbsp;default test page as shown below. By getting this, we know&nbsp;<code>Apache2<\/code>&nbsp;is working as expected.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/192.168.40.2\/wp-content\/uploads\/2025\/07\/apache2-default-page.png\"><img decoding=\"async\" src=\"http:\/\/192.168.40.2\/wp-content\/uploads\/2025\/07\/apache2-default-page.png\" alt=\"Apache2 Default Page\" title=\"Apache2 Default Page\"\/><\/a><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-mariadb-database-server\">Install MariaDB Database Server<\/h4>\n\n\n\n<p>MariaDB database server is a very good place to start when looking at open source database server to use with WordPress. To install MariaDB run this command:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Install MariaDB:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo apt-get install mariadb-server mariadb-client\n<\/code><\/pre>\n\n\n\n<p>Next, run the following commands which are used stop, start and enable&nbsp;<code>MariaDB<\/code>&nbsp;service to always start up when the server boots.<\/p>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Start and enable Apache2 service:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl stop mysql.service\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl start mysql.service\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl enable mysql.service\n<\/code><\/pre>\n\n\n\n<p>After that, by running the coming command,&nbsp;<code>MariaDB<\/code>&nbsp;server will be secured, by creating a root password and disallowing remote root access.<\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Run MariaDB configuration script:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo mysql_secure_installation\n<\/code><\/pre>\n\n\n\n<p>Now, answer the following questions as below:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Enter current password for root (enter for none):\u00a0<code>Just press the Enter<\/code><\/li>\n\n\n\n<li>Set root password? [Y\/n]:\u00a0<code>Y<\/code><\/li>\n\n\n\n<li>New password:\u00a0<code>Enter password<\/code><\/li>\n\n\n\n<li>Re-enter new password:\u00a0<code>Repeat password<\/code><\/li>\n\n\n\n<li>Remove anonymous users? [Y\/n]:\u00a0<code>Y<\/code><\/li>\n\n\n\n<li>Disallow root login remotely? [Y\/n]:\u00a0<code>Y<\/code><\/li>\n\n\n\n<li>Remove test database and access to it? [Y\/n]:\u00a0<code>Y<\/code><\/li>\n\n\n\n<li>Reload privilege tables now? [Y\/n]:\u00a0<code>Y<\/code><\/li>\n<\/ul>\n\n\n\n<p>Now, you can login to&nbsp;<code>MariaDB<\/code>&nbsp;by running this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo mysql -u root -p\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"configure-database\">Configure Database<\/h6>\n\n\n\n<p>To configure WordPress, we need to create&nbsp;<code>MariaDB<\/code>&nbsp;database. Let\u2019s do it!<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Access MariaDB commands:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo mysql -u root -p\n<\/code><\/pre>\n\n\n\n<p>The output will look similar to this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Welcome to the MariaDB monitor.  Commands end with ; or \\g.\nYour MariaDB connection id is 81\nServer version: 10.0.38-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nMariaDB &#91;(none)]&gt;\n<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Create database:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>MariaDB&gt; CREATE DATABASE wordpress;\n<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Grant access:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>MariaDB&gt; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER\n    -&gt; ON wordpress.*\n    -&gt; TO wordpress@localhost\n    -&gt; IDENTIFIED BY '&lt;your-password&gt;';\n<\/code><\/pre>\n\n\n\n<p>Do not forget to replace&nbsp;<code>&lt;your-password&gt;<\/code>&nbsp;with your password.<\/p>\n\n\n\n<p>In order to apply the changes above without reloading or restarting mysql service we need to flush the table:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>MariaDB&gt; FLUSH PRIVILEGES;\n<\/code><\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>Exit MariaDB commands:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>MariaDB&gt; EXIT;\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-php\">Install PHP<\/h4>\n\n\n\n<p>To install&nbsp;<code>PHP<\/code>&nbsp;use following commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo apt update\n$ sudo apt install php libapache2-mod-php php-mysql\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-wordpress\">Install WordPress<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Download and extract the latest version of WordPress:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/tmp &amp;&amp; wget https:\/\/wordpress.org\/latest.tar.gz\n<\/code><\/pre>\n\n\n\n<p>Then extract the package using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ tar -xzvf latest.tar.gz\n<\/code><\/pre>\n\n\n\n<p>This command will produce a folder called&nbsp;<code>wordpress<\/code>, copy this file to&nbsp;<code>\/var\/www\/html\/<\/code>&nbsp;by the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo cp -R wordpress \/var\/www\/html\/\n<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Exit\u00a0<code>\/tmp<\/code>\u00a0directory and run the following command to create\u00a0<code>upload<\/code>\u00a0folder for wordpress:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo mkdir \/var\/www\/html\/wordpress\/wp-content\/uploads\n<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"configure-wordpress\">Configure WordPress<\/h6>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Configure\u00a0<code>WordPress<\/code>\u00a0to use the installed database. First create\u00a0<code>\/var\/www\/html\/wordpress\/wp-config.php<\/code>\u00a0by running the following command:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo nano \/var\/www\/html\/wordpress\/wp-config.php\n<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Enter the following, and\u00a0<strong>don\u2019t forget to enter the password<\/strong>\u00a0that you have used earlier for the database:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\ndefine('DB_NAME', 'wordpress');\ndefine('DB_USER', 'wordpress');\ndefine('DB_PASSWORD', '&lt;your-password&gt;');\ndefine('DB_HOST', 'localhost');\ndefine('DB_COLLATE', 'utf8_general_ci');\ndefine('WP_CONTENT_DIR', '\/usr\/share\/wordpress\/wp-content');\n?&gt;\n<\/code><\/pre>\n\n\n\n<p>Now you can proceed to your web URL&nbsp;<code>server hostname or IP address\/wordpress<\/code>&nbsp;in your browser. And start installing and configure WordPress:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;server-ip\/wordpress\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/192.168.40.2\/wp-content\/uploads\/2025\/07\/welcom-to-wordpress-page.png\"><img decoding=\"async\" src=\"http:\/\/192.168.40.2\/wp-content\/uploads\/2025\/07\/welcom-to-wordpress-page.png\" alt=\"welcom to wordpress page\" title=\"welcom to wordpress page\"\/><\/a><\/figure>\n\n\n\n<p>Click on&nbsp;<code>Let's go!<\/code><\/p>\n\n\n\n<p>You will be asked for the title of your new site, username, password, and address e-mail. You can choose if you want to make your site indexed by search engines.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/192.168.40.2\/wp-content\/uploads\/2025\/07\/wordpress-installation.png\"><img decoding=\"async\" src=\"http:\/\/192.168.40.2\/wp-content\/uploads\/2025\/07\/wordpress-installation.png\" alt=\"wordpress installation\" title=\"wordpress installation\"\/><\/a><\/figure>\n\n\n\n<p>After that, you are able now to login under&nbsp;<code>server hostname or IP address\/wordpress\/wp-login.php<\/code>&nbsp;In Dashboard, you will see bunch of icons and options.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/192.168.40.2\/wp-content\/uploads\/2025\/07\/wordpress-dashboard.png\"><img decoding=\"async\" src=\"http:\/\/192.168.40.2\/wp-content\/uploads\/2025\/07\/wordpress-dashboard.png\" alt=\"wordpress dashboard\" title=\"wordpress dashboard\"\/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>This article shows how to install&nbsp;WordPress&nbsp;on Ubuntu with&nbsp;Apache2, MariaDB and PHP&nbsp;support. This setup will probably be how all WordPress sites will be configured going forward, for more ways to install<\/p>\n<p><a href=\"https:\/\/allogman.com\/?p=41\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\">Install WordPress on Ubuntu with Apache2, MariaDB and PHP<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-41","post","type-post","status-publish","format-standard","hentry","category-cloud-solutions"],"_links":{"self":[{"href":"https:\/\/allogman.com\/index.php?rest_route=\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/allogman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/allogman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/allogman.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/allogman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=41"}],"version-history":[{"count":1,"href":"https:\/\/allogman.com\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":46,"href":"https:\/\/allogman.com\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions\/46"}],"wp:attachment":[{"href":"https:\/\/allogman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/allogman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/allogman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}