Inhaltsverzeichnis
More about LAMP
Assumptions
Step #1: Install Apache on a CentOS 7 / RHEL 7 server
Enable the httpd service at boot time
Start the httpd service on a CentOS/RHEL v7.x
Stop the httpd service on a CentOS/RHEL v7.x
Restart the httpd service on a CentOS/RHEL v7.x
Finding the httpd service status on a CentOS/RHEL v7.x
Gracefully restart the httpd service on a CentOS/RHEL v7.x
Test httpd/Apache configuration file for errors on a CentOS/RHEL v7.x
httpd service default configuration
Step #2: Install MariaDB on a CentOS 7 / RHEL 7 server
Securing MariaDB
Test MariaDB installation
Step #3: Install PHP on a CentOS/RHEL v7.x
Test PHP on your server
Heim Datenbank MySQL-Tutorial CentOS and RHEL 7: Install Linux, Apache, MariaDB, PHP (LAMP_MySQL

CentOS and RHEL 7: Install Linux, Apache, MariaDB, PHP (LAMP_MySQL

Jun 01, 2016 pm 01:07 PM

RHELCentOSApacheLAMPMariaDB

I

am new Red Hat Enterprise Linux version 7 user/sysadmin/developer. This version made the big number change for RHEL 7/CentOS 7. How can I install LAMP (Linux, Apache, MariaDB, PHP) stack on a RHEL version 7 or CentOS Linux version 7 using CLI or over ssh based session?
Tutorial details
Difficulty Easy(rss)
Root privileges Yes
Requirements CentOS/RHEL v7.x
Estimated completion time 20m

RHEL 7 has been released and CentOS Linux 7 is on its way with many notable changes. This guide explains how to install LAMP server.

More about LAMP

LAMP is nothing but a software bundle or a platform consisting of Linux operating system, Apache web-server, MySQL database server and PHP (or Perl/Python)scripting language. The LAMP stack is used for building heavy-duty dynamic web sites entirely out of free and open-source software. In this tutorial, I'm going to explain how to Linux, Apache, MySQL/MariaDB (drop in replacement for MySQL), PHP (LAMP) stack On CentOS 7 or RHEL 7.

Assumptions

  • I'm assuming that you've installed basic RHEL 7 or CentOS 7 server. Open the Terminal app and type the following command as root user.
  • You must be familiar with theyum command
  • You must know your Server's IP address. Use the following command to find your server's ip address for eth0 interface:
    ifconfig eth0
    OR
    ip a show eth0
    OR
    ip addr list eth0 | awk '/inet /{sub(///[0-9]+/,"",$2); print $2}'
    OR
    ifconfig eth0 | awk '/inet /{print $2}'
    10.41.143.156
  • I'm going to use IP address 10.41.143.156 for testing purpose. Feel free to replace this IP address with your actual private or public IP address.

Enough talk, let's set up LAMP stack.

Step #1: Install Apache on a CentOS 7 / RHEL 7 server

Type the followingyum commandto install Apache web-server:

sudo yum install httpd

Sample outputs:

Loaded plugins: amazon-id, rhui-lbResolving Dependencies--> Running transaction check---> Package httpd.x86_64 0:2.4.6-17.el7 will be installed--> Processing Dependency: httpd-tools = 2.4.6-17.el7 for package: httpd-2.4.6-17.el7.x86_64--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-17.el7.x86_64--> Running transaction check---> Package httpd-tools.x86_64 0:2.4.6-17.el7 will be installed---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed--> Finished Dependency Resolution Dependencies Resolved ====================================================================================================== PackageArchVersion Repository Size======================================================================================================Installing: httpdx86_642.4.6-17.el7rhui-REGION-rhel-server-releases1.2 MInstalling for dependencies: httpd-toolsx86_642.4.6-17.el7rhui-REGION-rhel-server-releases 77 k mailcapnoarch2.1.41-2.el7rhui-REGION-rhel-server-releases 31 k Transaction Summary======================================================================================================Install1 Package (+2 Dependent packages) Total download size: 1.3 MInstalled size: 3.9 MIs this ok [y/d/N]: yDownloading packages:(1/3): httpd-tools-2.4.6-17.el7.x86_64.rpm |77 kB00:00:00(2/3): httpd-2.4.6-17.el7.x86_64.rpm | 1.2 MB00:00:00(3/3): mailcap-2.1.41-2.el7.noarch.rpm |31 kB00:00:00------------------------------------------------------------------------------------------------------Total 2.0 MB/s | 1.3 MB00:00:00Running transaction checkRunning transaction testTransaction test succeededRunning transactionInstalling : httpd-tools-2.4.6-17.el7.x86_641/3Installing : mailcap-2.1.41-2.el7.noarch2/3Installing : httpd-2.4.6-17.el7.x86_643/3Verifying: mailcap-2.1.41-2.el7.noarch1/3Verifying: httpd-tools-2.4.6-17.el7.x86_642/3Verifying: httpd-2.4.6-17.el7.x86_643/3 Installed:httpd.x86_64 0:2.4.6-17.el7 Dependency Installed:httpd-tools.x86_64 0:2.4.6-17.el7 mailcap.noarch 0:2.1.41-2.el7 Complete! 
Nach dem Login kopieren

Enable the httpd service at boot time

To make sure the httpd service start automatically at the boot time, enter:

sudo systemctl enable httpd.service

Sample outputs:

ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
Nach dem Login kopieren

The following command will disable the httpd service at the boot time:

sudo systemctl disable httpd.service

Sample outputs:

rm '/etc/systemd/system/multi-user.target.wants/httpd.service'
Nach dem Login kopieren

Start the httpd service on a CentOS/RHEL v7.x

sudo systemctl start httpd.service

At this stage, you can point your web-browser to your server's IP address such as http://10.41.143.156). The following page should display on screen:

Fig.01: Check if Apache is Running on CentOS/RHEL 7 server

Fig.01: Check if Apache is Running on CentOS/RHEL 7 server

Stop the httpd service on a CentOS/RHEL v7.x

sudo systemctl stop httpd.service

Restart the httpd service on a CentOS/RHEL v7.x

sudo systemctl restart httpd.service

Finding the httpd service status on a CentOS/RHEL v7.x

To verify that the httpd service is running, enter:

systemctl is-active httpd.service

Sample outputs:

active
Nach dem Login kopieren

Gracefully restart the httpd service on a CentOS/RHEL v7.x

sudo apachectl graceful

Test httpd/Apache configuration file for errors on a CentOS/RHEL v7.x

sudo apachectl configtest

Sample outputs:

Syntax OK
Nach dem Login kopieren

httpd service default configuration

  1. Default config file: /etc/httpd/conf/httpd.conf
  2. Configuration files which load modules : /etc/httpd/conf.modules.d/ directory (e.g. PHP)
  3. Select MPMs (Processing Model) as loadable modules [worker, prefork (default)] and event: /etc/httpd/conf.modules.d/00-mpm.conf
  4. Default ports: 80 and 443 (SSL)
  5. Default log files: /var/log/httpd/{access_log,error_log}

Step #2: Install MariaDB on a CentOS 7 / RHEL 7 server

MariaDB An enhanced, drop-in replacement for MySQL server. RHEL/CentOS v7.x shifts from MySQL to MariaDB for its database management system needs. Type the followingyum commandto install MariaDB server:

sudo yum install mariadb-server mariadb

To start mariadb, type:

sudo systemctl start mariadb.service

To make sure the mariadb service start automatically at the boot time, enter:

sudo systemctl enable mariadb.service

Sample outputs:

ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'
Nach dem Login kopieren

To stop/restart and disable mariadb service use the following commands:

sudo systemctl stop mariadb.service #<h3 id="Securing-MariaDB">Securing MariaDB</h3> <p>Type the following command:</p> <code>sudo /usr/bin/mysql_secure_installation</code> <p>Sample outputs:</p><pre class="brush:php;toolbar:false">NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE!PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the currentpassword for the root user.If you've just installed MariaDB, andyou 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): <strong>PRESS-ENTER-KEY</strong>OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.Set root password? [Y/n] YNew password: <strong>YOUR-NEW-PASSWORD-HERE</strong>Re-enter new password: <strong>YOUR-NEW-PASSWORD-HERE</strong>Password updated successfully!Reloading privilege tables.. ... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem.This is intended only for testing, and to make the installationgo a bit smoother.You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] <strong>Y</strong> ... Success!Normally, root should only be allowed to connect from 'localhost'.Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] <strong>Y</strong> ... Success!By default, MariaDB comes with a database named 'test' that anyone canaccess.This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] <strong>Y</strong> - Dropping test database... ... Success! - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] <strong>Y</strong> ... Success!Cleaning up...All done!If you've completed all of the above steps, your MariaDBinstallation should now be secure.Thanks for using MariaDB!
Nach dem Login kopieren

Test MariaDB installation

Type the following command

mysql -u root -p

Sample outputs:

Fig.02: Mariadb test connection on a CentOS / RHEL Linux v7.x

Fig.02: Mariadb test connection on a CentOS / RHEL Linux v7.x

Step #3: Install PHP on a CentOS/RHEL v7.x

To install PHP and modules such as gd/msyql type the followingyum command:

sudo yum install php php-mysql php-gd php-pear

You must restart the httpd (Apache) service, enter:

sudo systemctl restart httpd.service

To search all other php modules, type:

sudo yum search php-

Sample outputs:

php-cli.x86_64 : Command-line interface for PHPphp-common.x86_64 : Common files for PHPphp-gd.x86_64 : A module for PHP applications for using the gd graphics libraryphp-ldap.x86_64 : A module for PHP applications that use LDAPphp-mysql.x86_64 : A module for PHP applications that use MySQL databasesphp-odbc.x86_64 : A module for PHP applications that use ODBC databasesphp-pdo.x86_64 : A database access abstraction module for PHP applicationsphp-pear.noarch : PHP Extension and Application Repository frameworkphp-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemonphp-pgsql.x86_64 : A PostgreSQL database module for PHPphp-process.x86_64 : Modules for PHP script using system process interfacesphp-recode.x86_64 : A module for PHP applications for using the recode libraryphp-soap.x86_64 : A module for PHP applications that use the SOAP protocolphp-xml.x86_64 : A module for PHP applications which use XMLphp-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
Nach dem Login kopieren

To find more info about a module type:

sudo yum info php-pgsql

To install php module called php-pgsql type:

sudo yum install php-pgsql

Test PHP on your server

Create a file called /var/www/html/test.php as follows:

sudo vi /var/www/html/test.php

Append the following code:

 <?php phpinfo(INFO_GENERAL);?> 
Nach dem Login kopieren

Save and close the file. Point your web-browser to your server's IP address such as http://10.41.143.156/info.php (feel free to replace the 10.41.143.156 with your actual IP address):

http://10.41.143.156/info.php
Nach dem Login kopieren
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

Heiße KI -Werkzeuge

Undresser.AI Undress

Undresser.AI Undress

KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover

AI Clothes Remover

Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool

Undress AI Tool

Ausziehbilder kostenlos

Clothoff.io

Clothoff.io

KI-Kleiderentferner

AI Hentai Generator

AI Hentai Generator

Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)
2 Wochen vor By 尊渡假赌尊渡假赌尊渡假赌
Repo: Wie man Teamkollegen wiederbelebt
4 Wochen vor By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Abenteuer: Wie man riesige Samen bekommt
4 Wochen vor By 尊渡假赌尊渡假赌尊渡假赌

Heiße Werkzeuge

Notepad++7.3.1

Notepad++7.3.1

Einfach zu bedienender und kostenloser Code-Editor

SublimeText3 chinesische Version

SublimeText3 chinesische Version

Chinesische Version, sehr einfach zu bedienen

Senden Sie Studio 13.0.1

Senden Sie Studio 13.0.1

Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver CS6

Dreamweaver CS6

Visuelle Webentwicklungstools

SublimeText3 Mac-Version

SublimeText3 Mac-Version

Codebearbeitungssoftware auf Gottesniveau (SublimeText3)

Reduzieren Sie die Verwendung des MySQL -Speichers im Docker Reduzieren Sie die Verwendung des MySQL -Speichers im Docker Mar 04, 2025 pm 03:52 PM

In diesem Artikel wird die Optimierung von MySQL -Speicherverbrauch in Docker untersucht. Es werden Überwachungstechniken (Docker -Statistiken, Leistungsschema, externe Tools) und Konfigurationsstrategien erörtert. Dazu gehören Docker -Speichergrenzen, Tausch und CGroups neben

So lösen Sie das Problem der MySQL können die gemeinsame Bibliothek nicht öffnen So lösen Sie das Problem der MySQL können die gemeinsame Bibliothek nicht öffnen Mar 04, 2025 pm 04:01 PM

Dieser Artikel befasst sich mit MySQLs Fehler "Die freigegebene Bibliotheksfehler". Das Problem ergibt sich aus der Unfähigkeit von MySQL, die erforderlichen gemeinsam genutzten Bibliotheken (.SO/.dll -Dateien) zu finden. Lösungen beinhalten die Überprüfung der Bibliotheksinstallation über das Paket des Systems m

Wie verändern Sie eine Tabelle in MySQL mit der Änderungstabelleanweisung? Wie verändern Sie eine Tabelle in MySQL mit der Änderungstabelleanweisung? Mar 19, 2025 pm 03:51 PM

In dem Artikel werden mithilfe der Änderungstabelle von MySQL Tabellen, einschließlich Hinzufügen/Löschen von Spalten, Umbenennung von Tabellen/Spalten und Ändern der Spaltendatentypen, erläutert.

Führen Sie MySQL in Linux aus (mit/ohne Podman -Container mit Phpmyadmin) Führen Sie MySQL in Linux aus (mit/ohne Podman -Container mit Phpmyadmin) Mar 04, 2025 pm 03:54 PM

Dieser Artikel vergleicht die Installation von MySQL unter Linux direkt mit Podman -Containern mit/ohne phpmyadmin. Es beschreibt Installationsschritte für jede Methode und betont die Vorteile von Podman in Isolation, Portabilität und Reproduzierbarkeit, aber auch

Was ist SQLite? Umfassende Übersicht Was ist SQLite? Umfassende Übersicht Mar 04, 2025 pm 03:55 PM

Dieser Artikel bietet einen umfassenden Überblick über SQLite, eine in sich geschlossene, serverlose relationale Datenbank. Es beschreibt die Vorteile von SQLite (Einfachheit, Portabilität, Benutzerfreundlichkeit) und Nachteile (Parallelitätsbeschränkungen, Skalierbarkeitsprobleme). C

Ausführen mehrerer MySQL-Versionen auf macOS: Eine Schritt-für-Schritt-Anleitung Ausführen mehrerer MySQL-Versionen auf macOS: Eine Schritt-für-Schritt-Anleitung Mar 04, 2025 pm 03:49 PM

In diesem Handbuch wird die Installation und Verwaltung mehrerer MySQL -Versionen auf macOS mithilfe von Homebrew nachgewiesen. Es betont die Verwendung von Homebrew, um Installationen zu isolieren und Konflikte zu vermeiden. Der Artikel Details Installation, Starten/Stoppen von Diensten und Best PRA

Wie konfiguriere ich die SSL/TLS -Verschlüsselung für MySQL -Verbindungen? Wie konfiguriere ich die SSL/TLS -Verschlüsselung für MySQL -Verbindungen? Mar 18, 2025 pm 12:01 PM

In Artikel werden die Konfiguration der SSL/TLS -Verschlüsselung für MySQL, einschließlich der Erzeugung und Überprüfung von Zertifikaten, erläutert. Das Hauptproblem ist die Verwendung der Sicherheitsauswirkungen von selbstsignierten Zertifikaten. [Charakterzahl: 159]

Was sind einige beliebte MySQL -GUI -Tools (z. B. MySQL Workbench, PhpMyAdmin)? Was sind einige beliebte MySQL -GUI -Tools (z. B. MySQL Workbench, PhpMyAdmin)? Mar 21, 2025 pm 06:28 PM

In Artikel werden beliebte MySQL -GUI -Tools wie MySQL Workbench und PhpMyAdmin beschrieben, die ihre Funktionen und ihre Eignung für Anfänger und fortgeschrittene Benutzer vergleichen. [159 Charaktere]

See all articles