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.
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
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.
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.
Next is Apache. Apache reads Apache. By installing Apache, you will be able to use the functions of the web server.
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.
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.
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.
Copy and paste the following command and execute it.
By the way, don't enter
# in the code.
# yum -y install httpd
Check the startup status
# systemctl status httpd
# systemctl start httpd.service
# systemctl enable httpd.service
Check the status of automatic startup
# systemctl is-enabled httpd.service
Permanently disable SElinux (change ʻenforcing
# vi /etc/selinux/config
# systemctl stop firewalld
# systemctl disable firewalld
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.
Install repository file
# yum -y install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# yum -y install mysql mysql-devel mysql-server mysql-utilities
# vi /etc/my.cnf
Add the following to
[mysqld] in my.cnf
character-set-server = utf8
# 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
> FLUSH PRIVILEGES;
Log out of MySQL
# systemctl enable mysqld.service
Check the status of automatic startup
# systemctl is-enabled mysqld.service
# systemctl restart mysqld
This completes the MySQL installation.
EPEL repository added
# yum install epel-release
Remi repository added
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
# yum install --enablerepo=remi,remi-php70 php php-mbstring php-devel php-pdo php-gd
# 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
# 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.
This completes the LAMP environment construction.
When you publish your website, put the files you want to publish in the
/ var / www / html folder.