Here you will find the Knowledge base article on how to install apache2 and MySQL on the Ubuntu server of Azure Cloud using CLI in a few steps.
Prerequisites:
- Basic knowledge of Linux.
- Familiar with Azure portal.
Installing of Apache2.
Follow the below steps and parallelly start working on it.
(All Snips attached for Reference)
- Step 1:
Firstly you should be having a running Ubuntu Virtual Machine / Server in Azure Cloud.
VM Image : Ubuntu Server18.04 LTS -x64 Gen2
- Step 2:
Now copy the Public IP address from overview tab of Virtual Machine /Server and paste it in PuTTY.
[Go to Google and download PuTTY. (If not installed in your local system). Click here to download. (64-bit x86 recommended)]
SSH the VM/Server using the Username and Password.
- Step 3:
Run the command
sudo apt install apache2
This command will download and install the latest version of Apache2 available in the repository.
- Step 4:
Copy the IP address and browse it over Internet.
After the installation is complete, you can start the Apache service using the command
sudo service apache2 start
By default, Apache will serve web pages from the "/var/www/html" directory on the system.
You can test the installation by opening a web browser and navigating to http://localhost/
or http://your-server-ip-address, where you should see the default Apache web page.
In my case the your-server-ip-address is 20.106.210.31
- Step 5:
Now run the command
cd /var/www/html/
ls
The command "cd /var/www/html/" is used to change the current directory to the default document root directory of the Apache HTTP Server
Apache will serve files from this directory by default.
The "ls" command in Linux is used to list the files and directories in the current working directory or a specified directory.
You will find one index.html file present here which holds apache2 files.
- Step 6:
sudo vi test.html
The command "sudo vi test.html" is used to create or edit a file named "test.html" using the Vi text editor.
"vi" is a powerful text editor that is available on most Unix-based systems, including Linux. With Vi, you can create, edit, and manipulate text files using a variety of commands and keyboard shortcuts.
After running this command, Vi will open and display the contents of the "test.html" file (if it already exists) or create a new file with that name (if it doesn't exist yet). You can then use Vi's command mode and editing mode to make changes to the file.
<html>
<h1> This is the fresh Page </h1>
</html>
Once you've finished making changes, you can save the file and exit Vi by pressing ‘esc’ button and typing ":wq" and pressing Enter.
- Step 7:
Again check the file you created is present or not using ls command
ls
If you see test.html file. Kudos! If the file you created is not present, then again repeat the above steps to create one.
- Step 8:
Now move the main index.html file to backup.html for making a backup of it and also move the test.html file to main index.html file.
For doing this run the below commands.
sudo mv index.html backup.html
"mv" is the command used to move files and directories in Linux. In this case, we are using it to move the file "index.html" to "backup.html". This command will essentially move the file from its current location to a new file name.
After running this command, the original "index.html" file will no longer exist in the current directory, and a new file named "backup.html" will take its place.
sudo mv test.html index.html
We are using it to move the file "test.html" to "index.html". This command will essentially move the file from its current location to a new file name.
After running this command, the original "test.html" file will no longer exist in the current directory, and a new file named "index.html" will take its place.
- Step 9:
Refresh the page
Also add /index.html with IP address.
In my case it is : 20.206.210.31/index.html
The URL "20.206.210.31/index.html" is an example of a web address or URL that points to a specific file named "index.html" located on a web server with the IP address of 20.206.210.31.
Your apache2 is installed successfully on Ubuntu Server in Azure Cloud.
Moving towards installing of MySQL Server.
In continuation on same SSH.
- Step:
Run the command.
sudo apt-get install mysql-server
The command "sudo apt-get install mysql-server" is used to install the MySQL database server.
After running this command, APT will download and install the MySQL server package along with any necessary dependencies.
Press Y yes for giving permission of using additional disk.
Once the installation is completed successfully, check the version
mysql -V
This command is used to check the version of the MySQL database server.
If MySQL is not present or installed, it will give the error.
Top comments (0)