In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to install and configure Apache 2 Web server on Ubuntu 18.04". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
What is Apache Web Server?
The Apache or Apache HTTP server is a free open source Web server developed and maintained by the Apache Software Foundation (Apache Software Foundation). Its popularity can be judged by the fact that about 46 per cent of websites worldwide are supported by Apache. Apache allows website developers to provide their content over the web.
This tutorial is about installing and configuring Apache2 on Ubuntu systems. The commands and procedures mentioned in this article have been run on Ubuntu 18.04 LTS systems. Because we used the Ubuntu command line, terminal, in this article; you can open it through the system Dash or Ctrl + Alt + T shortcuts.
Install Apache 2 on Ubuntu Linux
Follow these steps to install the Apache2 software from the Ubuntu official repository.
Step 1: update the system repository
You can download the latest version of the software by first updating the local package index of the Ubuntu repository. Open the terminal and enter the following command to do this:
Linuxidc@linuxidc:~/ Desktop / linuxidc.com$ sudo apt update
Step 2: install Apache 2 using the apt command
Next, enter the following command as sudo to install Apache2 and its required dependencies:
Linuxidc@linuxidc:~/ Desktop / linuxidc.com$ sudo apt install apache2
The output is as follows:
Server version: Apache/2.4.29 (Ubuntu)
Server built: 2018-10-10T18:59:25
Configure UFW Firewall
In order to configure Apache, we first need to allow external access to some of our system's Web ports and allow Apache on your UFW firewall.
Step 1: list UFW application configuration files
To configure the firewall, let's first list the application configuration files we need to enable Apache access. Use the following command to list such available applications:
Linuxidc@linuxidc:~/ Desktop / linuxidc.com$ sudo ufw app list
The status of UFW will now show that Apache is enabled on the firewall.
$sudo ufw status
Configure the Apache Web server
Step 1: verify that the Apache service is running
The first step is to verify that the Apache2 service is up and running on your system with the following command:
Linuxidc@linuxidc:~/ Desktop / linuxidc.com$ sudo systemctl status apache2
● apache2.service-The Apache HTTP Server
Loaded: loaded (/ lib/systemd/system/apache2.service; enabled; vendor preset:
Drop-In: / lib/systemd/system/apache2.service.d
└─ apache2-systemd.conf
Active: active (running) since Sun 2018-11-25 19:26:03 CST; 10min ago
Main PID: 11590 (apache2)
Tasks: 6 (limit: 3500)
CGroup: / system.slice/apache2.service
├─ 11590 / usr/sbin/apache2-k start
├─ 11610 / usr/sbin/apache2-k start
├─ 11611 / usr/sbin/apache2-k start
├─ 11612 / usr/sbin/apache2-k start
├─ 11616 / usr/sbin/apache2-k start
└─ 11618 / usr/sbin/apache2-k start
November 25 19:26:03 linuxidc systemd [1]: Starting The Apache HTTP Server...
November 25 19:26:03 linuxidc apachectl [11574]: AH00558: apache2: Could not reliably
November 25th 19:26:03 linuxidc systemd [1]: Started The Apache HTTP Server.
Then try IP one by one in the Web browser, as follows:
Http://server_IP
Now let's create an index page, and if Apache runs our domain name, we can access them later for testing. Create a HTML file from the Nano editor or any text editor you like.
Nano / var/www/linuxidc.com/html/index.html
Enter the following HTML for the index page:
Welcome to the Linux commune page www.linuxidc.com
You're amazing! Your linuxidc.com server block has been started!
Enter the following custom configuration details for the domain name:
ServerAdmin admin@linuxidc.com
ServerName linuxidc.com
ServerAlias www.linuxidc.com
DocumentRoot / var/www/linuxidc.com/html
ErrorLog ${APACHE_LOG_DIR} / error.log
CustomLog ${APACHE_LOG_DIR} / access.log combined
We are using the nano editor to create this .conf file.
You can use Ctrl + X to save the file as nano, then enter Y and press Enter.
Step 2: enable the domain profile
Let's enable the profile created using the a2ensite tool:
Linuxidc@linuxidc:~/ Desktop / linuxidc.com$ sudo a2ensite linuxidc.com.conf
Enabling site linuxidc.com.
To activate the new configuration, you need to run:
Systemctl reload apache2
Now restart the Apache service:
Linuxidc@linuxidc:~/ Desktop / linuxidc.com$ sudo systemctl restart apache2
Step 3: test the error
Finally, let's test for any configuration errors with the following command:
Linuxidc@linuxidc:~/ Desktop / linuxidc.com$ sudo apache2ctl configtest
If you do not receive any errors, you will get the following output:
Syntax OK
Resolve errors:
Enter the following command to resolve the above error:
Linuxidc@linuxidc:~/ Desktop / linuxidc.com$ echo "ServerName linuxidc.com" >
Then:
Linuxidc@linuxidc:~/ Desktop / linuxidc.com$ sudo a2enconf servername
Enabling conf servername.
To activate the new configuration, you need to run:
Systemctl reload apache2
Step 4: test whether Apache provides services for your domain name
The Apache server is now configured to provide your domain name. This can be verified by entering your server name in any Web browser running on the system:
Http://www.linuxidc.com
The index page should appear as follows, indicating that Apache is now ready to serve your server block!
Access your website through the domain name
Chinese garbled code:
Then restart apache2
Linuxidc@linuxidc:~$ sudo systemctl restart apache2
Open it again, OK, and the Chinese web page garbled is solved.
Some common Apache management commands
After setting up the Web server, you may have to perform some basic administrative operations on the Apache. The following are the commands you can enter for these operations in your terminal application.
Sudo systemctl start apache2 / / use this command as sudo to start the Apache server.
Sudo systemctl stop apache2 / / use this command as a sudo to stop the Apache server while it is in startup mode.
Sudo systemctl restart apache2 / / use this command as a sudo to stop and then start the Apache service again.
Sudo systemctl reload apache2 / / use this command as a sudo to apply configuration changes without restarting the connection.
Sudo systemctl enable apache2 / / use this command as sudo to enable Apache each time you boot the system.
Sudo systemctl disable apache2 / / set Apache to start every time you start the system
Summary
In this article, you learned how to install and configure an Apache Web server on a Ubuntu system. This includes making some changes to your UFW firewall and then configuring the Web server for your IP address. We also recommend that you set up virtual hosts through Apache; this will provide you with the basis for how to use Apache to host files on Internet. Basic Apache management commands can also help you as a Web administrator to manage the Web server in the best way.
That's all for "how to install and configure Apache 2 Web server on Ubuntu 18.04". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 252
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.