Support Online
Skip to main content

Installing WordPress with LAMP on Ubuntu 16.04

Keyword: Ubuntu LAMP WordPress installation

What Will You Learn in This Guide?

In this guide, you will learn how to install WordPress using LAMP architecture on Ubuntu 16.04 server.
Apache configuration, PHP modules, and secure file permissions are covered.
At the end of the installation, you will have a working and manageable WordPress site.

Technical Summary

  • Technical Topic: Installing WordPress with LAMP on Ubuntu 16.04
  • Solved Problem: Correct configuration of Apache, PHP and MySQL for WordPress
  • Steps Followed:
    1. Creating MySQL database and user
    2. Installing the required PHP modules
    3. Configuring Apache to support .htaccess
    4. Download WordPress files
    5. Securely set file permissions
    6. Complete the installation via web interface

1. Database Preparation for WordPress

WordPress stores its data on MySQL.
First log in to the MySQL administrator account.

mysql -u root -p
  1. This command opens the MySQL administration panel.


CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
GRANT ALL ON wordpress.* TO 'wp_kullanici'@'localhost' IDENTIFIED BY 'guclu_sifre';
FLUSH PRIVILEGES;
EXIT;
  • Creates database and defines authorized users for WordPress.

2. Installing Required PHP Modules

  1. WordPress requires additional PHP modules for many plugins.

sudo apt-get update
sudo apt-get install php-curl php-gd php-mbstring php-mcrypt php-xml php-xmlrpc
  • Installs common PHP modules for WordPress.

sudo systemctl restart apache2
  • Enables Apache to use new PHP modules.

3. Editing Apache Configuration

  1. WordPress permalinks are based on .htaccess file. Therefore the Apache configuration is updated.

sudo nano /etc/apache2/apache2.conf
  • Opens the Apache main configuration file.


<Directory /var/www/html/>
AllowOverride All
</Directory>
  • Allows .htaccess files to work.


sudo a2enmod rewrite
sudo apache2ctl configtest
sudo systemctl restart apache2
  • Enables the Rewrite module and restarts Apache.

4. Downloading WordPress Files


cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
  • Downloads the current WordPress version.


cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
sudo cp -a /tmp/wordpress/. /var/www/html
  • Moves WordPress files to the web directory.

5. Setting Directory and File Permissions

  1. Secure and sustainable permits are defined.

sudo chown -R tr1-node01:www-data /var/www/html
sudo find /var/www/html -type d -exec chmod g+s {} \;
sudo chmod g+w /var/www/html/wp-content
  • Allows necessary permissions for theme and plugin installations.

6. Completing the Setup via Web Interface

  1. From the browser, go to the following address:

http://sunucu_ip_adresi
  1. Select your language

  2. Enter the site name and administrator information

  3. Click the Install WordPress button


Frequently Asked Questions (FAQ)

1. Can I update without entering FTP information? Yes. define('FS_METHOD', 'direct'); add.

2. I am getting a database connection error, why? Database name, user and password must be exactly the same.

3. The .htaccess file is not visible, is that a problem? No. It is a secret file. It is displayed with ls -a.

4. Is it necessary to change security keys? Not required, but strongly recommended.

Result

Your WordPress site is now running on Apache. You can choose themes and configure permalinks.

🚀 You can install this structure in minutes on the GenixNode infrastructure. You are ready for safe, stable and SEO compatible projects.