How To Install LAMP (linux, Apache ,Mysql ,PHP)
How to Install LAMP (Linux, Apache, MySQL, php) stack is an open source software that can be used for hosting website and applications. It’s a combination of Apache, MySQL Server And PHP scripting language.
We’re going to install Apache web server on Redhat 6/7 version and follow our steps to install it.I’m assuming you have Yum configured on the server.
First check Apache already installed or not. If you no output means this not installed.
By command rpm –qa httpd*
Step 1 : Run command mentioned below
yum install httpd* -y
After running this command Apache will be installed and check it by command mentioned below
rpm –qa | grep –I httpd
Step 2 : You can find the configuration file of Apache at this location
Step 3 : Now you have to start the service of Apache
systemctl start httpd
Install Mysql / Mariadb
Mariadb is a relational database server. It’s widely used MySQL server in the world. This is originally made by developer of MySQL. That’s well known as mariadb server in redhat /CentOS 6/7 version as we know if we installed MySQL server the package will be the name of MySQL not mariadb like in redhat 7.
Check Out : How To Send Root Mail To existing User
It uses the port 5432 and open source database serve. The main configuration file is /etc/my.cnf
Installation of Mariadb Server
First thing to do is to check whether already installed or not.
rpm –qa mariadb*
If not installed then run this command
yum install mariadb* -y
Once it’s get installed you need to check all the dependencies are installed or not by the same command
rpm –qa mariadb*
Packages included :
Now you need to start/enable the services of Mysql Server
Run following commands to do this
systemctl start mariadb
Check Out : Configure Varnish For Apache Web Server
systemctl enable mariadb
PHP (hypertext preprocessor) is a widely used scripting language for web development. It is also an open source scripting language. Current version of PHP 7.0 It was originally created by Rasmus Lerdorf in 1994.
The file extension .php and the path of php file stored at location /var/www/html/index.php
For php, you must have web server installed on your system e.g Apache or nginx etc.
- Php-mysql # mysql Server , you can any other database server
Php-gd = A module for PHP applications for using the gd graphics library
Php-pear = PHP Extension and Application Repository framework
Other Packages are mentioned below you can install them according to your need.
- OPcache (php-opcache)
- APCu (php-pecl-apcu)
- CLI (php-cli)
- PDO (php-pdo)
- PostgreSQL (php-pgsql)
- MongoDB (php-pecl-mongodb)
- Redis (php-pecl-redis)
- Memcache (php-pecl-memcache)
- MCrypt (php-mcrypt)
- XML (php-xml)
Step 1: Install PHP using Yum
Note : Must have web server installed on machine
yum install php php-mysql.x86_64 php-gd.x86_64 php-pear.noarch –y
Step 2: Now create a test file under the directory /var/www/html/test.php
Put these line in the file test.php
And save the file
Check Out : How To Install Memcached Memory Caching In Linux
Step 3: Now restart the Apache server service
systemctl restart httpd
You will see this page if php successfully installed and working.