[LINUX] Build a LAMP environment [CentOS 7]

Do you know the LAMP environment?

A very important LAMP environment for those who start web services. The content is designed to be understandable even for those who "have never built a LAMP environment" or "do not know what a LAMP environment is in the first place".

First of all, I will explain exactly what the LAMP environment is. In this article, we will proceed with the explanation on CentOS. The commands are slightly different, but the settings and procedures are not much different. I think it will be a reference for building a LAMP environment on Ubuntu and Debian.

table of contents

  1. Who is the target of this article
  2. What is LAMP environment?
  3. Linux installation
  4. Apache installation
  5. MySQL installation
  6. PHP installation
  7. Finally

1. Who is the target of this article

This article is written for the following readers:

--I have never built a LAMP environment ――I don't know what LAMP environment construction is --CentOS can be installed --Linux commands can be used to some extent

If you don't know how to install CentOS, please refer to the following article. [Understanding even beginners] Summary of how to install Linux CentOS

2. What is LAMP environment?

The LAMP environment is indispensable for building a server environment.

-** L ** inux -** A ** pache -** M ** mySQL -** P ** HP

The acronym for is called ** LAMP **. With all of these, you will have an environment in which you can provide Web services. In other words, once you know how to build a LAMP environment, you can easily provide Web services at any time.

What is Linux

First, Linux is the OS (Operating System). Since "Mac OS" and "Windows OS" are installed on the PCs that you often use, you can use them as PCs.

If the OS is not installed, it will be a "machine that looks like a PC". In other words, it is a machine that is pitch black and does not say "yes" or "no" even when the power is turned on. Thanks to some OS installed in the PC, we can use the PC without any inconvenience.

Among them, Linux is OSS, and it is usually free to use. I won't explain it in detail here, but the most famous Linux is "CentOS" and "Ubuntu". It would be nice to take this opportunity to remember.

What is Apache

Next is Apache. Apache reads Apache. By installing Apache, you will be able to use the functions of the web server.

What is MySQL

And MySQL. This is an open source relational database management system. Data is managed using SQL, which is a language for handling data. It is needed to store a huge amount of data called a database. It is used to save data such as member information and login time.

What is PHP

Finally, PHP. PHP stands for Hypertext Preprocessor and is an open source general purpose scripting language suitable for web development. It is required for login processing and handling form data.

3. Linux installation

Download the ISO image from CentOS and use Windows Rufus to boot your USB USB drive. Connect the USB to your PC, launch the BIOS (link) and install CentOS. When the installation is completed normally, the Linux installation is complete.

By the way, there is a pitfall here. That is ** installing an ISO image for a different platform **. Make sure it is for your PC before installing. Even if I install an ISO image for a different platform, the CentOS and Apache installation will complete successfully, but subsequent PHP installations will result in an error.

4. Apache installation

Copy and paste the following command and execute it. By the way, don't enter # in the code.

Apache installation

# yum -y install httpd

Check the startup status

# systemctl status httpd

Start apache

# systemctl start httpd.service

Enable autostart

# systemctl enable httpd.service

Check the status of automatic startup

# systemctl is-enabled httpd.service

Permanently disable SElinux (change ʻenforcing to disabled`)

# vi /etc/selinux/config


Stop firewalld

# systemctl stop firewalld

Disable firewalld

# systemctl disable firewalld 

CentOS restart

# reboot

Check the IP address of your PC and try accessing 192.168. ×. × with your browser. If the following message is displayed, Apache installation is complete.


4. MySQL installation

Install repository file

# yum -y install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

MySQL installation

# yum -y install mysql mysql-devel mysql-server mysql-utilities

Editing my.cnf

# vi /etc/my.cnf

Add the following to [mysqld] in my.cnf

character-set-server = utf8

Start MySQL

# systemctl start mysqld

Log in to MySQL (no password, just log in with Enter key)

# mysql -u root -p

Change root password to any password

> UPDATE mysql.user SET password=password('Any password') WHERE user = 'root';

Reflection of changes


Log out of MySQL

> exit;

Enable autostart

# systemctl enable mysqld.service

Check the status of automatic startup

# systemctl is-enabled mysqld.service

MySQL restart

# systemctl restart mysqld

This completes the MySQL installation.

5. PHP installation

EPEL repository added

# yum install epel-release

Remi repository added

# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

Installation execution

# yum install --enablerepo=remi,remi-php70 php php-mbstring php-devel php-pdo php-gd

Editing php.ini

# vi /etc/php.ini

date.timezone = "Asia/Tokyo"
mbstring.language = Japanese
mbstring.internal_encoding = UTF-8
mbstring.http_input = pass
mbstring.http_output = pass
mbstring.encoding_translation = Off
mbstring.detect_order = auto
mbstring.substitute_character = none
mbstring.func_overload = 0
mbstring.strict_detection = Off

Apache restart

# systemctl restart httpd

Create a test file

# vi /var/www/html/index.php

Write and save the code ↓ that displays info

<?php phpinfo(); ?>

Access from a browser, and if ʻinfo` is displayed as shown below, it's OK.


6. Finally

This completes the LAMP environment construction. When you publish your website, put the files you want to publish in the / var / www / html folder.

7. Reference

-Disable SElinux -CentOS 7-8 Firewall Disable -Create a LAMP environment with centos7

Recommended Posts

Build a LAMP environment [CentOS 7]
Build CentOS8 LAMP
Build a python3 environment on CentOS7
Build WordPress on CentOS 8 in LAMP environment
Build a LAMP environment on your local Docker
Build a LAMP environment in a very short time
Build a machine learning environment
Build a Python environment offline
Build a go environment using Docker
Create a python environment on centos
Install LAMP on Amazon Linux 2 and build a WordPress environment.
Build a LAMP environment with Vagrant (Linux + Apache + MySQL + PHP)
Build a python environment on CentOS 7.7 for your home server
How to build a LAMP environment using Vagrant and VirtulBox Note
Easily build a development environment with Laragon
How to build a sphinx translation environment
Build a python environment on MacOS (Catallina)
Build a Tensorflow environment with Raspberry Pi [2020]
I want to build a Python environment
Build a Fast API environment with docker-compose
[Linux] Build a jenkins environment with Docker
Build a python virtual environment with pyenv
Build a Python + OpenCV environment on Cloud9
Build a modern Python environment with Neovim
[Linux] Build a Docker environment with Amazon Linux 2
Build a CentOS Linux 8 environment with Docker and start Apache HTTP Server
Summary of how to build a LAMP + Wordpress environment with Sakura VPS
Build a WardPress environment on AWS with pulumi
System switching occurs in a CentOS 7 cluster environment
Simply build a Python 3 execution environment on Windows
Build a Django environment on Raspberry Pi (MySQL)
Build a Python environment on Mac (Mountain Lion)
Create a python3 build environment with Sublime Text3
Build a Django environment with Vagrant in 5 minutes
Build a Python development environment on your Mac
[Memo] Build a virtual environment with Pyenv + anaconda
Build a simple Python virtual environment without pyenv
Build a virtual environment with pyenv and venv
Build a Django development environment with Doker Toolbox
Build a Kubernetes environment for development on Ubuntu
Build a Python environment with OSX El capitan
Build a Minecraft plugin development environment in Eclipse
Quickly build a Python Django environment with IntelliJ
Build a mruby development environment for ESP32 (Linux)
Build a Python machine learning environment with a container
Build a Python development environment on Raspberry Pi
Build a python execution environment with VS Code
Static build ffmpeg (CentOS6)
Create a Python environment
Build a Django development environment using pyenv-virtualenv on Mac
# 2 Build a Python environment on AWS EC2 instance (ubuntu18.04)
Build a python virtual environment with virtualenv and virtualenvwrapper
Build a local development environment for Laravel6.X on Mac
Build a machine learning Python environment on Mac OS
Build a python environment for each directory with pyenv-virtualenv
Build a GVim-based Python development environment on Windows 10 (1) Installation
How to build a Django (python) environment on docker
I want to easily build a model-based development environment
Build a Python development environment on Mac OS X
Build a Python virtual environment using venv (Django + MySQL ①)
[Go + Gin] I tried to build a Docker environment