Skip to content Skip to sidebar Skip to footer

Deluge Baconbits org Error Host Not Found Non authoritative Try Again Later

Introduction

A "LAMP" stack is a grouping of open source software that is typically installed together in social club to enable a server to host dynamic websites and spider web apps written in PHP. This term is an acronym which represents the Linux operating organization, with the Apache spider web server. The site data is stored in a One thousandySQL database, and dynamic content is processed by PHP.

In this guide, yous'll gear up a LAMP stack on an Ubuntu 20.04 server.

Prerequisites

In order to complete this tutorial, you will need to take an Ubuntu 20.04 server with a not-root sudo-enabled user account and a basic firewall. This can be configured using our initial server setup guide for Ubuntu twenty.04.

Step 1 — Installing Apache and Updating the Firewall

The Apache spider web server is among the most popular web servers in the globe. It's well documented, has an agile community of users, and has been in wide use for much of the history of the web, which makes it a corking choice for hosting a website.

Start by updating the package managing director cache. If this is the kickoff time yous're using sudo inside this session, you'll be prompted to provide your user'due south password to confirm you accept the right privileges to manage system packages with apt.

                      
  1. sudo apt update

Then, install Apache with:

                      
  1. sudo apt install apache2

You'll also exist prompted to confirm Apache's installation past pressing Y, then ENTER.

Once the installation is finished, y'all'll need to adjust your firewall settings to allow HTTP traffic. UFW has different application profiles that yous can leverage for accomplishing that. To list all currently bachelor UFW application profiles, you can run:

                      
  1. sudo ufw app list

You'll see output like this:

                      

Output

Available applications: Apache Apache Total Apache Secure OpenSSH

Hither's what each of these profiles mean:

  • Apache: This contour opens but port 80 (normal, unencrypted web traffic).
  • Apache Full: This profile opens both port eighty (normal, unencrypted spider web traffic) and port 443 (TLS/SSL encrypted traffic).
  • Apache Secure: This profile opens but port 443 (TLS/SSL encrypted traffic).

For now, it'south best to permit just connections on port 80, since this is a fresh Apache installation and yous withal don't have a TLS/SSL certificate configured to allow for HTTPS traffic on your server.

To simply permit traffic on port fourscore, use the Apache profile:

                      
  1. sudo ufw permit in "Apache"

You can verify the change with:

                      
  1. sudo ufw status
                      

Output

Status: active To Action From -- ------ ---- OpenSSH ALLOW Anywhere Apache ALLOW Anywhere OpenSSH (v6) Let Anywhere (v6) Apache (v6) Allow Anywhere (v6)

Traffic on port fourscore is now immune through the firewall.

You can do a spot check right away to verify that everything went as planned by visiting your server's public IP accost in your web browser (see the note under the next heading to discover out what your public IP address is if you do not have this data already):

          http://your_server_ip                  

You'll come across the default Ubuntu 20.04 Apache spider web folio, which is at that place for advisory and testing purposes. It should look something like this:

Ubuntu 20.04 Apache default

If you see this folio, and so your spider web server is at present correctly installed and attainable through your firewall.

How To Find your Server's Public IP Address

If yous practice not know what your server's public IP address is, at that place are a number of means y'all can observe it. Usually, this is the address yous utilise to connect to your server through SSH.

There are a few different ways to do this from the control line. Start, you could utilise the iproute2 tools to get your IP accost by typing this:

                      
  1. ip addr bear witness eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

This volition give you two or three lines back. They are all correct addresses, but your figurer may only be able to use one of them, so experience gratuitous to try each ane.

An culling method is to utilise the curl utility to contact an outside political party to tell you how information technology sees your server. This is done by asking a specific server what your IP address is:

                      
  1. coil http://icanhazip.com

Regardless of the method yous use to become your IP address, type information technology into your spider web browser'due south address bar to view the default Apache page.

Step 2 — Installing MySQL

Now that yous have a spider web server up and running, yous need to install the database system to be able to store and manage data for your site. MySQL is a popular database management organization used within PHP environments.

Again, use apt to learn and install this software:

                      
  1. sudo apt install mysql-server

When prompted, ostend installation by typing Y, and so ENTER.

When the installation is finished, it's recommended that you run a security script that comes pre-installed with MySQL. This script will remove some insecure default settings and lock downward access to your database arrangement. Start the interactive script past running:

                      
  1. sudo mysql_secure_installation

This volition ask if you want to configure the VALIDATE PASSWORD PLUGIN.

Note: Enabling this feature is something of a judgment call. If enabled, passwords which don't friction match the specified criteria volition exist rejected past MySQL with an error. It is rubber to get out validation disabled, but you should ever use potent, unique passwords for database credentials.

Reply Y for yes, or annihilation else to continue without enabling.

          VALIDATE Password PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set just those passwords which are secure enough. Would you like to setup VALIDATE Password plugin?  Press y|Y for Aye, any other key for No:                  

If you answer "yeah", you'll be asked to select a level of password validation. Continue in listen that if you enter 2 for the strongest level, you will receive errors when attempting to ready any password which does not contain numbers, upper and lowercase letters, and special characters, or which is based on mutual lexicon words.

          In that location are three levels of password validation policy:  LOW    Length >= eight MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary              file  Delight enter 0 = Low, one = MEDIUM and 2 = STRONG:            1                  

Regardless of whether you chose to set upward the VALIDATE PASSWORD PLUGIN, your server will adjacent inquire y'all to select and ostend a password for the MySQL root user. This is not to exist confused with the system root. The database root user is an authoritative user with full privileges over the database organization. Even though the default authentication method for the MySQL root user dispenses the use of a password, even when 1 is set, you should define a strong password here as an additional rubber measure. We'll talk near this in a moment.

If you lot enabled password validation, you'll be shown the password strength for the root countersign you simply entered and your server will enquire if y'all desire to continue with that countersign. If y'all are happy with your current password, enter Y for "yes" at the prompt:

          Estimated strength of the password:            100            Do y'all wish to go on with the password provided?(Press y|Y for Yep, any other key for No) :            y                  

For the rest of the questions, press Y and striking the ENTER key at each prompt. This will remove some anonymous users and the test database, disable remote root logins, and load these new rules and so that MySQL immediately respects the changes you have made.

When yous're finished, exam if you're able to log in to the MySQL console past typing:

                      
  1. sudo mysql

This will connect to the MySQL server as the authoritative database user root, which is inferred by the use of sudo when running this command. You should see output similar this:

                      

Output

Welcome to the MySQL monitor. Commands cease with ; or \g. Your MySQL connection id is 22 Server version: viii.0.19-0ubuntu5 (Ubuntu) Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their corresponding owners. Type 'assist;' or '\h' for help. Type '\c' to clear the electric current input statement. mysql>

To exit the MySQL console, type:

                      
  1. go out

Notice that you didn't demand to provide a password to connect every bit the root user, even though yous have defined one when running the mysql_secure_installation script. That is because the default authentication method for the administrative MySQL user is unix_socket instead of password. Even though this might await similar a security business concern at first, information technology makes the database server more than secure considering the simply users allowed to log in every bit the root MySQL user are the system users with sudo privileges connecting from the panel or through an awarding running with the same privileges. In practical terms, that means you won't exist able to use the administrative database root user to connect from your PHP application. Setting a countersign for the root MySQL account works equally a safeguard, in case the default hallmark method is changed from unix_socket to password.

For increased security, information technology'south best to have dedicated user accounts with less expansive privileges set up for every database, especially if you plan on having multiple databases hosted on your server.

Annotation: At the time of this writing, the native MySQL PHP library mysqlnd doesn't support caching_sha2_authentication, the default authentication method for MySQL 8. For that reason, when creating database users for PHP applications on MySQL 8, you lot'll demand to make sure they're configured to utilise mysql_native_password instead. We'll demonstrate how to practice that in Step 6.

Your MySQL server is at present installed and secured. Side by side, we'll install PHP, the final component in the LAMP stack.

Step iii — Installing PHP

Yous have Apache installed to serve your content and MySQL installed to store and manage your data. PHP is the component of our setup that will process code to display dynamic content to the final user. In addition to the php package, you'll demand php-mysql, a PHP module that allows PHP to communicate with MySQL-based databases. You'll too need libapache2-modernistic-php to enable Apache to handle PHP files. Core PHP packages will automatically be installed as dependencies.

To install these packages, run:

                      
  1. sudo apt install php libapache2-mod-php php-mysql

One time the installation is finished, you tin can run the following command to ostend your PHP version:

                      
  1. php -5
                      

Output

PHP 7.4.iii (cli) (built: Jul 5 2022 15:13:35) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

At this signal, your LAMP stack is fully operational, but before you tin test your setup with a PHP script, it's best to set up a proper Apache Virtual Host to concur your website'southward files and folders. We'll practise that in the next step.

Pace 4 — Creating a Virtual Host for your Website

When using the Apache spider web server, you tin can create virtual hosts (similar to server blocks in Nginx) to encapsulate configuration details and host more than ane domain from a single server. In this guide, we'll fix a domain chosen your_domain, simply you should supervene upon this with your own domain name.

Note: In instance you are using DigitalOcean equally DNS hosting provider, you can check our product docs for detailed instructions on how to prepare up a new domain name and signal it to your server.

Apache on Ubuntu twenty.04 has one server block enabled past default that is configured to serve documents from the /var/www/html directory. While this works well for a single site, it can become unwieldy if yous are hosting multiple sites. Instead of modifying /var/www/html, we'll create a directory structure within /var/www for the your_domain site, leaving /var/world wide web/html in place as the default directory to exist served if a customer request doesn't friction match whatever other sites.

Create the directory for your_domain as follows:

                      
  1. sudo mkdir /var/www/your_domain

Next, assign ownership of the directory with the $USER surround variable, which will reference your current organization user:

                      
  1. sudo chown -R $USER : $USER /var/www/your_domain

Then, open a new configuration file in Apache's sites-available directory using your preferred command-line editor. Here, we'll use nano:

                      
  1. sudo nano /etc/apache2/sites-available/your_domain.conf

This volition create a new bare file. Paste in the following bare-bones configuration:

/etc/apache2/sites-bachelor/your_domain.conf

          <VirtualHost *:80>     ServerName            your_domain            ServerAlias www.your_domain            ServerAdmin webmaster@localhost     DocumentRoot /var/world wide web/your_domain            ErrorLog ${APACHE_LOG_DIR}/error.log     CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>                  

Save and close the file when you're washed. If you're using nano, you can do that by pressing CTRL+Ten, and then Y and ENTER.

With this VirtualHost configuration, we're telling Apache to serve your_domain using /var/www/your_domain as the web root directory. If yous'd like to exam Apache without a domain name, you can remove or annotate out the options ServerName and ServerAlias by adding a # character in the beginning of each option'south lines.

You lot can now use a2ensite to enable the new virtual host:

                      
  1. sudo a2ensite your_domain

You lot might want to disable the default website that comes installed with Apache. This is required if you're not using a custom domain name, because in this instance Apache'south default configuration would overwrite your virtual host. To disable Apache's default website, type:

                      
  1. sudo a2dissite 000-default

To make sure your configuration file doesn't contain syntax errors, run:

                      
  1. sudo apache2ctl configtest

Finally, reload Apache so these changes accept issue:

                      
  1. sudo systemctl reload apache2

Your new website is now agile, merely the web root /var/www/your_domain is still empty. Create an index.html file in that location so that we can exam that the virtual host works as expected:

                      
  1. nano /var/world wide web/your_domain/index.html

Include the following content in this file:

/var/world wide web/your_domain/index.html

          <html>   <head>     <championship>your_domain            website</title>   </head>   <trunk>     <h1>Hi World!</h1>      <p>This is the landing page of <strong>your_domain</strong>.</p>   </torso> </html>                  

Now get to your browser and access your server'due south domain name or IP address one time over again:

          http://server_domain_or_IP                  

You'll see a folio like this:

Apache virtual host test

If yous see this page, it ways your Apache virtual host is working as expected.

You tin leave this file in place as a temporary landing page for your awarding until you fix upwards an index.php file to replace it. Once y'all do that, call up to remove or rename the alphabetize.html file from your document root, every bit it would take precedence over an index.php file past default.

A Note Virtually DirectoryIndex on Apache

With the default DirectoryIndex settings on Apache, a file named index.html will always take precedence over an alphabetize.php file. This is useful for setting upwardly maintenance pages in PHP applications, by creating a temporary index.html file containing an informative message to visitors. Because this page will take precedence over the index.php page, it will then become the landing page for the application. Once maintenance is over, the index.html is renamed or removed from the document root, bringing back the regular application page.

In case you want to change this behavior, you'll need to edit the /etc/apache2/mods-enabled/dir.conf file and change the society in which the index.php file is listed within the DirectoryIndex directive:

                      
  1. sudo nano /etc/apache2/mods-enabled/dir.conf

/etc/apache2/mods-enabled/dir.conf

          <IfModule mod_dir.c>         DirectoryIndex            index.php            index.html index.cgi alphabetize.pl index.xhtml alphabetize.htm </IfModule>                  

After saving and endmost the file, you'll demand to reload Apache so the changes accept issue:

                      
  1. sudo systemctl reload apache2

In the next step, nosotros'll create a PHP script to test that PHP is correctly installed and configured on your server.

Step 5 — Testing PHP Processing on your Web Server

Now that yous have a custom location to host your website's files and folders, we'll create a PHP examination script to ostend that Apache is able to handle and procedure requests for PHP files.

Create a new file named info.php within your custom spider web root folder:

                      
  1. nano /var/www/your_domain/info.php

This will open up a blank file. Add together the following text, which is valid PHP code, inside the file:

/var/www/your_domain/info.php

                                    <?php              phpinfo              (              )              ;                              

When you are finished, save and close the file.

To test this script, go to your web browser and admission your server's domain name or IP accost, followed past the script name, which in this instance is info.php:

          http://server_domain_or_IP/info.php                  

Y'all'll run into a page similar to this:

Ubuntu 20.04 PHP info

This page provides data about your server from the perspective of PHP. It is useful for debugging and to ensure that your settings are being applied correctly.

If y'all can see this page in your browser, and so your PHP installation is working equally expected.

After checking the relevant information about your PHP server through that folio, it's best to remove the file you lot created every bit it contains sensitive information about your PHP environment and your Ubuntu server. You can use rm to practice then:

                      
  1. sudo rm /var/world wide web/your_domain/info.php

You tin can always recreate this page if yous need to access the data again subsequently.

Pace 6 — Testing Database Connection from PHP (Optional)

If you want to examination whether PHP is able to connect to MySQL and execute database queries, you lot can create a exam table with dummy information and query for its contents from a PHP script. Before we can do that, we demand to create a test database and a new MySQL user properly configured to access information technology.

At the time of this writing, the native MySQL PHP library mysqlnd doesn't support caching_sha2_authentication, the default authentication method for MySQL viii. We'll need to create a new user with the mysql_native_password authentication method in order to be able to connect to the MySQL database from PHP.

We'll create a database named example_database and a user named example_user, simply you can replace these names with different values.

Kickoff, connect to the MySQL console using the root account:

                      
  1. sudo mysql

To create a new database, run the following command from your MySQL console:

                      
  1. CREATE DATABASE example_database ;

Now you tin can create a new user and grant them full privileges on the custom database you lot've only created.

The following command creates a new user named example_user , using mysql_native_password as default authentication method. Nosotros're defining this user'south password as countersign , but you should replace this value with a secure password of your own choosing.

                      
  1. CREATE USER 'example_user'@'%' IDENTIFIED WITH mysql_native_password BY 'countersign' ;

Now we need to give this user permission over the example_database database:

                      
  1. GRANT ALL ON example_database.* TO 'example_user'@'%' ;

This will requite the example_user user total privileges over the example_database database, while preventing this user from creating or modifying other databases on your server.

Now exit the MySQL shell with:

                      
  1. exit

You tin exam if the new user has the proper permissions by logging in to the MySQL console again, this time using the custom user credentials:

                      
  1. mysql -u example_user -p

Detect the -p flag in this command, which will prompt you for the password used when creating the example_user user. After logging in to the MySQL console, confirm that you have admission to the example_database database:

                      
  1. Testify DATABASES;

This will give yous the post-obit output:

                      

Output

+--------------------+ | Database | +--------------------+ | example_database | | information_schema | +--------------------+ 2 rows in set (0.000 sec)

Side by side, nosotros'll create a test table named todo_list. From the MySQL panel, run the post-obit argument:

                      
  1. CREATE TABLE example_database.todo_list (
  2. item_id INT AUTO_INCREMENT,
  3. content VARCHAR( 255 ),
  4. PRIMARY KEY(item_id)
  5. ) ;

Insert a few rows of content in the test table. You might want to repeat the next command a few times, using dissimilar values:

                      
  1. INSERT INTO example_database.todo_list (content) VALUES ( "My kickoff of import particular" ) ;

To confirm that the data was successfully saved to your table, run:

                      
  1. SELECT * FROM example_database.todo_list ;

You'll encounter the following output:

                      

Output

+---------+--------------------------+ | item_id | content | +---------+--------------------------+ | 1 | My first important item | | 2 | My second important item | | 3 | My third of import item | | 4 | and this i more thing | +---------+--------------------------+ iv rows in set (0.000 sec)

Afterward confirming that you take valid data in your test table, you tin leave the MySQL console:

                      
  1. go out

Now y'all can create the PHP script that will connect to MySQL and query for your content. Create a new PHP file in your custom spider web root directory using your preferred editor. We'll use nano for that:

                      
  1. nano /var/world wide web/your_domain/todo_list.php

The post-obit PHP script connects to the MySQL database and queries for the content of the todo_list table, exhibiting the results in a list. If there'south a trouble with the database connexion, information technology will throw an exception. Copy this content into your todo_list.php script:

/var/www/your_domain/todo_list.php

                                    <?php              $user              =              "example_user"              ;              $countersign              =              "countersign"              ;              $database              =              "example_database"              ;              $tabular array              =              "todo_list"              ;              endeavor              {              $db              =              new              PDO              (              "mysql:host=localhost;dbname=                  $database                "              ,              $user              ,              $password              )              ;              echo              "<h2>TODO</h2><ol>"              ;              foreach              (              $db              ->              query              (              "SELECT content FROM                                  $table                "              )              every bit              $row              )              {              echo              "<li>"              .              $row              [              'content'              ]              .              "</li>"              ;              }              echo              "</ol>"              ;              }              catch              (              PDOException              $e              )              {              print              "Mistake!: "              .              $due east              ->              getMessage              (              )              .              "<br/>"              ;              die              (              )              ;              }                              

Save and close the file when you're washed editing.

You can at present admission this page in your web browser past visiting the domain name or public IP address configured for your website, followed by /todo_list.php:

          http://your_domain_or_IP/todo_list.php                  

You should see a folio like this, showing the content yous've inserted in your examination table:

Example PHP todo list

That means your PHP environs is ready to connect and interact with your MySQL server.

Conclusion

In this guide, we've built a flexible foundation for serving PHP websites and applications to your visitors, using Apache as web server and MySQL every bit database arrangement.

As an immediate side by side step, y'all should ensure that connections to your web server are secured, by serving them via HTTPS. In guild to attain that, you lot can use Allow's Encrypt to secure your site with a costless TLS/SSL certificate.

darnelldound1953.blogspot.com

Source: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-20-04

Post a Comment for "Deluge Baconbits org Error Host Not Found Non authoritative Try Again Later"