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:
- Digitalocean Install Nginx Ubuntu 18.04 Digitalocean Install Nginx Ubuntu 18.04 Introducing DigitalOcean and Nginx DigitalOcean is a virtual cloud server provider, allowing users to spin up virtual servers located in various geographical locations throughout the…
- Ubuntu Nginx Php-Fpm Short Cut Ubuntu Nginx Php-Fpm Short Cut What Is Nginx? Nginx is a web server software package developed by Igor Sysoev for use with the Linux operating system. It is open source…
- Virtual Host Nginx Ubuntu 16.04 Virtual Host Nginx Ubuntu 16.04 Introduction A virtual host (also known as Virtual Private Server or VPS) is a service that allows a single physical server to host multiple websites.…
- 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…
- 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 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…
- Centos 7 Install Nginx Php 7 Centos 7 Install Nginx Php 7 Nginx Server Overview and Prerequisites Nginx is a highly popular open source web server and reverse proxy software, known for its scalability and performance…
- Tutorial Install Nginx Di Ubuntu Vps Tutorial Install Nginx Di Ubuntu Vps Step 1: Install Nginx The first step to install nginx in your Ubuntu VPS is to install the nginx package. To do this, use…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- Failed To Start Nginx Service In Ubuntu Failed to Start Nginx Service in Ubuntu What is Nginx? Nginx is an open-source web server written in C, designed for high performance and stability. Nginx is one of the…
- Webdav Nginx Ubuntu 16.04 Webdav Nginx Ubuntu 16.04 Introduction to Webdav with Nginx in Ubuntu 16.04 The ever-evolving world of the internet has given us a powerful platform to share information, media, and files…
- Nginx Install Ssl Certificate Ubuntu Nginx Install SSL Certificate Ubuntu What is Nginx? Nginx is a free, open-source web server that is used for powering websites. It is popular for its speed, scalability, and stability,…
- Google Cloud Ubuntu 16 Install Nginx Php Google Cloud Ubuntu 16 Install Nginx Php 1. What is Nginx? Nginx is a powerful open source web server. It is used to serve web pages to the internet and…
- Install Nginx And Php On Ubuntu 18.04 Install Nginx And Php On Ubuntu 18.04 Introduction In this article, we will guide you on how to install Nginx and php on Ubuntu 18.04. Nginx is a popular web…
- 403 Forbidden Nginx Ubuntu 14.04 403 Forbidden Nginx Ubuntu 14.04 What Is a 403 Forbidden Error? A 403 Forbidden error is an HTTP status code that denotes that a server, upon receiving a request from…
- Install Phpmyadmin Nginx Ubuntu 16.04 Install Phpmyadmin Nginx Ubuntu 16.04 What is PhpMyAdmin? PhpMyAdmin is an open-source software for managing MySQL databases. It can be used to add, modify, and delete databases, tables, and columns.…
- Install Nginx In Ubuntu 16.04 Install Nginx In Ubuntu 16.04 Overview of Nginx Nginx (pronounced "engine-x") is an open-source Web server that is designed to provide a balance of flexibility, performance, and scalability. It is…
- Install Rails On Ubuntu Nginx Rbenv Install Rails On Ubuntu Nginx Rbenv Introduction Rails is an open-source web application framework written in Ruby. It is designed to make programming web applications easier by providing a full…
- 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…
- Install Php Nginx Mysql Ubuntu 18.04 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…
- Install Nginx Di Kali Linux Install Nginx Di Kali Linux Introduction Kali Linux is a well-known operating system specially designed for Penetration Testing and Security Auditing tasks. The operating system is loaded with all the…
- Letsencrypt Nginx Ubuntu 16.04 Let’s Encrypt Nginx on Ubuntu 16.04 What is Let’s Encrypt? Let’s Encrypt is an open source Certificate Authority (CA) for issuing free SSL/TLS certificates. SSL/TLS certificates are used to encrypt…
- Nginx Always Displaying Default Page In Ubuntu Nginx Always Displaying Default Page In Ubuntu Introduction Ubuntu is one of the most popular Linux distributions and an immensely powerful and versatile operating system. It has a great package…
- Nginx Ssl Ubuntu 16.04 Nginx SSL Ubuntu 16.04 What is SSL and Nginx? SSL stands for Secure Sockets Layer. It is a protocol used to encrypt communications over the internet. It is a secure…