Install Php Nginx Ubuntu 12.04
Introduction
Welcome to our guide on How to install PHP, Nginx & MySQL on Ubuntu 12.04 LTS. This guide should work on other Linux VPS systems as well but was tested and written for an Ubuntu 12.04 VPS system. Here we will go through the steps required to install the respective software on Ubuntu 12.04.
Prerequisites
Before we install PHP, Nginx and MySQL on Ubuntu 12.04, we should update the repositories and packages to the latest version. This can be done by running the following command on the terminal:
sudo apt-get update
sudo apt-get upgrade
The above commands should update and install all the required packages for the installation of PHP, Nginx and MySQL on Ubuntu 12.04.
Installing PHP on Ubuntu 12.04
Once we have the prerequisites sorted out, we can move on to install PHP on Ubuntu 12.04. To do this, we first need to install Php5 using the following command:
sudo apt-get install php5
The above command should install and setup all required components of PHP on Ubuntu 12.04. Once it is done, we can verify it by running the following command:
php -v
This should display the PHP version that is installed on the system. We will also need to install Php5-fpm in this step. To do that, we need to run the following command.
sudo apt-get install php5-fpm
This should install php5-fpm on the system and all related components. Once the installation in done, we can start and enable the service using the following command.
sudo service php5-fpm start
sudo update-rc.d php5-fpm defaults
Installing Nginx on Ubuntu 12.04
Once we have the prerequisites sorted out, we can move on to install Nginx on Ubuntu 12.04. To do this, we first need to add the Nginx repository by running the following command on the terminal:
sudo add-apt-repository ppa:nginx/stable
Once the repository is added, we can update the packages and repositories by running the following command:
sudo apt-get update
Finally, we can install Nginx on Ubuntu 12.04 by running the following command:
sudo apt-get install nginx
Once the installation is done, we can test and verify it by running the following command:
sudo nginx -t
This should output the Nginx version, and if everything is setup correctly it should say that the configuration file has been tested successfully.
Installing MySQL on Ubuntu 12.04
Once we have all the prerequisites setup, we can install MySQL on Ubuntu 12.04. To do this, we first need to add the MySQL repository by running the following command on the terminal:
sudo apt-get install mysql-server
Once the installation is done, we can test and verify it by running the following command:
sudo mysql -V
This should output the MySQL version, and if everything is setup correctly it should say that the server is running properly.
Making Nginx and PHP Work Together
Now that we have both Nginx and PHP setup on the system, we need to configure both to work together. To do this, we first need to create a configuration file in the Nginx directory. To do this, we need to run the following command:
sudo nano /etc/nginx/sites-available/php-fpm
In this file, we need to paste the following configuration:
server {
listen 80;
server_name example.com;
root /var/www/example.com;
index index.php index.html;
location ~ .php$ {
try_files $uri = 404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Once we have saved and enabled the configuration file, we can restart Nginx and PHP for the changes to take effect by running the following command:
sudo service nginx restart
sudo service php5-fpm restart
Conclusion
We have now successfully installed PHP, Nginx and MySQL on Ubuntu 12.04. We have also configured Nginx and PHP to work together. This should provide us with enough power and flexibility to run any web application that requires PHP, Nginx and My SQL.
FAQs
Q. How do I start PHP on Ubuntu 12.04?
A. You can start and enable the php5-fpm service using the command sudo service php5-fpm start
followed by sudo update-rc.d php5-fpm defaults
.
Q. How do I configure Nginx and PHP to work together?
A. You need to create a configuration file in the Nginx directory and add the configuration given in the article. After that you need to restart Nginx and PHP for the changes to take effect.
Q. How do I restart Nginx and PHP?
A. You can restart Nginx and PHP using the command sudo service nginx restart
and sudo service php5-fpm restart
.
Thank you for reading this article. Please read other articles for more information and updates.
Related Posts:
- Wordpress Nginx Ubuntu 18.04 Wordpress Nginx Ubuntu 18.04 Overview WordPress is a popular web software used by millions of people around the world. It allows users to easily create and manage websites without the…
- Install Nginx Passenger Ubuntu 16.04 Install Nginx Passenger Ubuntu 16.04 Installing Nginx On Ubuntu 16.04 Nginx is an open source web server that can be used to create web and application servers. It is a…
- Install Squirellmail On Nginx Ubuntu Install Squirrelmail On Nginx Ubuntu 1. What is Squirrelmail? Squirrelmail is a webmail application written in PHP. It is often used as an email client for the Linux operating system…
- Install Nginx Phpmyadmin Ubuntu 18.04 Install Nginx Phpmyadmin Ubuntu 18.04 Introduction to Nginx, PHP, and Ubuntu Nginx is an open-source, high-performance web server written in C and used to serve static and dynamic webpages. It…
- Install Nginx Mysql Phpmyadmin Ubuntu Install Nginx Mysql Phpmyadmin Ubuntu 1. Introduction In today's tutorial, we will show you how to install Nginx, MySQL, and phpMyAdmin on Ubuntu 20.04. Nginx is an open source web…
- 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…
- Reverse Proxy Nginx Ubuntu 18.04 Reverse Proxy Nginx Ubuntu 18.04 Introduction Reverse Proxy is a type of proxy server that forwards requests to another server. It is mainly used by web servers, such as Nginx,…
- Ubuntu Server Postgresql Nginx Php Ubuntu Server Postgresql Nginx Php Introduction Optimizing your server is one of the most important steps you can take when it comes to running a successful website or application. It…
- Upgrade Nginx Ubuntu 18.04 Upgrade Nginx Ubuntu 18.04 Getting Started with Nginx Ubuntu 18.04 Installation Nginx is a high performance web server and reverse proxy. It is written in C and has ways to…
- Ubuntu Install Nginx Php7.2 Mysql Ubuntu Install Nginx Php7.2 Mysql What is Nginx? Nginx is an open source web server that is very popular for powering web applications such as WordPress and Drupal. It is…
- Install Nginx Ubuntu 18.08 Local Install Nginx on Ubuntu 18.04 Local Installing Nginx on Ubuntu 18.04 can be accomplished quickly and in several different ways. Depending on your needs, some methods may be better suited…
- How To Set Rails On Nginx Ubuntu 18.04 How To Set Rails On Nginx Ubuntu 18.04 Step 1: Install Ruby Using RVM The first step for setting up Ruby on Rails on an Ubuntu 18.04 server with Nginx…
- Remove Nginx Full Complete On Ubuntu 18 Remove Nginx Full Complete On Ubuntu 18 Uninstallating Nginx From Ubuntu Ubuntu is one of the most popular Linux-based operating systems, and it has a wide variety of programs available…
- Install Laravel 5.1 Ubuntu 16.04 Nginx Install Laravel 5.1 on Ubuntu 16.04 Nginx Introduction Laravel is a free, open-source PHP web application framework that is highly popular with modern web developers. It leverages an expressive and…
- How To Install Nginx Maridb 10 On Ubuntu 16.04 Lts How To Install Nginx Maridb 10 On Ubuntu 16.04 Lts Step 1 — Installing Nginx The first step in installing Nginx and MariaDB 10 on Ubuntu 16.04 is installing Nginx.…
- Install Nginx And Php On Ubuntu Install Nginx And Php On Ubuntu A Comprehensive Tutorial to Install Nginx And Php On Ubuntu Nginx and PHP are two of the most popular web server and scripting language…
- 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…
- 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.…
- 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…
- Ubuntu Install Web Server Nginx Ubuntu Install Web Server Nginx Step 1: Install the Nginx Package The first step when installing Nginx on Ubuntu is to install the Nginx package from the Ubuntu repository. This…
- How To Setup Nginx On Ubuntu How To Setup Nginx On Ubuntu Introduction Nginx is a powerful web server that is very popular among Linux users. It is open-source and comes with great features such as…
- 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…
- Install Nginx 1.16 Ubuntu Install Nginx 1.16 Ubuntu Introduction to Nginx 1.16 Nginx 1.16 is a web server that helps you to serve web content quickly, efficiently and securely. It is especially popular with…
- Digitalocean Letsencrypt Nginx Ubuntu 18.04 Digitalocean Letsencrypt Nginx Ubuntu 18.04 Introduction Ubuntu 18.04 is the latest version of the popular Linux operating system. Digitalocean is a cloud hosting provider that specializes in hosting and managing…
- Step By Step Install Nginx And Phpmyadmin On Ubuntu Step By Step Install Nginx And Phpmyadmin On Ubuntu Introduction Setting up a web server on Ubuntu is easy and straightforward. Nginx is a popular web server for Ubuntu, and…
- 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…
- Perfect Server Ubuntu 18.04 Nginx Perfect Server Ubuntu 18.04 Nginx 1. Introduction Ubuntu is one of the most popular Linux distributions. It is popular due to its user friendliness and availability of excellent free software…
- Laravel Nginx Config Ubuntu 18 Laravel Nginx Config Ubuntu 18 Introduction Laravel is a powerful web-based MVC (Model-View-Controller) framework used by developers to create web applications, websites and APIs. It is based on the popular…
- Nginx Ssl Configuration Ubuntu 18.04 Nginx Ssl Configuration Ubuntu 18.04 What is Nginx? Nginx is an open source web server and reverse proxy software. It is used to manage web traffic on the internet, like…
- 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…