20.8 C
Texas
Melhttp://www.osradar.com
Guru Unix /Linux and GNU supporter

How to Install Apache, MariaDB, PHP7 (LAMP) on openSUSE Leap 15

This is my first test installing LAMP on OpenSUSE Leap 15. I know that OpenSUSE 15 leap has moved to firewalld instead of SuSEfirewall2, the rest I think will stay the same.

My  environment:

The server is OpenSUSE 15

Hostname: suse15.osradar.com

- Advertisement -

IP: 192.168.65.151

Let’s start.

How to Install Apache, MariaDB, PHP7 (LAMP) on openSUSE Leap 15

Install   Apache

suse15:~ # zypper in apache
Loading repository data...

Reading installed packages...
'apache' not found in package names. Trying capabilities.
Resolving package dependencies...

The following 8 NEW packages are going to be installed:
 apache2 apache2-prefork apache2-utils libapr-util1 libapr1 libbrotlicommon1 libbrotlienc1 system-user-wwwrun

8 new packages to install.
Overall download size: 2.1 MiB. Already cached: 0 B. After the operation, additional 6.0 MiB will be used.
Continue? [y/n/...? shows all options] (y):
Retrieving package libapr1-1.6.2-lp150.4.1.x86_64 (1/8), 113.9 KiB (244.4 KiB unpacked)
Retrieving: libapr1-1.6.2-lp150.4.1.x86_64.rpm ..............................................................[done]
Retrieving package libbrotlicommon1-1.0.2-lp150.1.3.x86_64 (2/8), 61.5 KiB (126.0 KiB unpacked)
Retrieving: libbrotlicommon1-1.0.2-lp150.1.3.x86_64.rpm ........................................[done (97.3 KiB/s)]
Retrieving package system-user-wwwrun-20170617-lp150.3.25.noarch (3/8), 10.3 KiB ( 96 B unpacked)
Retrieving: system-user-wwwrun-20170617-lp150.3.25.noarch.rpm ...............................................[done]
Retrieving package libapr-util1-1.6.1-lp150.2.5.x86_64 (4/8), 101.4 KiB (240.5 KiB unpacked)
Retrieving: libapr-util1-1.6.1-lp150.2.5.x86_64.rpm .........................................................[done]
Retrieving package libbrotlienc1-1.0.2-lp150.1.3.x86_64 (5/8), 191.9 KiB (533.9 KiB unpacked)
Retrieving: libbrotlienc1-1.0.2-lp150.1.3.x86_64.rpm ..........................................[done (522.9 KiB/s)]
Retrieving package apache2-utils-2.4.29-lp150.5.2.x86_64 (6/8), 148.8 KiB (202.1 KiB unpacked)
Retrieving: apache2-utils-2.4.29-lp150.5.2.x86_64.rpm .......................................................[done]
Retrieving package apache2-2.4.29-lp150.5.2.x86_64 (7/8), 1.2 MiB ( 4.1 MiB unpacked)
Retrieving: apache2-2.4.29-lp150.5.2.x86_64.rpm .................................................[done (3.8 MiB/s)]
Retrieving package apache2-prefork-2.4.29-lp150.5.2.x86_64 (8/8), 297.2 KiB (612.8 KiB unpacked)
Retrieving: apache2-prefork-2.4.29-lp150.5.2.x86_64.rpm .....................................................[done]
Checking for file conflicts: ................................................................................[done]
(1/8) Installing: libapr1-1.6.2-lp150.4.1.x86_64 ............................................................[done]
(2/8) Installing: libbrotlicommon1-1.0.2-lp150.1.3.x86_64 ...................................................[done]
(3/8) Installing: system-user-wwwrun-20170617-lp150.3.25.noarch .............................................[done]
Additional rpm output:
groupadd -r www
useradd -r -s /sbin/nologin -c "WWW daemon apache" -U -d /var/lib/wwwrun wwwrun
usermod -a -G www wwwrun


(4/8) Installing: libapr-util1-1.6.1-lp150.2.5.x86_64 .......................................................[done]
(5/8) Installing: libbrotlienc1-1.0.2-lp150.1.3.x86_64 ......................................................[done]
(6/8) Installing: apache2-utils-2.4.29-lp150.5.2.x86_64 .....................................................[done]
(7/8) Installing: apache2-2.4.29-lp150.5.2.x86_64 ...........................................................[done]
Additional rpm output:
Updating /etc/sysconfig/apache2 ...

Enable and Start Apache :

systemctl enable apache2

systemctl start apache2

systemct
suse15:~ # systemctl enable apache2
Created symlink /etc/systemd/system/httpd.service → /usr/lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/apache.service → /usr/lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /usr/lib/systemd/system/apache2.service.
suse15:~ # systemctl start apache2
suse15:~ # systemctl status apache2
● apache2.service - The Apache Webserver
 Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; vendor preset: disabled)
 Active: active (running) since Wed 2018-04-18 16:04:04 EDT; 2s ago
 Main PID: 8616 (httpd-prefork)
 Status: "Processing requests..."
 Tasks: 6
 CGroup: /system.slice/apache2.service
 ├─8616 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Incl
 ├─8622 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Incl
 ├─8623 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Incl
 ├─8624 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Incl
 ├─8625 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Incl
 └─8626 /usr/sbin/httpd-prefork -DSYSCONFIG -C PidFile /var/run/httpd.pid -C Include /etc/apache2/sysconfig.d//loadmodule.conf -C Incl

Apr 18 16:04:04 suse15 systemd[1]: Starting The Apache Webserver…
Apr 18 16:04:04 suse15 systemd[1]: Started The Apache Webserver.
lines 1-16/16 (END)

Add  apache  to the Firewall rules and  reload the firewall to activate the rule :

firewall-cmd --permanent --add-service=http
success
firewall-cmd --reload

Create Home page : 

Find Document Root directory

cat /etc/apache2/default-server.conf | grep -i DocumentRoot | grep www
DocumentRoot "/srv/www/htdocs"

Create index page :

cd /srv/www/htdocs/
echo “<h1>This is Apache OpenSUSE Leap 15. from Osradar team</h1>” > index.html

Now check http://ip or http://fqdn

Install and Configure MariaDB

MariaDB has become the standard MySQL server alternative for many Linux distributions

Install MariaDB server and client.

suse15:/ # zypper in mariadb mariadb-client
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following 8 NEW packages are going to be installed:
 libJudy1 libmariadb3 libpq5 mariadb mariadb-client mariadb-errormessages psqlODBC unixODBC

The following recommended package was automatically selected:
 psqlODBC

8 new packages to install.
Overall download size: 19.8 MiB. Already cached: 0 B. After the operation, additional 153.6 MiB will be used.
Continue? [y/n/...? shows all options] (y):
Retrieving package libJudy1-1.0.5-lp150.1.3.x86_64 (1/8), 103.1 KiB (319.1 KiB unpacked)
Retrieving: libJudy1-1.0.5-lp150.1.3.x86_64.rpm ..........................................................................................[done]
Retrieving package libmariadb3-3.0.2-lp150.2.5.x86_64 (2/8), 112.5 KiB (322.9 KiB unpacked)
Retrieving: libmariadb3-3.0.2-lp150.2.5.x86_64.rpm ..........................................................................[done (49.9 KiB/s)]
Retrieving package libpq5-10.3-lp150.1.2.x86_64 (3/8), 171.8 KiB (660.5 KiB unpacked)
Retrieving: libpq5-10.3-lp150.1.2.x86_64.rpm .............................................................................................[done]
Retrieving package mariadb-errormessages-10.2.13-lp150.2.3.noarch (4/8), 220.5 KiB ( 2.2 MiB unpacked)
Retrieving: mariadb-errormessages-10.2.13-lp150.2.3.noarch.rpm ...........................................................................[done]
Retrieving package unixODBC-2.3.6-lp150.1.1.x86_64 (5/8), 307.7 KiB ( 1.0 MiB unpacked)
Retrieving: unixODBC-2.3.6-lp150.1.1.x86_64.rpm ..........................................................................................[done]
Retrieving package mariadb-client-10.2.13-lp150.2.3.x86_64 (6/8), 1.1 MiB ( 25.6 MiB unpacked)
Retrieving: mariadb-client-10.2.13-lp150.2.3.x86_64.rpm ....................................................................[done (850.2 KiB/s)]
Retrieving package psqlODBC-10.01.0000-lp150.1.1.x86_64 (7/8), 391.9 KiB ( 1.3 MiB unpacked)
Retrieving: psqlODBC-10.01.0000-lp150.1.1.x86_64.rpm .......................................................................[done (856.1 KiB/s)]
Retrieving package mariadb-10.2.13-lp150.2.3.x86_64 (8/8), 17.4 MiB (122.1 MiB unpacked)
Retrieving: mariadb-10.2.13-lp150.2.3.x86_64.rpm .............................................................................[done (3.7 MiB/s)]
Checking for file conflicts: .............................................................................................................[done]
(1/8) Installing: libJudy1-1.0.5-lp150.1.3.x86_64 ........................................................................................[done]
(2/8) Installing: libmariadb3-3.0.2-lp150.2.5.x86_64 .....................................................................................[done]
(3/8) Installing: libpq5-10.3-lp150.1.2.x86_64 ...........................................................................................[done]
(4/8) Installing: mariadb-errormessages-10.2.13-lp150.2.3.noarch .........................................................................[done]
(5/8) Installing: unixODBC-2.3.6-lp150.1.1.x86_64 ........................................................................................[done]
(6/8) Installing: mariadb-client-10.2.13-lp150.2.3.x86_64 ................................................................................[done]
Additional rpm output:
usermod: no changes
(7/8) Installing: psqlODBC-10.01.0000-lp150.1.1.x86_64 ...................................................................................[done]
Additional rpm output:
odbcinst: Driver installed. Usage count increased to 1.
 Target directory is /etc/unixODBC


(8/8) Installing: mariadb-10.2.13-lp150.2.3.x86_64 .......................................................................................[done]
Additional rpm output:
usermod: no changes


Update notifications were received from the following packages:
mariadb-10.2.13-lp150.2.3.x86_64 (/var/adm/update-messages/mariadb-10.2.13-lp150.2.3-something)

 

Enable and start MariaDB 

Now let’s create MariaDB root password 

suse15:~ # 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): <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.
By default, MariaDB comes with a database named 'test' that anyone can
 access. This is also intended only for testing, and should be removed
 be
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
 installation should now be secure.

Thanks for using MariaDB!

Test MariaDB root password:

Log in and  create osradar database

Install PHP7 and Related Modules 

suse15:~ # zypper install php7 php7-mysql apache2-mod_php7
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following 12 NEW packages are going to be installed:
 apache2-mod_php7 php7 php7-ctype php7-dom php7-iconv php7-json php7-mysql php7-pdo php7-sqlite php7-tokenizer php7-xmlreader php7-xmlwriter

The following 8 recommended packages were automatically selected:
 php7-ctype php7-dom php7-iconv php7-json php7-sqlite php7-tokenizer php7-xmlreader php7-xmlwriter

The following 4 packages are suggested, but will not be installed:
 php7-gd php7-gettext php7-mbstring php7-pear

12 new packages to install.

Enable PHP7 and restart Apache

a2enmod php7
systemctl restart apache2

Create PHP Test  page

 vi /srv/www/htdocs/test.php

Put the following PHP code into the file.

<?php phpinfo(); ?>

Save and exit.

Check now http://ip/test.php

Install phpMyAdmin

If you are not a professional on the command line, this tool will help you toMySQLge mysql/MariaDB  databases

suse15:~ #  zypper install phpMyAdmin

Loading repository data....

Resolving package dependencies...




The following 11 NEW packages are going to be installed:

  libzip5 php7-bz2 php7-curl php7-gd php7-gettext php7-mbstring php7-openssl php7-zip php7-zlib phpMyAdmin pwgen




The following 2 recommended packages were automatically selected:

  php7-curl php7-zip




11 new packages to install.

Overall download size: 7.9 MiB. Already cached: 0 B. After the operation, additional 36.7 MiB will be used.

Continue? [y/n/...? shows all options] (y): y

Restart  Apache

Systemctl restart  apache2

Now check  phpMyadmin login page :

your-server-ip/phpMyAdmin

 

You are ready to go! Now, you can manage your server. Let us know if this tutorial working for you and if you still need any help. Cheers !!!

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

3 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article