Saturday, 16 March 2019

How to Install PHP

to create a  PHP application first we need to install PHP in the local machine to practice more and more. so we are going to learn how to install PHP in Windows or Mac or Linux OS.


Install PHP in windows or mac


its very very easy process tiinstall WAMP in Windows or mac machine for that you have to go to the website of wampp and have to download that, and to download wampp for windows or mac follow the below described link:
https://www.wampserver.com/en/#download-wrapper
 
From the above link download the wamp for 64 bit machine or 32 bit machine. and then follow the instructions,
the instructions are also given on the wampp website also.
Installation instructions.
* Double click on the downloaded file and just follow the instructions. Everything is automatic. The WampServer package is delivered whith the latest releases of Apache, MySQL and PHP.
* Once WampServer is installed, you can manually add aditionals Apache, Php or MySql (only VC9, VC10 and VC11 compiled) versions. Explanations will be provided on the https://forum.wampserver.com/list.php?2.
* Each release of Apache, MySQL and PHP has its own settings and its own files (datas for MySQL).
How to use wampserver.
* The “www” directory will be automatically created (usually c:\wamp\www)
* Create a subdirectory in “www” and put your PHP files inside.
* Click on the “localhost” link in the WampSever menu or open your internet browser and go to the URL : https://localhost


Another simple process to install PHP in widows or mac,



There is another cery simple way to install php on windows or mac machine , by installing xampp, to install xampp you need to first go to the website of xampp, you can go to xampp website by clicking the below link also,
the link is: https://www.apachefriends.org/index.html
* after downloading doubble click on the downloaded installer file and just fllow the instruntions appear during the installation.
For both case you need to remember that skype should be exited else it will block the port 80, and in that setuation you have to install wampp or xampp and use from port 8080 or other.
Now we are going to see how to install PHP on linux machine.
We have alrady discussed about the both software xampp and wamp and both software have linux version , and if that support your linux version then its as easy as before. but if not then you need to install from the terminal.
here I am going to shoe how to install php on ubuntu machine.
to install php in a ubuntu linux machine flow the below instructions.
Step 1: Install Apache and Allow in Firewall

Open your terminal to install apache and input the below code one by one , here i am given the output also for the commend inserted on the terminal.

sudo apt-get update
 
sudo apt-get install apache2
sudo apache2ctl configtest
Output
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
sudo nano /etc/apache2/apache2.conf
ServerName server_domain_or_IP
sudo apache2ctl configtest
Output
Syntax OK
sudo systemctl restart apache2
sudo ufw app list
utput
Available applications:
Apache
Apache Full
Apache Secure
OpenSSH
sudo ufw app info "Apache Full"
Output
Profile: Apache Full
Title: Web Server (HTTP,HTTPS)
Description: Apache v2 is the next generation of the omnipresent Apache web
server.
Ports:
80,443/tcp
sudo ufw allow in "Apache Full"
https://your_server_IP_address
Now to findout server ip address:
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
sudo apt-get install curl
curl https://icanhazip.com
Step 2: Install MySQL
sudo apt-get install mysql-server
mysql_secure_installation
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No:
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
Step 3: Install PHP
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
 
sudo nano /etc/apache2/mods-enabled/dir.conf
sudo systemctl restart apache2
sudo systemctl status apache2
Sample Output

● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Wed 2016-04-13 14:28:43 EDT; 45s ago
Docs: man:systemd-sysv-generator(8)
Process: 13581 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
Process: 13605 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
Tasks: 6 (limit: 512)
CGroup: /system.slice/apache2.service
├─13623 /usr/sbin/apache2 -k start
├─13626 /usr/sbin/apache2 -k start
├─13627 /usr/sbin/apache2 -k start
├─13628 /usr/sbin/apache2 -k start
├─13629 /usr/sbin/apache2 -k start
└─13630 /usr/sbin/apache2 -k start
Apr 13 14:28:42 ubuntu-16-lamp systemd[1]: Stopped LSB: Apache2 web server.
Apr 13 14:28:42 ubuntu-16-lamp systemd[1]: Starting LSB: Apache2 web server...
Apr 13 14:28:42 ubuntu-16-lamp apache2[13605]: * Starting Apache httpd web server apache2
Apr 13 14:28:42 ubuntu-16-lamp apache2[13605]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerNam
Apr 13 14:28:43 ubuntu-16-lamp apache2[13605]: *
Apr 13 14:28:43 ubuntu-16-lamp systemd[1]: Started LSB: Apache2 web server.
Install PHP Modules
apt-cache search php- | less
 
libnet-libidn-perl - Perl bindings for GNU Libidn
php-all-dev - package depending on all supported PHP development packages
php-cgi - server-side, HTML-embedded scripting language (CGI binary) (default)
php-cli - command-line interpreter for the PHP scripting language (default)
php-common - Common files for PHP packages
php-curl - CURL module for PHP [default]
php-dev - Files for PHP module development (default)
php-gd - GD module for PHP [default]
php-gmp - GMP module for PHP [default]

:
Press q to quit
apt-cache show package_name
apt-cache show php-cli
Output

Description-en: command-line interpreter for the PHP scripting language (default)
This package provides the /usr/bin/php command interpreter, useful for
testing PHP scripts from a shell or performing general shell scripting tasks.
.
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
open source general-purpose scripting language that is especially suited
for web development and can be embedded into HTML.
.
This package is a dependency package, which depends on Debian's default
PHP version (currently 7.0).

sudo apt-get install php-cli
sudo apt-get install package1 package2 ...
Step 4: Test PHP Processing on your Web Server
sudo nano /var/www/html/info.php
it will open a editable page and type there
<?php
phpinfo();
?>
and then save
then go to your browser and type
https://your_server_IP_address/info.php
and you are rady to make code.
Hope the post how to install php on your local server helped you,

Thanks a lot for reading.

No comments:

Post a Comment