Home » Ubuntu
Category Archives: Ubuntu
How to Back Up and Restore a MySQL Database : Easy Tutorial
It is essential to important to make regular backups of all data in case of loss. Has your MySQL database has been lost, and you’re scrambling to restore a copy from your last backup?
In this tutorial, we present two easy ways to back up and restore your MySQL Database.
Prerequisites
- A Linux operating system
- MySQL installed
- An existing database
- Mysqldump utility (should be included with your MySQL software)
Back Up from the Command-Line with mysqldump
The mysqldump client utility can dump a database including the SQL statements required to rebuild the database.
By default, the dump file includes the SQL commands to restore the tables and data.
To back up your MySQL database, the general syntax is:
sudo mysqldump -u [user] -p [database_name] > [filename].sql
- Replace [user] with your username and password (if needed).
- The [database_name] is the path and filename of the database.
- The > command specifies the output.
- [filename] is the path and filename you want to save the dump file as.
Other examples:
To back up of an entire Database Management System:
mysqldump --all-databases --single-transaction --quick --lock-tables=false > full-backup-$(date +%F).sql -u root -p
To include more than one database in the backup dump file:
sudo mysqldump -u [user] -p [database_1] [database_2] [database_etc] > [filename].sql
How to Restore MySQL with mysqldump
Step 1: Create New Database
On the system that hosts the database, use MySQL to create a new database.
Make sure you’ve named it the same as the database you lost. This creates the foundation file that mysqldump will import the data into. Since the dump file has the commands to rebuild the database, you only need to create the empty database.
Step 2: Restore MySQL Dump
To restore a MySQL backup, enter:
mysql -u [user] -p [database_name] < [filename].sql
Make sure to include [database_name] and [filename] in the path.
It’s likely that on the host machine, [database_name] can be in a root directory, so you may not need to add the path. Make sure that you specify the exact path for the dump file you’re restoring, including server name (if needed).
Using phpMyAdmin to Back Up or Restore MySQL
If you’re running phpMyAdmin backing up and restoring your MySQL database is simple.
The export function is used as a backup, and the import function is used to restore.
Step 1: Create a MySQL Database Backup
1. Open phpMyAdmin. On the directory tree on the left, click the database you want to back up.
This should open the directory structure in the right-hand window. You’ll also notice that, in the directory tree on the left, all the assets under the main database are highlighted.
2. Click Export on the menu across the top of the display.
You’ll see a section called “Export Method.” Use Quick to save a copy of the whole database. Choose Custom to select individual tables or other special options.
Leave the Format field set to SQL, unless you have a good reason to change it.
3. Click Go. If you select Quick, your web browser will download a copy of the database into your specified downloads folder. You can copy that to a safe location.
Step 2: Clear the Old Database Information
It’s important to clear out old data before restoring a backup. If there’s any old data, it isn’t overwritten when you restore. This can create duplicate tables, causing errors and conflicts.
1. Open phpMyAdmin, on the navigation pane on the left, choose the database you want to restore.
2. Click the check all box near the bottom. Then, use the drop-down menu labeled With selected to select Drop.
3. The tool should prompt you to confirm that you want to go forward. Click yes.
This will get rid of all the existing data, clearing the way for your restoration.
Step 3: Restore Your Backed up MySQL Database
In phpMyAdmin, the Import tool is used to restore a database.
1. On the menu across the top, click Import.
2. The first section is labeled File to import. A couple of lines down, there’s a line that starts with “Browse your computer,” with a button labeled Choose File. Click that button.
3. Use the dialog box to navigate to the location where you’ve saved the export file that you want to restore. Leave all the options set to default. (If you created your backup with different options, you can select those here.)
4. Click Go.
Also read : How To Install Linux, Nginx, MySQL, PHP (LEMP stack) on Ubuntu
How to disable keyring password in Ubuntu 22.04 / Ubuntu 20.04
Disable/Remove keyring password in Ubuntu 22.04 or Ubuntu 20.04
In cases where you want to use automatic login but don’t want to unlock keyring manually, you may choose to disable the keyring with a workaround. Keep in mind that you are disabling a security feature so think twice before doing so.
Gnome keyring auto unlock
The process is similar to changing keyring password. Open Password and Keys application and go on to change the keyring password.
The trick is that when it asks to change the password, don’t enter a new password and hit Continue instead. This will remove any password from the keyring.
This way, the keyring will have no password and it remains unlocked all the time.
Also read : How to Use Keyring in Ubuntu
How to Change keyring password in Ubuntu 22.04 / 20.04
Change keyring password in Ubuntu 22.04 or Debian
Suppose you changed your account password. Now when you login, your system tries to unlock the keyring automatically using the new login password. But the keyring still uses the old login password.
In such a case, you can change the keyring password to the new login password so that the keyring gets unlocked automatically as soon as you login to your system.
Keyring password change – Steps for Ubuntu / Debian based systems
Open the Password and Keys application from the menu:
Look for Password and Keys app in the menu
Now, right click on the Login keyring and click on Change Password:
Change Keyring Password
What if you don’t remember the old login password?
You probably know that it is easy to reset forgotten password in Ubuntu. The problem comes with the keyring in such cases. You changed the account password but you don’t remember the old account password that is still used by the keyring.
Now you cannot change it because you don’t know the old password. What to do now?
In such a case, you’ll have to remove the entire keyring itself. You can do that from the Passwords and Keys application:
It will ask for your confirmation:
Alternatively, you may also manually delete the keyring files in ~/.local/share/keyrings directory.
When the old keyring is removed and you try to use Chrome/Chromium, it will ask you to create new keyring.
You can use the new login password so that the keyring gets unlocked automatically.
Also read:
How to Use Keyring in Ubuntu
If you use automatic login in Ubuntu or other Linux distributions, you might have come across a pop-up message of this sort:
Enter password to unlock your login keyring
The login keyring did not get unlocked when you logged into your computer.
It keeps on popping up several times before disappearing if you keep on clicking cancel. You may wonder why do you keep seeing this keyring message all the time?
Let me tell you something. It’s not an error. It’s a security feature.
Surprised? Let me explain the keyring concept in Linux.
What is keyring in Linux and why is it used?
Why do you use a keyring (also called keychain) in the real life? You use it to keep one or more keys grouped together so that they are easy to find and carry.
It’s the same concept in Linux. The keyring feature allows your system to group various passwords together and keep it one place.
Most desktop environments like GNOME, KDE, Xfce etc use an implementation of gnome-keyring to provide this keyring feature in Linux.
This keyring keeps your ssh keys, GPG keys and keys from applications that use this feature, like Chromium browser. By default, the keyring is locked with a master password which is often the login password of the account.
Every user on your system has its own keyring with (usually) the same password as that of the user account itself. When you login to your system with your password, your keyring is unlocked automatically with your account’s password.
The problem comes when you switch to auto-login in Ubuntu. This means that you login to the system without entering the password. In such case, your keyring is not unlocked automatically.
Keyring is a security feature
Remember I told you that the keyring was a security feature? Now imagine that on your Linux desktop, you are using auto-login. Anyone with access to your desktop can enter the system without password but you have no issues with that perhaps because you use it to browse internet only.
But if you use a browser like Chromium or Google Chrome in Ubuntu, and use it to save your login-password for various websites, you have an issue on your hand. Anyone can use the browser and login to the websites for which you have saved password in your browser. That’s risky, isn’t it?
This is why when you try to use Chrome, it will ask you to unlock the keyring repeatedly. This ensures that only the person who knows the keyring’s password (i.e. the account password) can use the saved password in browser for logging in to their respective websites.
If you keep on cancelling the prompt for keyring unlock, it will eventually go away and let you use the browser. However, the saved password won’t be unlocked and you’ll see ‘sync paused’ in Chromium/Chrome browsers.
If this keyring always exited, why you never saw it?
That’s a valid question if you have never seen this keyring thing in your Linux system.
If you never used automatic login (or changed your account’s password), you might not even have realized that this feature exists.
This is because when you login to your system with your password, your keyring is unlocked automatically with your account’s password.
Ubuntu (and other distributions) asks for password for common admin tasks like modifying users, installing new software etc irrespective of whether you auto login or not. But for regular tasks like using a browser, it doesn’t ask for password because keyring is already unlocked.
When you switch to automatic login, you don’t enter the password for login anymore. This means that the keyring is not unlocked and hence when you try to use a browser which uses the keyring feature, it will ask to unlock the keyring.
You can easily manage the keyring and passwords
Where is this keyring located? At the core, it’s a daemon (a program that runs automatically in the background).
Don’t worry. You don’t have to ‘fight the daemon’ in the terminal. Most desktop environments come with a graphical application that interacts with this daemon. On KDE, there is KDE Wallet, on GNOME and others, it’s called Password and Keys (originally known as Seahorse).
You can use this GUI application to see what application use the keyring to manage/lock passwords.
As you can see, my system has the login keyring which is automatically created. There is also a keyrings for storing GPG and SSH keys. The Certificates is for keeping the certificates (like HTTPS certificates) issued by a certificate authority.
You can also use this application to manually store passwords for website. For example, I created a new password-protected keyring called ‘Test’ and stored a password in this keyring manually.
This is slightly better than keeping a list of passwords in a text file. At least in this case your passwords can be viewed only when you unlock the keyring with password.
One potential problem here is that if you format your system, the manually saved passwords are definitely lost. Normally, you make backup of personal files, not of all the user specific data such as keyring files.
There is way to handle that. The keyring data is usually stored in ~/.local/share/keyrings directory. You can see all the keyrings here but you cannot see its content directly. If you remove the password of the keyring (I’ll show the steps in later section of this article), you can read the content of the keyring like a regular text file. You can copy this unlocked keyring file entirely and import it in the Password and Keys application on some other Linux computer (running this application).
So, let me summarize what you have learned so far:
- Most Linux has this ‘keyring feature’ installed and activated by default
- Each user on a system has its own keyring
- The keyring is normally locked with the account’s password
- Keyring is unlocked automatically when you login with your password
- For auto-login, the keyring is not unlocked and hence you are asked to unlock it when you try to use an application that uses keyring
- Not all browsers or application use the keyring feature
- There is a GUI application installed to interact with keyring
- You can use the keyring to manually store passwords in encrypted format
- You can change the keyring password on your own
- You can export (by unlocking the keyring first) and import it on some other computer to get your manually saved passwords
Related Posts
How to Install Apache with PHP-FPM in Ubuntu 20.04 / 18.04
PHP FPM (FastCGI Process Manager) is an alternative implementation of PHP FastCGI. It provides some additional features like Adaptive process spawning which is useful for sites. This tutorial will help you to install Apache with PHP-FPM/FastCGI on Ubuntu 20.04 system. In this tutorial, we are using PHP 7.4 and configure with Apache using PHP-FPM and FastCGI.
Step 1 – Installing Apache
Apache web server debian packages are available under the default repositories. Login to your Ubuntu system with sudo privileges account. Open a terminal. And run the following commands in it :
sudo apt update sudo apt install apache2 libapache2-mod-fcgid
The above commands will install Apache and FastCGI module to your server.
Step 2 – Install PHP with FPM
Next, install PHP and PHP-FPM on your Ubuntu system. For this tutorial, we choose PHP 7.4 to install using
For the PHP installation we recommend to use ppa:ondrej/php PPA. Execute below couple of commands to add the PPA to your system.
sudo apt install software-properties-common sudo add-apt-repository ppa:ondrej/php
Then install PHP 7.4 (or required version) the latest version available on the day of writing this tutorial. Simply execute follows commands for the installation of PHP and PHP-FPM packages.
sudo apt update sudo apt install php7.4 php7.4-fpm
After installing the packages php7.4-fpm service will automatically be started. To make sure, type:
sudo systemctl status php7.4-fpm ● php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php7.4-fpm.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2020-05-09 04:41:44 UTC; 19s ago Docs: man:php-fpm7.4(8) Process: 375077 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/7.4/fpm/pool.d/www.conf 74 (code=exited> Main PID: 375073 (php-fpm7.4) Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec" Tasks: 3 (limit: 2283) Memory: 9.3M CGroup: /system.slice/php7.4-fpm.service ├─375073 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf) ├─375075 php-fpm: pool www └─375076 php-fpm: pool www May 09 04:41:43 tecadmin systemd[1]: Starting The PHP 7.4 FastCGI Process Manager... May 09 04:41:44 tecadmin systemd[1]: Started The PHP 7.4 FastCGI Process Manager.
Step 3 – Apache Configuration
Now, You need to enable some of the Apache modules required for the FastCGI confiugration. You can enable the requird module by running command:
sudo a2enmod actions fcgid alias proxy_fcgi
Then configure Apache Virtual Host to run with FPM/FastCGI. For this tutorial, we use default VirtualHost. Edit VirtualHost host configuration file in a text editor. You can also create a new configuration as per your choice.
sudo vim /etc/apache2/sites-available/000-default.conf
Update the configuration as followings.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html
<Directory /var/www/html>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
<FilesMatch \.php$>
# 2.4.10+ can proxy to unix socket
SetHandler “proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://localhost”
</FilesMatch>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
|
Save your changes to the configuration file and restart Apache to reload the changes.
sudo systemctl restart apache2
Step 4 – Verify Setup
Apache with PHP-FPM configuration has been done. Now all the PHP files will be run with the FPM.
To verify these settigns, create a PHP script with phpinfo() function and place it to your server document root. Use below command to create file:
echo "<?php phpinfo(); ?>" > /var/www/html/info.php
Then access the info.php using server IP address (for default VirtualHost) or your configured domain in Apache VirtualHost.
How To Install Linux, Nginx, MySQL, PHP (LEMP stack)
LEMP installation : Ubuntu 20.04
This guide demonstrates how to install a LEMP stack on an Ubuntu 20.04 server. The Ubuntu operating system takes care of the first requirement. We will describe how to get the rest of the components up and running.
What is LEMP ?
The LEMP software stack serves dynamic web pages and web applications written in PHP. This is an acronym that describes a Linux operating system, with an Nginx (pronounced like “Engine-X”) web server. The MySQL database stores backend data and PHP handles the dynamic processing.
Prerequisites
In order to complete this tutorial, you will need access to an Ubuntu 20.04 server as a regular, non-root sudo
user, and a firewall enabled on your server. To set this up, you can follow our initial server setup guide for Ubuntu 20.04.
Step 1 – Installing the Nginx Web Server
In order to display web pages to our site visitors, we are going to employ Nginx, a high-performance web server. We’ll use the apt
package manager to obtain this software.
Since this is our first time using apt
for this session, start off by updating your server’s package index. Following that, you can use apt install
to get Nginx installed:
When prompted, enter Y
to confirm that you want to install Nginx. The Nginx web server will be active and running on your Ubuntu 20.04 server, after the installation is complete.
If you have the ufw
firewall enabled, as recommended in our initial server setup guide, you will need to allow connections to Nginx. Nginx registers a few different UFW application profiles upon installation. To check which UFW profiles are available, run:
Available applications:
Nginx Full
Nginx HTTP
Nginx HTTPS
OpenSSH
You should enable the most restrictive profile. It will still allow the traffic you need. Since you haven’t configured SSL for your server in this guide, you will only need to allow regular HTTP traffic on port 80
.
Enable this by typing:
You can verify the change by running:
This command’s output will show that HTTP traffic is now allowed:
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Nginx HTTP ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Nginx HTTP (v6) ALLOW Anywhere (v6)
With the new firewall rule added, you can test if the server is up and running by accessing your server’s domain name or public IP address in your web browser.
If you do not have a domain name pointed at your server and you do not know your server’s public IP address, you can find it by running the following command:
This will print out a few IP addresses. You can try each of them in turn in your web browser.
As an alternative, you can check which IP address is accessible, as viewed from other locations on the internet:
Type the address that you receive in your web browser and it will take you to Nginx’s default landing page:
http://server_domain_or_IP
If you see this page, it means you have successfully installed Nginx and enabled HTTP traffic for your web server.
Step 2 — Installing MySQL
Now that you have a web server up and running, you need to install the database system to be able to store and manage data for your site. MySQL is a popular database management system used within PHP environments.
Again, use apt
to acquire and install this software:
When prompted, confirm installation by typing Y
, and then 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 down access to your database system. Start the interactive script by running:
This will 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 match the specified criteria will be rejected by MySQL with an error. It is safe to leave validation disabled, but you should always use strong, unique passwords for database credentials.
Answer Y
for yes, or anything 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 only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No:
If you answer “yes”, you’ll be asked to select a level of password validation. Keep in mind that if you enter 2
for the strongest level, you will receive errors when attempting to set any password which does not contain numbers, upper and lowercase letters, and special characters, or which is based on common dictionary words.
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
Regardless of whether you chose to set up the VALIDATE PASSWORD PLUGIN
, your server will next ask you to select and confirm a password for the MySQL root user. This is not to be confused with the system root. The database root user is an administrative user with full privileges over the database system. Even though the default authentication method for the MySQL root user dispenses the use of a password, even when one is set, you should define a strong password here as an additional safety measure. We’ll talk about this in a moment.
If you enabled password validation, you’ll be shown the password strength for the root password you just entered and your server will ask if you want to continue with that password. If you are happy with your current password, enter Y
for “yes” at the prompt:
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
For the rest of the questions, press Y
and hit 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 so that MySQL immediately respects the changes you have made.
When you’re finished, test if you’re able to log in to the MySQL console by typing:
This will connect to the MySQL server as the administrative database user root, which is inferred by the use of sudo
when running this command. You should see output like this:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 8.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 respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
To exit the MySQL console, type:
Notice that you didn’t need to provide a password to connect as the root user, even though you 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 look like a security concern at first, it makes the database server more secure because the only users allowed to log in as the root MySQL user are the system users with sudo privileges connecting from the console or through an application running with the same privileges. In practical terms, that means you won’t be able to use the administrative database root user to connect from your PHP application. Setting a password for the root MySQL account works as a safeguard, in case the default authentication method is changed from unix_socket
to password
.
For increased security, it’s 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.
Note: 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’ll need to make sure they’re configured to use mysql_native_password
instead. We’ll demonstrate how to do that in Step 6.
Your MySQL server is now installed and secured. Next, we’ll install PHP, the final component in the LEMP stack.
Step 3 – Installing PHP
You have Nginx installed to serve your content and MySQL installed to store and manage your data. Now you can install PHP to process code and generate dynamic content for the web server.
While Apache embeds the PHP interpreter in each request, Nginx requires an external program to handle PHP processing and act as a bridge between the PHP interpreter itself and the web server. This allows for a better overall performance in most PHP-based websites, but it requires additional configuration. You’ll need to install php-fpm
, which stands for “PHP fastCGI process manager”, and tell Nginx to pass PHP requests to this software for processing. Additionally, you’ll need php-mysql
, a PHP module that allows PHP to communicate with MySQL-based databases. Core PHP packages will automatically be installed as dependencies.
To install the php-fpm
and php-mysql
packages, run:
When prompted, type Y
and ENTER
to confirm installation.
You now have your PHP components installed. Next, you’ll configure Nginx to use them.
Step 4 — Configuring Nginx to Use the PHP Processor
When using the Nginx web server, we can create server blocks (similar to virtual hosts in Apache) to encapsulate configuration details and host more than one domain on a single server. In this guide, we’ll use your_domain as an example domain name. To learn more about setting up a domain name with DigitalOcean, see our introduction to DigitalOcean DNS.
On Ubuntu 20.04, Nginx has one server block enabled by default and is configured to serve documents out of a directory at /var/www/html
. While this works well for a single site, it can become difficult to manage if you are hosting multiple sites. Instead of modifying /var/www/html
, we’ll create a directory structure within /var/www
for the your_domain website, leaving /var/www/html
in place as the default directory to be served if a client request doesn’t match any other sites.
Create the root web directory for your_domain as follows:
Next, assign ownership of the directory with the $USER environment variable, which will reference your current system user:
Then, open a new configuration file in Nginx’s sites-available
directory using your preferred command-line editor. Here, we’ll use nano
:
This will create a new blank file. Paste in the following bare-bones configuration:
Here’s what each of these directives and location blocks do:
listen
— Defines what port Nginx will listen on. In this case, it will listen on port80
, the default port for HTTP.root
— Defines the document root where the files served by this website are stored.index
— Defines in which order Nginx will prioritize index files for this website. It is a common practice to listindex.html
files with a higher precedence thanindex.php
files to allow for quickly setting up a maintenance landing page in PHP applications. You can adjust these settings to better suit your application needs.server_name
— Defines which domain names and/or IP addresses this server block should respond for. Point this directive to your server’s domain name or public IP address.location /
— The first location block includes atry_files
directive, which checks for the existence of files or directories matching a URI request. If Nginx cannot find the appropriate resource, it will return a 404 error.location ~ \.php$
— This location block handles the actual PHP processing by pointing Nginx to thefastcgi-php.conf
configuration file and thephp7.4-fpm.sock
file, which declares what socket is associated withphp-fpm
.location ~ /\.ht
— The last location block deals with.htaccess
files, which Nginx does not process. By adding thedeny all
directive, if any.htaccess
files happen to find their way into the document root ,they will not be served to visitors.
When you’re done editing, save and close the file. If you’re using nano
, you can do so by typing CTRL+X
and then y
and ENTER
to confirm.
Activate your configuration by linking to the config file from Nginx’s sites-enabled
directory:
Then, unlink the default configuration file from the /sites-enabled/
directory:
Note: If you ever need to restore the default configuration, you can do so by recreating the symbolic link, like this:
This will tell Nginx to use the configuration next time it is reloaded. You can test your configuration for syntax errors by typing:
If any errors are reported, go back to your configuration file to review its contents before continuing.
When you are ready, reload Nginx to apply the changes:
Your new website is now active, but the web root /var/www/your_domain
is still empty. Create an index.html
file in that location so that we can test that your new server block works as expected:
Include the following content in this file:
Now go to your browser and access your server’s domain name or IP address, as listed within the server_name
directive in your server block configuration file:
http://server_domain_or_IP
You’ll see a page like this:
If you see this page, it means your Nginx server block is working as expected.
You can leave this file in place as a temporary landing page for your application until you set up an index.php
file to replace it. Once you do that, remember to remove or rename the index.html
file from your document root, as it would take precedence over an index.php
file by default.
Your LEMP stack is now fully configured. In the next step, we’ll create a PHP script to test that Nginx is in fact able to handle .php
files within your newly configured website.
Step 5 –Testing PHP with Nginx
Your LEMP stack should now be completely set up. You can test it to validate that Nginx can correctly hand .php
files off to your PHP processor.
You can do this by creating a test PHP file in your document root. Open a new file called info.php
within your document root in your text editor:
Type or paste the following lines into the new file. This is valid PHP code that will return information about your server:
When you are finished, save and close the file by typing CTRL
+X
and then y
and ENTER
to confirm.
You can now access this page in your web browser by visiting the domain name or public IP address you’ve set up in your Nginx configuration file, followed by /info.php
:
http://server_domain_or_IP/info.php
You will see a web page containing detailed information about your server.
Also read : How to Back Up and Restore a MySQL Database