Open In App

LAMP installation and important PHP configurations on Ubuntu

PHP is the Web development (Server Side Scripting Language) written and developed for web developers.It was developed by Rasmus Lerdorf in 1994, for maintaining his personal homepage. Later he added the feature to communicate with web forms and to connect with databases, named it as Personal Home Page Tools (PHP), Lerdorf wrote those using C binaries. 

Let us get started with installing PHP in Ubuntu. In order to test our PHP pages, a server is needed. MySQL database is also required to manage or save data.Don’t worry you don’t have to buy a web hosting for testing your Web pages, I’m going to tell you how to install your own local host web server. 



LAMP is basically a collection of software which you require to create the dynamic website and web applications.These tools are capable enough that you don’t require any other tool for the purpose. The interesting thing about LAMP is that all the tools in it are free and open-source

Software components of LAMP 
 



 

Installing all components of LAMP together

 

 

By installing LAMP you have successfully installed Apache, MySQL, and PHP

 
 

Installing all the LAMP components separately

1. Installing Apache 2 Server 

To install Apache Server use the command:- 
 

 

Open your browser and check whether the service has properly installed or not. 

Type in the URL: –http://localhost 

 

If you are able to see the  Default page,You have properly installed your Apache Server. 

Else, if you are getting message “Could not determine server”,Then you need to just copy the below command and run it in terminal. 
 

Test your server again. 

2. Installing PHP 5 and MySQL 

To install PHP5 and MySQL 
 

 

To Check if  PHP is Working 
 

Open the terminal and type:- 
 

Open your Browser and type in http://localhost/phpmyadmin.Username: root and password (blank or either “password”).

Configuring PHP (php.ini file) 

Editing php.ini file is most efficient and immediate way to affect the PHP’s functionality. As php.ini file is read each time when ever PHP is initialized in other words whenever our server is restarted or whenever httpd is restarted. 

Location of php.ini: /etc/php5/apache2/php.ini 

1) short_open_tag = off 

“<? ?>” these are called short open tags. And if you want to use XML functions then you need to    set the “default value” to off. 
 

2) disable_functions=[function1, ……]

 

PHP has the ability to disable selected functions for security reasons.

 

3) max_execution_time =30 

This will make the script time out in safe mode when the time limit exceeds. In windows, script is aborted based on the memory consumption rather than time.

 

  

4) error_reporting =E_ALL & ~E_NOTICE 

By default the value is to report all the errorit encounters and should be remain as such. 

5) error_prepend_string = [“<font color = ff0000>”] 

This flag will print the error message in different colour then normal text in the colour which you have specified in the flag. You should set the flag value to the blink so that your eyes can easily catch the error message pho has encounter. 

 

6) variables_order = EGPCS 

This will tell you the order of execution of the variables that are Environment, GET, POST, COOKIE and SERVER. (i.e. left to right). 

References 
 

 

About the Author: Sahib Singh is currently pursuing B.E. from Chandigarh University. He has a keen interest in programming, developing websites and making android apps. You can reach him at: http://in.linkedin.com/in/sdsahib 

If you also wish to showcase your blog here, please see GBlog for guest blog writing on GeeksforGeeks.
 

Article Tags :