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:
- Letsencrypt Ubuntu 12.04 Nginx Letsencrypt Ubuntu 12.04 Nginx What is a Let's Encrypt Certificate? Let’s Encrypt is a free, automated, and open certificate authority (CA). It will allow you to secure your website with…
- 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…
- How To Install Nginx And Mariadb 10 How To Install Nginx And Mariadb 10 What is Nginx and MariaDB 10 Nginx is a free, open-source web server that is known for its scalability and performance. It is…
- 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…
- 502 Bad Gateway Nginx In Ubuntu 502 Bad Gateway Nginx In Ubuntu What Is A 502 Bad Gateway Error? A 502 Bad Gateway Error is an HTTP status code that is not able to connect to…
- 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…
- 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…
- Ubuntu 16.04 Nginx Ipv6 Ubuntu 16.04 Nginx Ipv6 What is Ubuntu 16.04? Ubuntu 16.04 is a version of the Ubuntu Linux operating system for computers and servers. Ubuntu has been around since 2004, and…
- How To Install Flask Nginx On Ubuntu 1604 How To Install Flask Nginx On Ubuntu 1604 Introduction Flask is a web application framework based on Python. It is highly useful for web developers due to its flexibility and…
- Php-Fpm Nginx Ubuntu 18.04 PHP-FPM & Nginx on Ubuntu 18.04 Introduction to PHP-FPM PHP-FPM (FastCGI Process Manager) is an implementation of FastCGI, which is a standard protocol for interfacing external applications with web servers.…
- How To Deactive Nginx Ubuntu How To Deactivate Nginx Ubuntu Introduction Nginx is a web server that’s popular in the Linux world because of its simple configuration, scalability, and performance. The Apache httpd web server…
- 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…
- 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…
- 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…
- Ubuntu 18.04 Nginx Hide Port Ubuntu 18.04 Nginx Hide Port Introduction to Nginx with Ubuntu Nginx is an open source web server and reverse proxy software that is commonly used in Linux servers. It is…
- 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.…
- 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…
- 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 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…
- Replace Apache To Nginx Ubuntu 18 Replace Apache To Nginx Ubuntu 18 Installing Nginx Ubuntu 18 uses Nginx as its default web server, and it is pre-installed. However, if you want to use a fresh version…
- 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…
- 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…
- 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…
- Nginx On Ubuntu 18.04 Nginx On Ubuntu 18.04 What is Nginx? Nginx is a free, open-source, high-performance web server software. It is known for its stability, rich feature set, simple configuration, and low resource…
- How To Ufw Allow Nginx Http Digitalocean How To Ufw Allow Nginx Http Digitalocean What is UFW for Nginx on DigitalOcean? UFW (Uncomplicated Firewall) is a firewall application package for use with the Ubuntu Linux operating system.…
- 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…
- 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…
- 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…
- 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…
- 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,…