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:
- Install Nginx Php Windows 7 Install Nginx Php Windows 7 What is Nginx and PHP? Nginx and PHP both are web server applications that are used to host websites on the internet. Nginx is an…
- Deploy Laravel Nginx Ubuntu 18 Deploy Laravel Nginx Ubuntu 18 Intro to Laravel Laravel is a free, open-source, Model-View-Controller (MVC) web framework written in PHP. It has become one of the most popular web development…
- Apt-Get Install Nginx Php Mysql Apt-Get Install Nginx Php Mysql What is Apt-Get? Apt-Get is a powerful and innovative command line tool used by Linux-based operating systems such as Debian, Ubuntu, Linux Mint and others.…
- Install Postgis Ubuntu 18.04 Nginx Install Postgis Ubuntu 18.04 Nginx What is Postgis? Postgis is a Postgres-based open source geographic information system (GIS) that enables users to store, query, and analyze spatial data stored in…
- Install Laravel Nginx Ubuntu 18.04 Install Laravel Nginx on Ubuntu 18.04 Introduction In this tutorial, we will look at how to install Laravel with Nginx on an Ubuntu 18.04 server. Laravel is a powerful PHP…
- Install Wordpress On Nginx Ubuntu Install Wordpress On Nginx Ubuntu Introduction WordPress is a popular open-source blogging platform and content management system (CMS). It is made to be used on the internet, and it is…
- Install Phpmyadmin Nginx Ubuntu 16.04 Php 7 Install Phpmyadmin Nginx Ubuntu 16.04 Php 7 Introduction to PhpMyAdmin PhpMyAdmin is a web-based tool that enables the users to manage their MySQL databases. It also provides a graphical interface…
- Docker Nginx Php Mysql In Xampp Docker Nginx Php Mysql In Xampp Overview of Docker Nginx Php Mysql in Xampp Docker Nginx Php Mysql in Xampp is a powerful web development platform used for developing complex…
- Create Wordpress With Nginx Mariadb Php-Fpm 16.04 Create WordPress With Nginx Mariadb Php-Fpm 16.04 What Is WordPress? WordPress is a content management system (CMS) and a blogging platform. It allows you to easily create and manage websites…
- Ubuntu Server Postgresql Nginx Php Digitalocean Laravel Ubuntu Server Postgresql Nginx Php Digitalocean Laravel Introduction To The Stack Ubuntu Server, Postgresql, Nginx, PHP, Digitalocean and Laravel are an exceptional combination of elements that, when put together, make…
- Ubuntu Server18 How To Enable Nginx Pdo Mysql Ubuntu Server18: How to Enable Nginx Pdo Mysql As a developer, you may have heard of Nginx, PDO, and MySQL – all are essential components of web applications. Nginx is…
- Install Phpmyadmin Ubuntu 18.04 Nginx Install PhpMyAdmin Ubuntu 18.04 Nginx What is PhpMyAdmin? PhpMyAdmin is an open source software written in PHP that provides a graphical web-based interface for accessing and managing your MySQL or…
- Deploy Laravel Nginx Ubuntu 17 Deploy Laravel Nginx Ubuntu 17 Requirements for Installing Laravel 5.4 on Ubuntu 17 This article will guide you through the process of installing Laravel 5.4 on Ubuntu 17. Before we…
- Can I Install Phpmyadmin In Nginx Can I Install Phpmyadmin In Nginx? PHPmyadmin is a web-based management tool for databases such as MySQL and MariaDB. It is a popular tool for web developers and database administrators…
- Speed Up Vestacp On Centos 7 Nginx Apache Speed Up VestaCP On Centos 7 Nginx Apache Overview of the Setup VestaCP is a popular hosting control panel that uses a set of open source servers and applications to…
- Install Laravel Nginx 16.04 Install Laravel Nginx 16.04 What is Laravel? Laravel is an open source PHP framework designed to organize, develop, and easily deploy modern web applications. It is built on the Model-View-Controller…
- Cacti Nginx Php-Fpm Alpine Cacti Nginx Php-Fpm Alpine What is Cacti? Cacti is an open-source network monitoring and infrastructure management solution that offers an easy-to-use graphical interface for graphing, logging, and analyzing network traffic.…
- How To Ubuntu 16.04 Multiple Php Nginx How to Ubuntu 16.04 Multiple PHP Nginx Ubuntu 16.04 is a robust operating system that is commonly used for web application development. This operating system uses Nginx as the web…
- 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…
- Install Database Mysql Vagrant Nginx Install Database Mysql Vagrant Nginx What is Nginx? Nginx is an open source, high-performance web and proxy server designed to serve a variety of web applications. It handles requests from…
- Bitnami Wordpress Nginx Sent Email Arent Work Bitnami WordPress Nginx Sent Emails Aren't Working What is Bitnami WordPress? Bitnami WordPress is an open source software package specifically designed for quickly setting up and managing a WordPress website.…
- How Use Nginx Mysql Ubuntu How to Use Nginx, MySQL and Ubuntu What is Nginx? Nginx is an open source web server and reverse proxy software written by Igor Sysoev. It is a popular choice…
- Install Nginx Php Java On Centos 7 Install Nginx Php Java On Centos 7 What is Nginx? Nginx is an open source Web server created to serve Web traffic efficiently, reliably, and quickly. Nginx has become the…
- How To Install Phpmyadmin With Nginx On Windows 10 How To Install Phpmyadmin With Nginx On Windows 10 What Is Phpmyadmin? PhpMyAdmin is a popular open source tool used for managing MySQL databases, created written in PHP language. It…
- Centos 6 Nginx Phpmyadmin Forbideen Centos 6 Nginx Phpmyadmin Forbidden Introduction CentOS 6, an open-source Linux operating system, is one of the most popular web server operating systems. It is considered to be a reliable…
- 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 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.…
- Ubuntu 18.04 Nginx Php Mariadb Ubuntu 18.04 Nginx, Php, and Mariadb Understanding Ubuntu 18.04 Ubuntu 18.04 is the latest version of the popular open-source Linux distribution. It is based on Debian and is known for…
- Ubuntu 18 Enable Php Mysql Nginx Ubuntu 18 Enable Php Mysql Nginx Introduction: What Is Ubuntu? Ubuntu is an open source operating system based on the Debian GNU/Linux distribution. Built around the Linux kernel and released…
- Install Wordpress On Ubuntu 18.04 Nginx Install WordPress On Ubuntu 18.04 Nginx Introduction To Ubuntu And Nginx Ubuntu is a popular open-source operating system which has gained immense popularity over the years. It is easy to…