DEV Community

technonotes-hacker
technonotes-hacker

Posted on

LAMP & Wordpress Installation

15-08-2023 " HAPPY INDEPENDENCE DAY "

Before starting to install WORDPRESS , below LAMP should be in place to bring the WordPress installation successful.

LAMP

Image description


APACHE2

  • Apache is the web server that processes requests and serves web assets and content via HTTP.
  • All the configuration files for Apache are located in /etc/httpd/conf and /etc/httpd/conf.d .
  • The data for websites you'll run with Apache is located in /var/www by default, but you can change that if you want.
  • Listen: to bind Apache to specific IP addresses and/or ports. HTTP server, by default, runs on port 80 for production. But, when it has to deal with secure web transactions, it uses the port 443. This secure transaction works using the SSL certificate.
sudo apt update -y && apt upgrade -y
sudo apt install apache2 apache2-utils -y
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl status apache2
apache2 -v
sudo chown -R www-data:www-data /var/www/html
Enter fullscreen mode Exit fullscreen mode

In the above command , while giving "apt upgrade -y" it may take more time. So try to do when necessary. If the command is given don't try to stop in-between it may lead to many issues.

Image description

Image description

Image description

MariaDB

  • MariaDB is a community-developed, commercially supported fork of the MySQL relational database management system, intended to remain free and open-source software under the GNU General Public License. ( as per WIKI )
  • When it comes to performing queries or replication, MariaDB is faster than MySQL.
  • MariaDB also easily supports a high concurrent number of connections without much performance degradation.
sudo apt install mariadb-server mariadb-client
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo systemctl status mariadb
Enter fullscreen mode Exit fullscreen mode

Root Password,

mysql_secure_installation
Enter current password for root (enter for none): enter
Set root password? [Y/n] Y
New password:******
Re-enter new password:******
Remove anonymous users? [Y/n]Y
Disallow root login remotely? [Y/n]Y
Remove test database and access to it? [Y/n]Y
Reload privilege tables now? [Y/n]Y
Enter fullscreen mode Exit fullscreen mode

Login to MariaDB,

mariadb -u root -p
mariadb --version
Enter fullscreen mode Exit fullscreen mode

Image description

PHP

  • The full form of PHP is Hypertext Preprocessor.
  • It is a programming language widely used to build web applications or websites.
  • It is the server-side scripting language encoded with HTML to develop Dynamic website, Static website or Web applications.
  • PHP is an open-source, server-side programming language that can be used to create websites, applications, customer relationship management systems and more.
  • It is a widely-used general-purpose language that can be embedded into HTML.
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.2 libapache2-mod-php8.2 php8.2-mysql php-common php8.2-cli php8.2-common php8.2-opcache php8.2-readline php-json
php --version
sudo vim /var/www/html/info.php --> Edit and test
<?php phpinfo(); ?>
http://localhost/info.php --> Try in the browser
curl http://localhost/info.php

Enter fullscreen mode Exit fullscreen mode

Image description

Image description

Image description

Image description

Image description

Image description

rm /var/www/html/info.php
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

Above LAMP INSTALLATION COMPLETED SUCCESSFULLY


WordPress Installation

  • WordPress is a content management system (CMS) that allows you to host and build websites.
  • WordPress is free, as are many of its add-ons.
  • WordPress lives on a web server, and delivers web content to a user's web client (his or her browser). Processes that occur on the server are called “server-side,” as is the server environment itself.

Let's jump into the set-up, login MariaDB and create a DB w.r.t WordPress ,

mysql -u root -p
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'kan123';
CREATE DATABASE wpdb;
GRANT ALL PRIVILEGES ON wpdb.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
exit;
Enter fullscreen mode Exit fullscreen mode

Image description

Now download WordPress latest version ,

wget https://wordpress.org/latest.zip
unzip latest.zip
rm latest.zip
sudo mv wordpress/ /var/www/html/
sudo chown www-data:www-data -R /var/www/html/wordpress/
sudo chmod -R 755 /var/www/html/wordpress/
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

Image description

Image description

Creation of configuration file ,

sudo vim /etc/apache2/sites-available/wordpress.conf
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/wordpress
ServerName <server_ip> --> which you have mapped in /etc/hosts
<Directory /var/www/html/wordpress/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enter fullscreen mode Exit fullscreen mode

Image description

Enable the virtual host and the rewrite module,

sudo a2ensite wordpress.conf
sudo systemctl reload apache2
sudo a2enmod rewrite
sudo systemctl restart apache2
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

In the browser , try below URL - it will navigate to WordPress home page configuration.

http://server_ip
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Schemas created by the WordPress,

Image description

Error's Faced :

ERROR 1. Inside hosts file, we could see many host-name which is mapped to 127.0.0.1 . Its better to delete and try to make the WordPress up and then add if its required.

Image description

ERROR 2. PHP is not loaded properly,

Image description

Image description

Image description

E: Unable to correct problems, you have held broken packages.

The following packages have unmet dependencies:
curl : Depends: libcurl4 (= 7.81.0-1ubuntu1.10) but 7.81.0-1ubuntu1.13 is to be installed
E: Unable to correct problems, you have held broken packages.

Which leads to unable to start the apache2 ,

Image description

Try the below to which the issue details,

cd /etc/apache2
apache2ctl configtest
journalctl | tail
Enter fullscreen mode Exit fullscreen mode

Image description

Try to purge the apache2 and start the service,

Image description

E: The repository 'https://ppa.launchpadcontent.net/ondrej/php/ubuntu lunar Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Image description

sudo apt --fix-broken install
sudo apt update
sudo cp /etc/apt/trusted.gpg /etc/apt/trusted.gpg.d
sudo apt update
sudo apt install apache2 apache2-utils -y
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

ERROR 3. Its loading different index page,

Image description

cd /var/www/html/
sudo rm index.html site1.test.com/ site2.test.com/
Enter fullscreen mode Exit fullscreen mode

Image description

ERROR 4. Unable to connect DB,

Image description

Image description

Image description

Image description

Image description

Solution : Provide the proper "Password".

ERROR 5. Could not enable dependency mpm_prefork for php8.2, aborting:

Image description

Image description

Image description

Image description

Still it was failing,

Image description

Image description

Solution:

https://stackoverflow.com/questions/47024111/apache-installing-and-running-php-files

sudo a2dismod mpm_event
sudo systemctl restart apache2
sudo a2enmod mpm_prefork
sudo systemctl restart apache2
sudo systemctl status apache2
sudo a2enmod php8.2
sudo a2ensite wordpress.conf
sudo systemctl reload apache2
sudo a2enmod rewrite
sudo systemctl restart apache2
Enter fullscreen mode Exit fullscreen mode

Important points:

  1. https://mariadb.org/
  2. https://httpd.apache.org/
  3. https://www.php.net/
  4. Completed installation steps with more details : https://github.com/tkdhanasekar/kaniyam-devops-course-materials/blob/main/Linux/lamp-stack.md
  5. https://wordpress.com/
  6. shift control + n/p --> Private Window
  7. All plugins are available in WordPress , which are free and can be paid.

Top comments (0)