MySQL is open-source database management system. This tutorial will go over how to install MySQL version 8.0 on an Ubuntu 20.04 server. By completing it, you will have a working relational database that you can use to build your next website or application.
Installing MySQL
On Ubuntu, you can install MySQL using the APT package repository. At the time of this writing, the version of MySQL available in the default Ubuntu repository is version 8.0.27.
To install it, update the package index on your server if you’ve not done so recently:
sudo apt update
Then install the mysql-server package:
sudo apt install mysql-server
Ensure that the server is running using the systemctl start command:
sudo systemctl start mysql.service
These commands will install and start MySQL, but will not prompt you to set a password or make any other configuration changes. Because this leaves your installation of MySQL insecure, we will address this next.
Configuring MySQL
First, open up the MySQL prompt:
sudo mysql
Then run the following ALTER USER command to change the root user’s authentication method to one that uses a password. The following example changes the authentication method to mysql_native_password:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
After making this change, exit the MySQL prompt:
mysql> exit
That’s all for installing and configure MySQL in ubuntu.
How to install elasticsearch in ubuntu
About Elasticsearch.
Elasticsearch is the distributed search and analytics engine at the heart of the Elastic Stack. Logstash and Beats facilitate collecting, aggregating, and enriching your data and storing it in Elasticsearch. Kibana enables you to interactively explore, visualize, and share insights into your data and manage and monitor the stack. Elasticsearch is where the indexing, search, and analysis magic happens.
Installing Elasticsearch.
We can install elasticsearch two way
Install ES using repository
We sign all of our packages with the Elasticsearch Signing Key (PGP key D88E42B4, available from https://pgp.mit.edu) with fingerprint:
You need to install the apt-transport-http package on debian before proceeding.
sudo apt-get install apt-transport-http
Save the repository definition to /etc/apt/sources.list.d/elastic-8.x.list:
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
Note: These instructions do not use add-apt-repository for several reasons: add-apt-repository adds entries to the system /etc/apt/sources.list file rather than a clean per-repository file in /etc/apt/sources.list.d add-apt-repository is not part of the default install on many distributions and requires a number of non-default dependencies. Older versions of add-apt-repository always add a deb-src entry which will cause errors because we do not provide a source package. If you have added the deb-src entry, you will see an error like the following until you delete the deb-src line: Unable to find expected entry ‘main/source/Sources’ in Release file (Wrong sources.list entry or malformed file)
You can install the Elasticsearch Debian package with:
Composer is a popular dependency management tool for PHP, created mainly to facilitate installation and updates for project dependencies. It will check which other packages a specific project depends on and install them for you, using the appropriate versions according to the project requirements.
Requirments
Before install composer we need PHP. If you do not install PHP then first you need to install PHP in your ubuntu system.
If you need help to install PHP then click here for more info.
After installing PHP we can able to install composer in Ubuntu.
Installing Composer
Composer provides an installer script written in PHP. We’ll download it, verify that it’s not corrupted, and then use it to install Composer.
Make sure you’re in your home directory, then retrieve the installer using curl:
cd ~
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
Next, we’ll verify that the downloaded installer matches the SHA-384 hash for the latest installer found on the Composer Public Keys / Signatures page. To facilitate the verification step, you can use the following command to programmatically obtain the latest hash from the Composer page and store it in a shell variable:
If the output says Installer corrupt, you’ll need to download the installation script again and double check that you’re using the correct hash. Then, repeat the verification process. When you have a verified installer, you can continue.
To install composer globally, use the following command which will download and install Composer as a system-wide command named composer, under /usr/local/bin:
Output
All settings correct for using Composer
Downloading...
Composer (version 2.2.9) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
To test your installation, run this:
composer
Output
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version Composer version 2.2.9 2022-03-15 22:13:37
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--profile Display timing and memory usage information
--no-plugins Whether to disable plugins.
-d, --working-dir=WORKING-DIR If specified, use the given directory as working directory.
--no-cache Prevent use of the cache
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
...
That’s all for installing composer in Ubuntu.
How to install apache 2.x in ubuntu
About Apache
Apache is an open source web server that’s available for Linux servers free of charge.
In this tutorial we’ll be going through the steps of setting up an Apache server.
Install Apache 2 in Ubuntu
To install Apache, install the latest meta-package apache2 by running:
sudo apt update
sudo apt install apache2
Verify apache is installed or not
Open your borwser and just type http://localhost/ or http://<your_ip>/ and press enter.
it should show the apache default page.
That’s all, Apache 2 is installed in your ubuntu system.
How to install Magento 2.4.6 in Ubuntu
What is Magento ?
Magento is opensource e-commerce platform, which provides online merchants with a flexible shopping cart system. Magento offers powerful marketing, search engine optimization, and catalog-management tools.
We need to give correct permission to Magento directories by this below commands:
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chmod -Rf 777 var
chmod -Rf 777 pub/static
chmod -Rf 777 pub/media
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
chmod -Rf 775 bin
Create new database for Magento
We need to create empty database for new Magento setup.
mysql> CREATE DATABASE mag24;
Install Magento 2 using command
Before install we need to check elasticsearch is running and check MySQL server is running. Run the following lines in Command Line to install your Magento 2:
Today we are going to create a simple module in Magento 2. We display a simple message using the controller and using a custom layout.
So, In this module we need to create one controller and a custom route. Using this route we are able to see our simple message in magento.
Also, We need to create the layout file for displaying simple messages using layout.
Our module vendor is RS and the module name is FirstModule.
Let’s start creating a simple module in Magento 2.x.
1. Create module directory
First we need to create a vendor directory, Our vendor name is RS. So, We need to create an RS directory under your app/code directory.
After creating the vendor directory we need to create a module directory. Our module name is FirstModule. So, we need to create FirstModule under the app/code/RS/ directory.
In my case the module directory looks like MAGENTO_ROOT/app/code/RS/FirstModule/. But in your case you need to create a directory as per your vendor name and module name.
Ex. your vendor name is Abc and module name is Hello the your module file looks like MAGENTO_ROOT/app/code/Abc/Hello/.
2. Create module registration.php file & What is the use of this file?
This file helps to register our component to our Magento 2 application. Magento 2 have different type of component like Module, Theme, Langauge and Library. We have register our module component to Magento 2.
This file registered our custom route to Magento application. We have define two attributes in this file. id and frontName, using id we can create our custom layout. frontName is represent the first part of url.
5. Create controller for display custom message without layout
Created the controller for display the simpple message in Magento 2.x. I have just print simple message using echo function.
<?php
//file path: MAGENTO_ROOT/app/code/RS/FirstModule/Controller/First/Index.php
namespace RS\FirstModule\Controller\First;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
class Index extends Action
{
public function __construct(Context $context)
{
return parent::__construct($context);
}
public function execute()
{
echo __("This is my first Magento 2 module");
}
}
6. Install your module to magento
We have create custom module for print simple message without using XML layout. Above all the command is responsible to enable and install our module to Magento 2.
After that run the setup:upgrade and setup:static-content:deploy -f command to install module.
7. Check your first module message
Let’s verify our module is working fine or not.
How we can check our module in browser?
Our custom route is first_module.
Our controller name is First.
Our action name is Index.
Our url looks like first_module/first/index. Using this url we can check our module result.
Open this URL(http://your_magento_url/first_module/first/index) on your browser
Output:
8. Now we will display this message using Magento layout. So we need to some changes to our existing controller
Modified Index.php file for load simple message using custom layout. I have added new dependency in constructor, this new argument is responsible to load custom layout.
<?php
//file path: MAGENTO_ROOT/app/code/RS/FirstModule/Controller/First/Index.php
namespace RS\FirstModule\Controller\First;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
class Index extends Action
{
/**
* @var PageFactory
*/
protected $resultPageFactory;
/**
* Controller constructor
*
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory
) {
$this->resultPageFactory = $resultPageFactory;
return parent::__construct($context);
}
/**
* Execute view action
*
* @return Magento\Framework\View\Result\Page
*/
public function execute()
{
return $this->resultPageFactory->create();
}
}
9. Create layout file
Create custom layout file. Using id we can create the custom layout file name. Our route id is first_module and our controller name is First and action name is Index. Our layout file look like first_module_first_index.xml.
In the simple module we not need any dynamic value in template file. So, I just use default magento template block Magento\Framework\View\Element\Template.