[Vagrant] Prepare LAMP development environment with Vagrant (centos + apache + MySQL + PHP)

Leave it as a memo for yourself.

manner

1. Vagrant Box download-mysql, apache, php installation

I searched for various things, but I think the one posted on Masaki Yamada's staff blog is the easiest and most polite, and even beginners can easily build it.

[(External site) Build "CentOS7 + LAMP environment" with VirtualBox + Vagrant](https://www.willstyle.co.jp/blog/2832/ "(External site) VirtualBox + Vagrant with" CentOS7 + LAMP environment " To build ")

If you follow the procedure, access http://192.168.33.10/phpmyadmin and if PHPMyAdmin is displayed, the LAMP environment has been built properly for the time being. The default document root is / var / www / html.

In addition, CentOS time zone, mysql my.cnf adjustment, etc. are necessary, so I will explain how to adjust it later.

2. Adjustment etc.

Host OS side adjustment

Specify the specifications of the guest OS machine

If you like, add the following to your Vagrant file to adjust the guest OS specs.

Vagrant file


#* Additional information`Vagrant.configure("2") do |config|`Is inside.
  config.vm.provider "virtualbox" do |vb|
    vb.cpus = 2
    vb.memory = 2048
    vb.gui = true
  end

vb.gui = true is an option to display the guest OS screen. Maybe it's just me, but sometimes vagrant up fails, so I can't isolate the problem or investigate on the guest OS side without displaying the GUI, so I personally recommend setting it!

Guest OS side (CentOS side) adjustment

Switch to root for the time being before doing any further work.

sudo su - 
#Switch to root and the current directory/Become root

Adjust My.cnf in MySQL for multibyte support

Adjusted by referring to the following article. (Reference article) Make mysql handle Japanese

Set CentOS time zone to Japan

timedatectl set-timezone Asia/Tokyo

Update packages installed on CentOS

I think it will take a lot of time because there may be updates to the kernel etc.

yum update
# -Skip confirmation with y option

** * If you only need security update, do the following **

yum --security update

Finally

If you build up to this point, if things are not going well, you will be able to start from the box with LAMP built, so it is recommended to create a box file. (Reference) [Vagrant] Save the current OS image as a vagrant box and share it with other engineers.

that's all.

Recommended Posts

[Vagrant] Prepare LAMP development environment with Vagrant (centos + apache + MySQL + PHP)
[Environment construction (step debugging)] Windows10 VirtualBox Vagrant centOS7 (GUI) LAMP environment (Linux Apache MySQL [Mariadb] PHP) Laravel
Prepare Python3 environment with CentOS7
Prepare Java development environment with Atom
Prepare a transcendentally simple PHP & Apache environment on Mac with Docker
Prepare Java development environment with VS Code
Lightweight PHP 7.4 development environment created with Docker
Prepare the JVM language development environment with WSL
Prepare the environment of CentOS 8 with Sakura VPS
[Rails] Development with MySQL
Debug the VSCode + Docker + PHP development environment with XDebug.
Rails application development environment construction with Docker [Docker, Rails, Puma, Nginx, MySQL]
Build apache7.4 + mysql8 environment with Docker (with initial data) (your own memo)
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
Build a development environment for Django + MySQL + nginx with Docker Compose
Steps to build a Ruby on Rails development environment with Vagrant
Rails + MySQL environment construction with Docker
Build jooby development environment with Eclipse
[Environment construction with Docker] Rails 6 & MySQL 8
When I tried to build an environment of PHP7.4 + Apache + MySQL with Docker, I got stuck [Windows & Mac]
Build a development environment on AWS EC2 with CentOS7 + Nginx + pm2 + Nuxt.js
Install PHP7.4 to build CentOS7 Laravel environment
Create Spring Boot development environment on Vagrant
CentOS8 + Anaconda + Django development environment construction procedure
Set up ImpressPages 5.0 with LAMP on CentOS 7.3
Create Rails 6 + MySQL environment with Docker compose
Prepare the format environment with "Rails" (VScode)
Edit Mysql with commands in Docker environment
Create a MySQL environment with Docker from 0-> 1
Create Spring Boot-gradle-mysql development environment with Docker
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Laravel + MySQL + phpMyadmin environment construction with Docker
Run Keras with CentOS7 + Anaconda + Django + Apache
Build a Wordpress development environment with Docker
Launch java verification environment locally with Vagrant