Install Apache2 With PHP5 And MySQL (LAMP) On openSUSE 12.1

ADVERTISEMENT

LAMP Stands for Linux,Apache,MySQL and PHP. Most of the websites works with the above combination. Here i used the openSUSE as Linux. The main purpose of LAMP is for testing the application locally by the programmer before going to the production and also setting up the web server for the clients need.

 

ADVERTISEMENT
Article will continue after the ad

 

Below are the steps to install LAMP (Apache, PHP and MySQL in openSUSE) using Zypper:-

Install Linux:

Here i am not going to show How to install openSUSE 12, the main purpose of this post is to setup AMP (Apache,MySQL and PHP) only.

Installing Apache:

To start off we will install Apache.

Step 1: Open up the Terminal and Swicth to root user.

raj@geeksite:~ $ su

Step 2: Package name of the Apache is apache2. Install apache2 using zypper. Type following Command on the Terminal and then press enter.

root@geeksite:~ # zypper in apache2

Step 3: Start the Apache by using the following command.

root@geeksite:~ # systemctl start apache2.service

Step 4: To make the apache to start during the every boot, Type the following on terminal and hit Enter.

root@geeksite:~ # systemctl enable apache2.service

Testing Apache:

To make sure everything installed correctly we will now test Apache to ensure it is working properly.

1. Open up any web browser and then enter the following into the web address:

 http://localhost/  or  http://your.ip.addr.ess

You will get the web page saying “Access Forbidden” because no index.html file in the default document root, now the Apache is working fine. Apache’s default document root is /srv/www/htdocs on openSUSE, and the configuration file is in /etc/apache2/httpd.conf and additional configurations are stored in the /etc/apache2/conf.d/ directory.

2. Place index.html file on /srv/www/htdocs/ directory for testing the web server, to do that create the file using the following command.

root@geeksite:~ # vi /srv/www/htdocs/index.html

3. Add the following content in index.html file.

Hi! Welcome GeekSite Webserver on openSUSE 12.1

4. Now refresh the same page or go to http://localhost, this time you should get the following web page on the browser.

Installing MySQL:

Next is to install the MySQL on the Linux, follow the Steps.

Step 1: Open the Terminal.

Step 2: Type the following command and then Press Enter.

root@geeksite:~ # zypper in mysql-community-server mysql-community-server-client

Start MySQL server.

root@geeksite:~ # systemctl start mysql.service

Step 3: To make the MySQL to start during the every boot, Type the following on terminal and hit Enter.

root@geeksite:~ # systemctl enable mysql.service

Next is to make the MySQL secure by using the mysql_secure_installation command.

This program enables you to improve the security of your MySQL installation in the following ways:

  • You can set a password for root accounts.
  • You can remove root accounts that are accessible from outside the local host.
  • You can remove anonymous-user accounts.
  • You can remove the test database (which by default can be accessed by all users, even anonymous users), and privileges that permit anyone to access databases with names that start with test_.

root@geeksite:~ # mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we’ll need the current
password for the root user.  If you’ve just installed MySQL, 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): <– ENTER
OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] <– ENTER
New password: <– yourrootsqlpassword
Re-enter new password: <– yourrootsqlpassword
Password updated successfully!
Reloading privilege tables..
 … Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL 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] <– ENTER
 … 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] <– ENTER
 … Success!

By default, MySQL 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] <– ENTER
 – 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] <– ENTER
 … Success!

Cleaning up…

All done!  If you’ve completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Installing PHP:

By default Apache server supports the HTML language only, not PHP for that we need to install PHP. To install PHP please follow the steps.

Step 1: Open the Terminal again.

Step 2: Type following line into Terminal and press enter: This command includes support package for the MySQL.

root@geeksite:~ # zypper in php5 php5-mysql apache2-mod_php5

Step 3. You need to restart the server after the installation of the PHP, to do that type the following on the terminal.

root@geeksite:~ # systemctl restart apache2.service

Testing PHP:

For testing the PHP, Place one PHP file on to the default directory of the Apache. The document root of the default web site is /srv/www/htdocs/. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.

Step 1. In the terminal copy/paste the following line:

root@geeksite:~ # vi /srv/www/htdocs/info.php

This will open up a file called info.php.

Step 2. Copy/Paste this line into the phpinfo file:

<?php
phpinfo();
?>

Step 3. Save and close the file. use Esc + ;wq for saving the file.

Step 4. Now open you’re web browser and type the following into the web address:

http://localhost/info.php or http://your.ip.add-ress/info.php

The page will look like below:

Scroll down the browser to modules section to check the support for the MySQL. you will get the screen like below.

phpMyAdmin:

phpMyAdmin is the web based interface to manage the MySQL database. it helps to administer the databases very easily. This is available in fedora package. So install it by using the following command.

root@geeksite:~ # zypper in phpMyAdmin

Afterwards, you can access phpMyAdmin under http://127.0.0.1/phpMyAdmin/ or http://your.ip.add.ress/phpMyAdmin/. It will ask you the user name and password for accessing phpMyAdmin; enter the root user name and the password that we have created earlier using mysql_secure_installation command.

Now you will get the home page of phpMyAdmin, here you can manage the database created on MySQL.

That’s All!

ADVERTISEMENT

POSTS YOU MAY LIKE -:)

Share This Post

  • Watch Game of Thrones Season 4 Episode 6 Online

    Just as Joffrey was unconscious of the peril he was in, Obama feels secure in the knowledge that he won’t get impeached
    for his actions. There are two-kinds of smiles: one is showing your teeth only,
    and the other consists of your eyes (crows’ feet on sides of each eye),
    and showing your teeth. Taking part in an activity you love gives you more of a sense that life is worthwhile.

  • melisew marekegn

    is very nice tutor……thanks a lot

Shares