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
- Linux is an operating system which UNIX-like and it’s free and open source for development and distribution. All of the Linux based operating systems provide Lamp packages.
- Apache is an HTTP Server which is used to process the HTTP request i.e. the webpages. It is one of the most popular web servers used by the developers around the globe. It is developed and maintain by the Apache Software Foundation.
- MySQL The Role of the RDBMS (Relational Database Management System) in LAMP bundle is played by MySQL. It helps us to save and manage data efficiently.
- PHP is a server-side scripting language used to interact with web server. It embeds with the HTML code.
Installing all components of LAMP together
- Open up your terminal by either going to dash and typing “terminal” or by pressing Ctrl+Alt+T
- Run the following Command to upgrade your index first(recommended)
- $ sudo apt-get update
- Install the LAMP Bundle
- $ sudo apt-get install lamp-server^
Installing all the LAMP components separately
1. Installing Apache 2 Server
To install Apache Server use the command:-
- $ sudo service apache2 restart
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.
- $ echo “ServerName localhost” | sudo tee /etc/apache2/conf-available/fqdn.conf&& sudo a2enconf fqdn
Test your server again.
2. Installing PHP 5 and MySQL
To install PHP5 and MySQL
- $ sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
To Check if PHP is Working
- Go to /var/www/ folder and create a file with .php extension (test.php)
- Type or copy <?phpphpinfo(); ?>and save it.
- Now open up your browser and go to “http://localhost/test.php” if you see the page same as below then php is successfully installed.3. Setting up MySQL Password
Open the terminal and type:-
- $ mysql -u root // MySQL console will open up
- $ mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘yourpassword’) //Open phpMyAdmin portal
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
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 thee 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).
- Official Ubuntu site (https://help.ubuntu.com/)
- PHP6 and MySQL Bible(Book by Joyce Park and Tim Converse)
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.
- How to use GIT in Ubuntu ? (Part -2)
- Introduction and Installation of Git
- How to install, configure and use GIT on ubuntu?
- Django Introduction and Installation
- Creating and Configuring Wi-Fi Hotspot in Ubuntu
- How to Install and Configure Elasticsearch on Ubuntu ?
- How to install Apache server in Ubuntu ?
- Configuring Face Unlock in Ubuntu | Howdy
- How to speed up the downloading of packages using apt-fast in Ubuntu?
- How to Install and Configure Fish Shell in Ubuntu?
- How to Install ImageMagick and Imagick PHP extension in Ubuntu ?
- Creating custom domain name instead of localhost in Ubuntu
- How to change login screen background in Ubuntu
- Beginning BootStrap (Part-1) | Introduction and Installation
- Introduction and Installation of Heroku CLI on Windows machine
Improved By : ShubhamRai4