How to install wordpress on ubuntu 18

When developing for WordPress locally on Windows, we need lớn have Apache, PHP và MySQL installed. There are web development environments available such as EasyPHP or WampServer, but I always prefer to install them manually. The experience you gain from it becomes useful when you encounter a problem with either PHP, Apache, or MySQL database as you will have a better idea where khổng lồ look for the issues.

Bạn đang xem: How to install wordpress on ubuntu 18

We will first install a PHP, then an Apache web server, and finally a MySQL database. We will also install the MySQL Notifier utility to lớn manage the MySQL instances và phpMyAdmin tool, khổng lồ manage MySQL databases. Finally, we will go through each step to lớn install WordPress that will run on our localhost.

So let's get started.

Table of Contents

1. Install PHP

WordPress is written in PHP which is a scripting language and we are going to install that first. On PHP official tải về page, there will be two versions available for download, ThreadSafe & NonThreadSafe. We will download the ThreadSafe .zip file.

Extract the ThreadSafe file somewhere on your computer and copy the folder to C: root partition. Currently, the latest PHP version is 8.x, so we will rename the thư mục to php8 khổng lồ reflect the PHP version. The absolute PHP path will be as follows:


About the php.ini configuration file

The php.ini is a mặc định PHP configuration tệp tin where we declare changes to the PHP behavior. The extracted files inside C:php8 will not have the php.ini file. Instead, you should see two configuration files, php.ini-development & php.ini-production. The main difference is that in the development version, the warnings and errors are not hidden, so we will use that one.

We will make some changes lớn it và then save it as php.ini file.

Modify the php.ini file

Open php.ini-development in the text editor so we can make the following modifications:

Extension directoryFind:

;extension_dir = "ext"Change it lớn this:

extension_dir = "C:php8ext"We uncommented the line by removing semicolon ; at the beginning và added path khổng lồ ext folder, which in our case is C:php8ext. This is the thư mục containing various PHP extension .dll libraries.

By default, all these extensions are commented out, but we need lớn enable a few of them.

mysqli extensionWe also need to enable mysqli extension for the MySQL library. Find this extension (it should be few lines above extension=openssl) and remove the bình luận so it will look lượt thích this:

extension=mysqliOther extensionsSome WordPress plugins also need other extensions lớn be enabled, such as curl and fileinfo extension, so you might also uncomment those, but for basic WordPress installation, mysqliopenssl extension is all we need.
Note: With cURL extension, just enabling it in php.ini might not be enough. Check this article khổng lồ learn how lớn enable cURL in Windows.
upload_max_filesize & post_max_size directivesLet's also modify few more lines. Find the following:

upload_max_filesize = 2Mand change it to

upload_max_filesize = 64MAlso find this line:

post_max_size = 8Mand change it to:

post_max_size = 64MIncreasing the value of upload_max_filesize & post_max_size directives will increase the allowed uploaded file và POST data in the PHP applications. We need this for example when importing a database using the phpMyAdmin tool. If the imported database file kích cỡ is greater than the above specified-values, the import could fail with the message "phpMyAdmin - Error - Incorrect format parameter".

We are finished with modifying the configuration file. Don't forget lớn save the changes as php.ini file!!

Note: When making changes in php.ini file while the Apache server is running, we need to restart the Apache hệ thống for changes to take effect.

We are done configuring PHP, now let’s turn our focus lớn the Apache webserver.

2. Install Apache

Apache is a web hệ thống software that enables your computer lớn host websites. We can download Apache by going to lớn Apache Lounge tải về page. Tải về the Win64 or Win32 .zip file, extract it và copy Apache24 folder into C:, so that the path is:


Configuring Apache

Now we need lớn configure Apache. Go to C:Apache24conf and xuất hiện the httpd.conf in the text editor.

Listen directiveLet’s first make sure the Apache will only listen to lớn localhost. Find the following line. It should be at the start of the httpd.conf file:

Listen 80Change it to:

Listen will make sure that the Apache listens only to lớn requests from localhost and will ignore the external addresses.

DocumentRoot và Directory directiveNext, we need khổng lồ set the root server folder in httpd.conf file.Find the following directives:

DocumentRoot "$SRVROOT/htdocs"You can leave it as it is in which case the root server thư mục will be located at:


If you prefer to have it somewhere else, change the path. For example, if you want it to be at d:/www, you would change it to

DocumentRoot "d:/www"

Note: The thư mục separator in the path should contain forward slashes / instead of Windows backslashes
DirectoryIndex directiveNext, we need to set the index.php as mặc định page. Find the following line inside httpd.conf:

DirectoryIndex index.htmlChange it to:

DirectoryIndex index.html index.phpIn the above code, the index.html will have priority if both index.html & index.php exist on the same folder.

AddHandler directiveNow we need to tell Apache which files should be processed by PHP. We bởi vì that by using AddHandler directive. Find the following line in httpd.conf:

#AddHandler cgi-script .cgiThis is just a comment, so leave it as it is. Below it, add the following line:

AddHandler application/x-httpd-php .phpServerName directiveFind the following line:

#ServerName is also just a comment. Below it, địa chỉ the following line:

ServerName the ServerName directive, the Apache vps might give you the following warning:

Error:AH00558: httpd.exe: Could not reliably determine the server's fully qualified domain name name

And we are done with modification of Apache configuration file. Save the httpd.conf file.

Start the Apache server

All that is left to bởi vì is lớn start the Apache server. Go to lớn C:Apache24in và run the httpd.exe file. A window with a command prompt should mở cửa and remain open.

Note: If the command prompt windows closes immediately after running httpd.exe then there is probably an error in the httpd.conf file. In this case mở cửa the command prompt (click search on Windows và type cmd), type cd c:apache24in and once there, typehttpd.exe. Check the errors shown, fix them và try running httpd.exe again.

Test the Apache website server

Now, let's demo if the Apache vps is really running. Xuất hiện browser and go to lớn or http://localhost/. The browser should now show you the content of the thư mục that was phối in DocumentRootDirectory directives when we modified the httpd.conf file.

Let’s create a test php file to see if Apache does indeed support PHP. Mở cửa text editor, create a test.php file in the root server folder and add the following code:

Save the file và go to to run it. You should see the trắng page with the "hello world" message.

Starting Apache server by running c:Apache24inhttpd.exe is not very efficient though. A better way is lớn run it as a service.

Run Apache as a service

First, close the Command Prompt window running httpd.exe if it is still opened from the previous step.

Next, we need to lớn run a command prompt as an administrator. There are many ways to vì chưng this, one quick way is lớn type "cmd" in the Windows Search:


Command Prompt should show up as the best match. On the right side, click on "Run as administrator". User tài khoản Control Window should show up asking you lớn confirm this. After clicking "Yes", the command prompt window should show up.

Inside the command prompt, first type the line shown below, so that we will be inside the Apache bin folder:

cd c:apache24inOnce we are inside it, type the following command:

httpd -k installIf everything was successful, you should get the following message:

Installing the 'Apache2.4' serviceThe 'Apache2.4' service is successfully installed.Testing httpd.conf....Errors reported here must be corrected before the service can be started.

This will địa chỉ Apache as a service, but the service has not started yet.

Manage Apache service

The easiest way to control the Apache Service is by running ApacheMonitor.exe located in the same c:apache24in folder.

After running this utility, you should see that the notification icon on the taskbar has been added for the ApacheMonitor utility. If you click on it, you can start the Apache service by going to lớn Apache2.4 > Start. You can also Stop và Restart the Apache service the same way.


After selecting Apache2.4 > Start, the ApacheMonitor notification icon should now display in the Notification area as a tiny green arrow and if you hover over it, it should say "Running All Apache Services".

Adding ApacheMonitor.exe lớn a Windows Startup

It would be better if we make the ApacheMonitor.exe start with windows. Here are the steps:

Go khổng lồ c:apache24in & create a shortcut for ApacheMonitor.exe.Type "run" in Windows tìm kiếm and xuất hiện the "Run" App."The popup window will show up. Type the command "shell:startup" as shown below and press enter:
This will open the file Explorer in the "Startup" folder.Copy the shortcut we created earlier to lớn this folder.

Now, every time your Windows start, the ApacheMonitor.exe should also start.

So far we have a Web vps that is able khổng lồ process PHP files. Next, let’s install the MySQL database.

3. Install MySQL database

WordPress also uses MySQL database, so we are going to install the MySQL Community database on our Windows machine.

Downloading the MySQL

Go to lớn MySQL download page. There should be two installers available for downloads. One is a much smaller web online installer which is handy if you have a slow mạng internet connection as it will download only stuff you need. The other one is an offline installer with all the features và due khổng lồ that is a much larger file. Choose whichever you prefer và click "download".

You should now see the following page.


Simply click on the "No thanks, just start my download." link.

Run the MySQL Installer

After the download is complete, run the installer. User tài khoản Control Window should show up. Check that the verified advertiser is "Oracle America, Inc." và click "Yes". MySQL Installer window should open. The installer consists of the following steps as shown below:


Choosing a cài đặt TypeIn the first step, we need to lớn choose a thiết lập type. If you choose "Developer Default", it will install MySQL server và additional products, such as MySQL Shell, MySQL for Excel, MySQL for Visual Studio, but for our purposes of running WordPress, we really only need MySQL server, so choose "Server Only" & click "Next".

Note: If it prompts you khổng lồ install "Microsoft Visual C++ 2015-2019 Redistributable", địa chỉ a checkbox to lớn agree with the license terms & click "Install".
InstallationIn this step, you should see a các mục of products that will be installed. There should be "MySQL Server" product with the status "Ready to install". Click on "Execute". If successful, there should be a green checkbox next to lớn the "MySQL Server" hàng hóa with the status "Complete". Click on the "Next" button.You should now be at "Product Configuration" step. In this step, we configure the products that we just installed, in our case, this would be MySQL hệ thống with the status "Ready to configure". Click on "Next".

On the left sidebar, you should now see steps to lớn various configuration options.

Xem thêm: length array php w3schools


Type & NetworkingConfig Type should be already set at "Development Computer". If not, mix it & click "Next".Authentication MethodHere, we choose the recommended "Use Strong Password Encryption for Authentication" option. The other "Use Legacy Authentication Method (Retain MySQL 5.x Compatibility" is needed for PHP 7.2 or lower, but we used the latest PHP version which is currently PHP 8.

Accounts and RolesHere, choose a root password. Make sure that after typing và repeating the password you get the message "Password strength: Strong" và click "Next".

Windows ServiceLeave everything as it is. This way, MySQL will run as a service. Click "Next".Apply ConfigurationHere, you will see a danh mục of steps, the configuration needs to perform. Click on "Execute". This shouldn't last long (at most not more than a few minutes). When finished, if everything went without issues, all the steps should display green checkboxes. Click on the "Finish" button.Product ConfigurationYou should now see the "MySQL Server" hàng hóa with the status "Configuration complete". Click "Next".Installation CompleteWhen we reach this step, the installation is done. We have an option to copy the installation log to lớn the clipboard. Click "Finish".

After installation is completed, the MySQL server should now run in the background of your system as a Windows service.

About MySQL configuration file

Before we go khổng lồ the next step, let's talk about the MySQL configuration file for a moment. Similar to lớn Apache, the MySQL hệ thống also has a configuration file named my.ini where we can change & add various settings. For MySQL vps 8.0, the file is located at ProgramDataMySQLMySQL vps 8.0

Default settings in my.ini file are fine và we don't need lớn change anything, but it is always good khổng lồ know the location of configuration files in case we need to change settings in the future.

Note: Any change in the my.ini tệp tin will require restarting of MySQL.

In the next step, we are going khổng lồ install a small utility MySQL Notifier utility khổng lồ easily manage the MySQL service.

3.1. Tải về MySQL Notifier utility

During installation, we chose the mặc định option to run MySQL hệ thống as a Windows service. In order to easily stop / start / restart this service, we can tải về the MySQL Notifier utility. Click on the "Download" button, save the file và run the installer.

When we install it và run MySQL Notifier, a notification icon will appear on the taskbar from which we can easily stop, start or restart the MySQL vps as shown below:


Note: The install will make sure that the MySQL Notifier runs each time the Windows starts. To change that, right-click on the notifier icon & choose "Actions > Options" và deselect "Run at Windows startup".

4. Install phpMyAdmin tool

With a working MySQL server, we need khổng lồ know how to manage MySQL databases and database users. For this purpose, we are going to use the PhpMyAdmin, a MySQL management tool written in PHP that we run on a browser from our localhost.

Download the phpMyAdmin

Go to lớn the phpMyAdmin trang web and download it by clicking on the green "Download" button. Extract the downloaded file into your localhost root hệ thống folder.

About phpMyAdmin configuration file

The phpMyAdmin tool also has a configuration file named, but after extracting the files you will notice that it's missing. We are going lớn use a sample configuration tệp tin named, so open that file in the text editor.

Find the following line:

$cfg<'blowfish_secret'> = '';We need lớn put a random 32 characters long string as a value to this configuration setting. We can use this online tool that generates the $cfg<'blowfish_secret'> containing the random secret. Copy this generated code & save the tệp tin as

Run the phpMyAdmin tool

To run the phpMyAdmin, open the browser and go khổng lồ the following URL shown below. The X.X.X should be replaced with the phpMyAdmin version you are using.

If everything worked as it should, the phpMyAdmin will ask you for the login information:


Use the root as username và password that you picked when MySQL was configured.

The phpMyAdmin dashboard should now show up:


Note: If you prefer GUI desktop applications, you could use a MySQL Workbench utility instead.

Possible Errors

The phpMyAdmin needs a PHP mysqli extension for it to work. We enabled this extension when we configured php.ini file at the beginning of this article when we modified the php.ini file. If it’s not enabled, we get the following error:

phpMyAdmin - ErrorThe mysqli extension is missing. Please check your PHP configuration.

5.1. Creating a Database and Database user for WordPress

We will use the phpMyAdmin tool khổng lồ create a database và a database user for our WordPress website. The steps are as follows:

Run the phpMyAdmin tool from our root server thư mục and login by using your MySQL login credentials.Once inside the phpMyAdmin dashboard, click on the "Databases" tab. Under the "Create database", there will be a text field. Type a database name you want to use and click on the "Create" button.After database creation, your tabs will change khổng lồ manage this database. Click on the "Privileges" tab lớn manage database users for this database.Here, you should see the list of existing database users. We will create a new user. Click on the "add user account" link.Under "Login Information", we need lớn set:UsernameGive it a name, for example, mywpuser. Remember it as we will need it later when we install WordPress.Host nameFrom the dropdown, change from "Any host" to lớn "Local".PasswordChoose a strong password. The easiest way is to click on the "Generate" button located below the "Password" field. It will generate one for you. This password will be used when we will install WordPress, so save it temporarily somewhere on your computer.

Now scroll all the way down & click the "Go" button located on the bottom right corner to save the settings. If everything went without issues, you should see the green "You have added a new user." message.

We have now created a WordPress database that is currently empty and also created a new database user tài khoản for this database. Both will be used in the next step.

5.2. Running WordPress Installation

To install WordPress, we first navigate to the URL of the folder with extracted WordPress files in our localhost which in our case should be:

This should redirect you to:

There are several steps we need lớn go through.

In this step, we are going lớn fill in the database information:
We need lớn fill the fields shown above.

Database NameUsernamePassword

For the Database Name, Username và Password, enter the values used when we created the database earlier using phpMyAdmin.

Database HostLeave it at localhost as the database is on the same machine.Table PrefixLeave it as it is. This will địa chỉ cửa hàng a prefix wp_ khổng lồ the database tables generated with this installation.

Click the "Submit" button. This information will be saved in wp-config.php file inside the WordPress root folder. If we need khổng lồ modify any of these settings again in the future, we edit the wp-config.php tệp tin in the text editor.

If everything was entered correctly, WordPress should now be able khổng lồ communicate with the database & we should see the message shown below:

Click on the "Run the installation" button lớn continue to the next step.

On the other hand, if there is an issue and WordPress cannot establish a database connection, you might get one of the following errors:

Error establishing a database connectionThis error will contain the following message:
This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database hệ thống at localhost. This could mean your host’s database hệ thống is down.

Are you sure you have the correct username and password?Are you sure you have typed the correct hostname?

In this step, we now need khổng lồ fill in the information regarding the WordPress website.


Note: Everything here can be later changed in the dashboard except for username. Lớn change the username, we can use the Easy Username Updater plugin.

We will mix the following:

Site TitleUsernamePassword

The username and password we enter here are the login information for the administrator user & are used khổng lồ login into a WordPress Dashboard. Don't confuse them with the database username và password.

Click "Install WordPress" khổng lồ continue.

If the installation completes successfully, you should see the following page:

Click on "Log in" button.

You should now see the default WordPress login page:

Note: lớn access the admin dashboard in the future, showroom /wp-admin/ path khổng lồ the end of the URL of your installed WordPress website.

After successful login, you should see the dashboard as shown below:


If you made it this far, Congratulations. You are now running a WordPress trang web locally on your Windows machine.


In this article, we learned how to run WordPress locally on Windows systems. We had khổng lồ first install PHP, Apache server, và MySQL database. For easy management of the MySQL database, we installed the phpMyAdmin tool and for easier management of the MySQL service, we installed MySQL Notifier utility. After that, all that was left was to lớn install WordPress.