Install Php Nginx Mysql Ubuntu 18.04
What is PHP, Nginx, and MySQL
PHP is a popular and powerful scripting language that can be used to create dynamic web pages, web applications, and websites. It is an essential web development language because it is easy to learn and is widely used on the web. Nginx is a web server software that is used for hosting websites, web applications and other servers. MySQL is a database management system used to store data securely and efficiently.
The installation of PHP, Nginx, and MySQL on Ubuntu 18.04 is an easy task that can be done in a few steps. In this tutorial, we will learn how to install PHP, Nginx, and MySQL on Ubuntu 18.04. We will also cover how to configure the server and test the installation to make sure that it is working properly.
Prerequisites
Before you start with this tutorial, make sure that you have the following requirements:
- A working installation of Ubuntu 18.04.
- A non-root user with sudo privileges configured.
- A basic understanding of Linux commands.
Step 1 – Update System Packages
Before we start the installation of PHP, Nginx and MySQL on Ubuntu 18.04, it is a good idea to update system packages to their latest versions. To do this, run the following command as a sudo user:
sudo apt-get update && sudo apt-get upgrade
Step 2 – Install PHP
To install PHP on Ubuntu 18.04 we first need to install some required packages. We can do this by running the following command:
sudo apt-get install php7.2-cli php7.2-fpm libapache2-mod-php7.2
This command will install version 7.2 of PHP, which is the latest stable version available at the time of writing. After the installation is complete, we need to enable some additional PHP modules. To do this, run the following command:
sudo apt-get install php7.2-mysql php7.2-common php7.2-json php7.2-opcache php7.2-readline php7.2-mbstring php7.2-xml
After the installation is complete, we need to restart the PHP-FPM service in order for the changes to take effect. To do this, run the following command:
sudo systemctl restart php7.2-fpm
Step 3 – Install Nginx
The Nginx web server can be installed by running the following command:
sudo apt-get install nginx
After the installation is complete, we need to configure Nginx to use PHP-FPM as its PHP processor. To do this, we need to edit the default configuration file. To do this, run the following command:
sudo nano /etc/nginx/sites-available/default
When the configuration file is open, add the following directives inside the location block:
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
Save the changes and exit the editor. Next, we need to restart the Nginx service in order for the changes to take effect. To do this, run the following command:
sudo systemctl restart nginx
Step 4 – Install MySQL
To install MySQL, we can use the APT package manager. To do this, run the following command:
sudo apt-get install mysql-server
After the installation is complete, we need to create a new MySQL user. To do this, run the following command:
mysql -u root -p
When prompted, enter the root password. This will open the MySQL prompt. To create a new user, run the following command from the prompt:
GRANT ALL PRIVILEGES ON *.* TO 'new_user'@'localhost' IDENTIFIED BY 'new_user_password';
This command will create a user named new_user and grant all privileges to the user. Finally, run the following command to save the changes:
FLUSH PRIVILEGES;
EXIT;
Step 5 – Testing the Installation
To test the installation and make sure that everything works properly, we can create a basic PHP script. To do this, we need to create a new file in the /var/www/html directory. To do this, run the following command:
sudo nano /var/www/html/phpinfo.php
When the file is opened, add the following lines:
phpinfo();
?>
Save the changes and exit the editor. To test the script, open your browser and go to http://localhost/phpinfo.php. You should see a page with detailed information about your PHP installation. If the page displays properly, then the installation was successful.
Conclusion
In this tutorial, we learned how to install PHP, Nginx, and MySQL on Ubuntu 18.04. We also learned how to configure the server and test it to make sure that it is working properly. If you have any questions or suggestions, please leave a comment below.
FAQs
- How can I install PHP on Ubuntu 18.04?
To install PHP on Ubuntu 18.04, you can use the APT package manager. To do this, run the following command: sudo apt-get install php7.2-cli php7.2-fpm libapache2-mod-php7.2
. After the installation is complete, you need to enable some additional PHP modules. To do this, run the command sudo apt-get install php7.2-mysql php7.2-common php7.2-json php7.2-opcache php7.2-readline php7.2-mbstring php7.2-xml
. Then, restart the PHP-FPM service in order for the changes to take effect.
- How can I install Nginx on Ubuntu 18.04?
To install Nginx on Ubuntu 18.04, you can use the APT package manager. To do this, run the following command: sudo apt-get install nginx
. After the installation is complete, you need to configure Nginx to use PHP-FPM as its PHP processor. To do this, edit the default configuration file and add the following directives inside the location block: location ~ .php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; }
. Then, restart the Nginx service in order for the changes to take effect.
- How can I install MySQL on Ubuntu 18.04?
To install MySQL on
Related Posts:
- Ubuntu 18.04 Letsencrypt Nginx Ubuntu 18.04 Letsencrypt Nginx What is Ubuntu and Why is it Used for Nginx? Ubuntu is a Linux-based operating system designed for open-source use. It is regularly updated, secure, and…
- Setting Php Nginx Ubuntu Vps Setting Up a PHP, Nginx, and Ubuntu VPS What is a VPS? A Virtual Private Server (VPS) is a type of virtualized hosting. It works in the same way as…
- Cara Agar Mysql Diakses Hanya Menggunakan Ip Tertentu Nginx Cara Agar Mysql Diakses Hanya Menggunakan IP Tertentu - Nginx Apa itu Nginx? Nginx adalah salah satu server web populer di seluruh dunia. Nginx telah menjadi pilihan yang populer di…
- Bash Install Nginx On Ubuntu How To Install Nginx On Ubuntu What is Nginx? Nginx is a web server that is gaining popularity in the world of web hosting. Nginx is an open source web…
- How To Login Phpmyadmin In Nginx Server Ubuntu How To Login Phpmyadmin In Nginx Server Ubuntu What is Nginx & phpMyAdmin Nginx is a web server software that is commonly used on Linux-based systems, though it works on…
- How To Install Phpmyadmin In Ubuntu 18.04 Nginx How To Install Phpmyadmin In Ubuntu 18.04 Nginx Introduction The MySQL database management system is one of the most popular and powerful open source database systems available today. To make…
- Install Pdo_Mysql Ubuntu Nginx Install Pdo_Mysql Ubuntu Nginx What is Pdo_Mysql? PDO_Mysql is a driver for the PHP Data Objects (PDO) extension that provides a database abstraction layer for working with MySQL databases.PDO_Mysql provides…
- Docker Compose Nginx Node Js Mysql Docker Compose Nginx Node Js Mysql What is Docker Compose? Docker Compose is a utility used to deploy and manage applications created with multiple services (or containers) in a single…
- Connecting Nginx To Smtp Server Php Connecting Nginx To Smtp Server Php What is Nginx? Nginx is an open-source, high-performance web server used for hosting websites and web applications. It is designed for low resource consumption…
- Debian Install Nginx Php Mysql Phpmyadmin On Debian 9 Debian Install Nginx Php Mysql PhpMyAdmin On Debian 9 What Is Debian 9? Debian 9 (codenamed “stretch”) is the most recent stable version released by the Debian project, the developers…
- Digital Ocean Ubuntu Server Nginx Docker Digital Ocean Ubuntu Server Nginx Docker Understanding Digital Ocean Digital Ocean is a cloud service provider that focuses on simplifying web infrastructure for cloud developers. They offer a platform where…
- Linux Nginx Mysql Php Lemp Linux Nginx Mysql Php Lemp What is Linux, Nginx, MySQL, PHP (LEMP)? Linux, Nginx, MySQL, PHP (LEMP) is a software stack combination of Linux, Nginx, MySQL, and PHP, commonly referred…
- Install Phpmyadmin On Nginx Ubuntu Install Phpmyadmin On Nginx Ubuntu What Is Phpmyadmin? Phpmyadmin is a free, open source web application written in PHP specifically designed to help manage MySQL databases. It is a powerful…
- Available Application Apache And Nginx Available Application Apache And Nginx What is Apache? Apache is a web server software that allows users to store and deliver web content quickly and efficiently. Apache was created in…
- Install Nginx Php Mysql Phpmyadmin Centos 7 Install Nginx Php Mysql Phpmyadmin Centos 7 A Brief Overview of Centos 7 Centos 7 is a Linux distribution based on the Redhat Enterprise Linux Server, and is a popular…
- Install Mysql Pada Nginx Pada Ubuntu Install Mysql Pada Nginx Pada Ubuntu Overview of Nginx and Its Benefits Nginx is a web server, reverse proxy server, and mail proxy server application that is open-source and available…
- Wordpress Nginx File Not Found Wordpress Nginx File Not Found What is Nginx? Nginx is a powerful open-source web server used to host web content and applications. It is designed to be fast, reliable, and…
- Tutorial Start Nginx Ubuntu Webserver Tutorial Start Nginx Ubuntu Webserver Step 1: Prerequisites Before we start configuring Nginx as a web server on Ubuntu, we need to make sure we have the following prerequisites: A…
- Install Phpmyadmin On Nginx Ubuntu 18.04 Install Phpmyadmin On Nginx Ubuntu 18.04 Introduction PhpMyAdmin is one of the most popular and widely used web-based database management tools available. It is used for administering, managing and maintaining…
- Cara Install Nginx Ubuntu 14.04 Cara Install Nginx Ubuntu 14.04 Step 1: Update the Software Packages The first step in installing Nginx is to update the software packages in Ubuntu 14.04. This can be done…
- Add Root Password Mysql Nginx Ubuntu 16.04 Add Root Password Mysql Nginx Ubuntu 16.04 What is a root password? In the context of computer security, a root password is a user account that is given access to…
- How To Install Cachet Nginx How To Install Cachet Nginx Overview Cachet is an open-source monitoring platform that is widely used by web developers, DevOps engineers, and system administrators for monitoring the performance of a…
- Upload Max Size Nginx Phpmyadmin Upload Max Size Nginx Phpmyadmin What is Nginx? Nginx is an open source web server and reverse proxy created for high performance and scalability. It is used to serve web…
- How To Install Nginx On Ubuntu 18.04 How To Install Nginx on Ubuntu 18.04 Introduction Nginx is a popular open-source web server and reverse proxy software that’s used by millions of websites. It’s the most widely used…
- Wordpress With Postgres And Nginx Wordpress with Postgres and Nginx Why Use Postgres? Postgres is a powerful and open-source database system that is commonly used for web applications. It’s becoming increasingly popular due to its…
- Hhvm Nginx Ubuntu 16.4 HHVM Nginx Ubuntu 16.4 What is HHVM? HHVM, also known as HipHop Virtual Machine, is a virtual machine developed by Facebook to speed up the execution of PHP code. It…
- Php Run On Server Apache Nginx PHP Run on Server Apache Nginx What is PHP? PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source scripting language that can be used to create dynamic…
- Nginx Php-Fpm Php Mariadb Mysql Centos 7.2 Digitalocean Nginx, Php-Fpm, Php, Mariadb, Mysql, Centos 7.2 Digitalocean Introduction: What is Nginx? Nginx is a powerful web server that was first released in 2004. It is known for being a…
- Install Laravel 5.8 Nginx Php7.3 Install Laravel 5.8 Nginx Php7.3 Overview Installing Laravel 5.8 on a Nginx server running PHP 7.3 can be a tricky task. This tutorial explains how to install the popular open…
- Cara Install Phpmyadmin Di Nginx Ubuntu Cara Install Phpmyadmin Di Nginx Ubuntu Pengertian PhpMyAdmin PhpMyAdmin adalah antarmuka web-berbasis yang memungkinkan Anda untuk mengelola basis data MySQL dan istilah yang lebih umum dalam pengelolaan basis data SQL.…