SDB:LAMP setup
Tested on openSUSE
Recommended articles
Related articles
- a working Apache2 webserver;
- a configured MariaDB database server;
- PHP7 (or PHP5) for work with Apache; and finally
- phpMyAdmin with a configured pmadb database.
Contents
This article is updated to reflect the installation in currently supported openSUSE Leap and Tumbleweed. However it does not deviate much from lower versions of openSUSE.
Getting root access
To get root access, open a terminal and enter the following command:
Password:
After entering a valid password, the prompt should turn red and end with a #.
Apache
Webserver setup and configuration.
Installing Apache2
First of all, make sure you have root access and enter the following command:
Starting Apache2
To start the apache server, enter the following command:
or if you want to stop it
To automatically start the apache server after a reboot:
Testing the installation
To check if you apache server works, use you favorite text editor an create the index.html file in the /srv/www/htdocs/ folder with the following content:
<html><body><h1>Welcome to my web site!</h1></body></html>
Now point your favorite Web browser to: 'localhost'. You should see a page with Welcome to my web site! as a headline.
Enabling public access to the web server
In this state the web server is only accessible as localhost. If you want to give access to it from a remote host, you have to open port http (=80) in the firewall.
SuSEfirewall2
To do this, edit the /etc/sysconfig/SuSEfirewall2 file and change the line
FW_CONFIGURATION_EXT=""
into
FW_CONFIGURATION_EXT="apache2"
After editing you have to restart the firewall using:
Firewalld
As root execute this. Note that this assumes that the zone you have configured is public. Replace public with your zone you have selected.
firewall-cmd --zone=public --add-port=80/tcp --permanent
Once you add the firewall rule reload firewall service.
firewall-cmd --reload
Alternatively, you can use the graphic user interface through YaST
- Open the YaST Control Center
- Select Firewall
- The Configuration for modification defaults under Runtime. Any changes you make will only affect the current Runtime of the machine
- Note the Zone that the network is running and ensure that the current zone is selected under the Zones tab.
- In the Services tab, locate apache2 in the window.
- If you would like to make this change permanent under the selected Zone, select Options > Runtime to Permanent
- If no further changes to the firewall are required, close the Configuration window, changes are immediate.
Setting up PHP
Installing PHP7
Make sure you have root access — see above. Install php7 using:
Don't forget to enable mod-php by executing:
Your are done, php7 is now installed.
Installing PHP5
If instead you want to install PHP5, the steps are the same as above with 'php5' instead of 'php7':
Note you need to choose if to install php7 or php5. You cannot have both of them.
Restarting the webserver
Now that you have installed php, you have to restart the apache2 webserver:
Testing the installation
To verify that php is properly working, create a index.php file into the /srv/www/htdocs/ folder with the following content:
<?php phpinfo(); ?>
Now, point your browser to 'localhost/index.php'. You should see a page containing a table with all php settings displayed.
Setting up MariaDB
Installing MariaDB
Make sure you have root access — see above. We need to install mariadb and mariadb-tools:
Starting the MariaDB server
To start the MariaDB server, execute:
Ensure that the server will start at every boot:
or if you want to stop it
Configuring the MariaDB/MySql server
To configure the MariaDB server with improved security, please use the script 'mysql_secure_installation provided by openSUSE. Hereafter is the description of the full process.
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):Just press Enter here.
... (output sequel of previous command)
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] yJust enter y here.
... (output sequel of previous command)
New password:
Enter the password for root now.
... (output sequel of previous command)
Re-enter new password:
Enter the password confirmation.
... (output sequel of previous command)
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]Answer y to remove anonymous users.
... (output sequel of previous command)
... 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]Answer y now.
... (output sequel of previous command)
... 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]Answer y.
... (output sequel of previous command)
- 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]Answer y.
... (output sequel of previous command)
... 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!For memory in older versions
Replacing <NEW PASSWORD> with the value of the new password your want to define, execute:
Password:
Enter the present password or press only Enter if it has never been defined.
Logging in to the client
Now you can log in into the server client by executing
Enter password:
Then give your password.
... (output sequel of previous command)
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 154 Server version: 10.0.22-MariaDB openSUSE package
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>To go back to the terminal, execute:
... (output sequel of previous command)
Installing phpMyAdmin
What is phpMyAdmin?
phpMyAdmin — a.k.a. pma — is a tool to administrate your databases from a Web interface.
Installing phpMyAdmin
To install phpMyAdmin execute:
This also installs a number of needed php5 modules and restarts the apache2 server.
Logging into phpMyAdmin
To log in to phpMyAdmin:
- Navigate to localhost/phpMyAdmin
- Enter the root username and the root password of your mysql server
- Click on the 'go' button
Checking phpMyAdmin
Now point your browser at http://localhost/phpMyAdmin/ or http://ip_address/phpMyAdmin/ and enter the mysql root username and its passord.
That's all! You can now administer your databases from a Web interface.
You can read the documentation on phpMyAdmin on the phpMyAdmin website.
You should have a working LAMP server now!