DEV Community

ishwar
ishwar

Posted on

4 2

Setup Wordpress On Ubuntu Server | Install Wordpress On Ubuntu Server

Setup Wordpress On Ubuntu Server Is Quit Easy :-)

Install PHP7, Mysql, Apache2

  1. Install Apache Web Server

    sudo apt-get install apache2 apache2-utils

We need to enable Apache2 web server to start at system boot time, as well start the service as follows:

sudo systemctl enable apache2
sudo systemctl start apache2
Enter fullscreen mode Exit fullscreen mode

Check status :
sudo service apache2 status

  1. Install MySQL Database Server

Next, we need to install MySQL database server by running the command below, You will be prompted to set the root user password for mysql

sudo apt-get install mysql-client mysql-server
Enter fullscreen mode Exit fullscreen mode
  1. Install PHP and Modules

    sudo apt-get install php7.0 php7.0-mysql libapache2-mod-php7.0 php7.0-cli php7.0-cgi php7.0-gd

To test if php is working in collaboration with the web server, we need to create a info.php file inside /var/www/html.

$ sudo vi /var/www/html/info.php

And paste the code below into the file, save it and exit.

<?php
phpinfo();
?>

When that is done, open your web browser and type in the this address http://localhost/info.php.

  1. Install WordPress CMS

Download the latest WordPress package and extract it by issuing the commands below on the terminal:

$ wget -c http://wordpress.org/latest.tar.gz
$ tar -xzvf latest.tar.gz

Now move the WordPress files from the extracted folder to the Apache default root directory, /var/www/html/:

sudo rsync -av wordpress/* /var/www/html/
Enter fullscreen mode Exit fullscreen mode

Give CHMOD permissions, Set the correct permissions on the website directory, that is give ownership of the WordPress files to the web server as follows:

sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/
Enter fullscreen mode Exit fullscreen mode
  1. Login to mysql, create user and database

Execute the command below and provide the root user password, then hit Enter to move to open mysql shell:

mysql -u root -p

// Create Database

mysql> CREATE DATABASE wp_myblogs;

//Grant Access

mysql> GRANT ALL PRIVILEGES ON wp_myblogs.* TO 'your_username_here'@'localhost' IDENTIFIED BY 'your_chosen_password_here';

mysql> FLUSH PRIVILEGES;
mysql> EXIT;
Go the /var/www/html/ directory and rename existing wp-config-sample.php to wp-config.php:

sudo mv wp-config-sample.php wp-config.php

Then update it with your database information under the MySQL settings section

define('DB_NAME', 'database_name');
define('DB_USER', 'username');
define('DB_PASSWORD', 'password');
define('DB_HOST', 'localhost');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

At the last, restart the web server and mysql service using the commands below:

sudo systemctl restart apache2.service
sudo systemctl restart mysql.service

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay