How to Setup LAMP ( Linux , Apache , Mysql , Php ) Server in Centos 7 / Redhat 7 / Fedora
How to Setup LAMP ( Linux , Apache , Mysql , Php ) Server in Centos 7 / Redhat 7 / Fedora
LAMP Linux Apache Mysql Php Server in one of the most used web server setup to host dynamic websites in linux. We can host any dynamic Website or CMS websites like WordPress , Wix , Drupal and many more with this setup.
Now Lets Install these Softwares one by one.
Apache:-
1) Install the httpd Package.
2) Start and enable the Service.
systemctl enable httpd
3) Apply the firewall rule.
firewall-cmd –reload
4) Open your Web Browser.
http://<your_ip>
Our Apache Web Server is Displaying the Test Page or Default Page which means our Apache web server is up and running.
MySql :-
1) Install mariadb package.
We have Installed two Packages to setup mysql one is mariadb which is a client package to access mysql server and maridb-server is the mysql server package it is used to setup mysql server.
2) Start and Enable the service.
systemctl enable mariadb
3) Apply the firewall rule.
firewall-cmd –reload
4) Configure Mysql.
Parameters used in setting up mariadb. According to your scenario you can setup using these parameters.
Set root password? [Y/n] – Y (To Setup Root Password to the database)
Remove anonymous users? [Y/n] – Y (To Remove Anonymous Users from database)
Disallow root login remotely? [Y/n] – Y (To Disallow Remote Root login to Database)
Remove test database and access to it? [Y/n] – Y (To Remove Test Database)
Reload privilege tables now? [Y/n] – Y (To Reload Priviege)
mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we’ll need the current
password for the root user. If you’ve just installed MariaDB, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):Hit Enter
OK, successfully used password, moving on…
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
… Success!
Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
… Success!
By default, MariaDB comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
– Dropping test database…
… Success!
– Removing privileges on test database…
… Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
… Success!
Cleaning up…
All done! If you’ve completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
Now Lets Connect to our Database.
Enter password: Enter the Root Password
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.MariaDB [(none)]>
PHP :-
1) Install php.
We have Installed two packages one in php which is for supporting php in our apache web server and php-mysqlnd which will setup database integration.
2) Restart the Apache Server service and Mariadb server serivce.
We Have successfully configured LAMP Stack . Now Lets check .
Let’s create a file index.php and check wheater it is working with our apache server.
press i to get into insert mode
after making changes in the file press escape from keyboard and press :wq! to write and quite from file.
Open your Web Browser
http://<your_ip>
Our LAMP Stack is up and running and working fine.
Follow our Guided tutorial on YouTube :-
Recent Comments