[LINUX] Summary of how to build a LAMP + Wordpress environment with Sakura VPS

Summary of how to build a LAMP + Wordpress environment with Sakura VPS

I built a LAMP environment with Sakura VPS for learning, so I will summarize the procedure.

table of contents

Operating environment

OS : macOS Mojave 10.14.6 VPS OS : centOS


Apply for Sakura VPS

  1. Visit Sakura's website> VPS> Free trial for 2 weeks Add the server to the cart and apply.

  2. Log in with the ID and password provided in the email and log in to the VPS control panel.

  3. Settings> OS installation

This completes the process from applying for Sakura VPS to installing the OS.

ssh connection

Next, I will summarize the procedure for setting up an SSH connection to connect to a VPS on the Internet from a local PC.

1. Start Terminal and log in with root privileges

Start Terminal with your MAC.

Then connect with the following ssh command. The password was entered when the OS was installed.

$ ssh root@IP address of VPS

2. Software update

$ yum update

3. Creating a general user

$ adduser jun1 #user added
$ passwd jun1 #password setting

Set to use sudo

$ visudo
wheel ALL=(ALL) ALL #Uncomment

Add jun1 user to wheel group

$ usermod -aG wheel jun1
$ groups jun1
jun1 : jun1 wheel

Check if you can log in with jun1

$ ssh jun1@IP address of VPS
$password input

4. ssh key authentication settings

Start and run the terminal on your local PC

MAC$ ssh-keygen -t rsa -v
MAC$ ls ~/.ssh
config		id_rsa		id_rsa.pub	known_hosts

Connect to VPS with ssh

VPS$ mkdir .ssh
VPS$ chmod 700 .ssh

Transfer public key from local PC to VPS

Local PC

MAC$ scp ~/.ssh/id_rsa.pub jun1@IP address of VPS:~/.ssh/authorized_keys
MAC$Enter VPS password

Log in to the server using the key

Local PC

MAC$ ssh -i ~/.ssh/id_rsa jun1@IP address of VPS

Security settings for ssh connections

1. Port number setting


$ sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.ort #Backup of configuration file
$ sudo vim /etc/ssh/sshd_config

Search for Port, delete #, 22-> 56789 (any number is acceptable)

2. Disable password authentication

Search for PasswordAuthentication and Change to no

3. Disable root login

Search with PermitRootLogin and change to no

4. Check the configuration file


$ sudo sshd -t #Check the configuration file for syntax errors.OK if nothing comes out
$ sudo systemctl restart sshd #Restart sshd

5. Firewall settings


$ sudo cp /usr/lib/firewalld/services/ssh.xml /etc/firewalld/services/ssh-56789.xml

$ sudo vim /etc/firewalld/services/ssh-56789.xml

Change port number to 22-> 56789


$ sudo firewall-cmd --reload
$ sudo firewall-cmd --permanent --add-service=ssh-56789
$ sudo firewall-cmd --reload
$ sudo firewall-cmd --list-all

6. SSH operation check

Open another tab without closing the terminal opened above


$ ssh -p 56789 -i ~/.ssh/id_rsa jun1@IP address of VPS

7. Remove ssh from firewall


$ sudo firewall-cmd --permanent --remove-service=ssh
$ sudo firewall-cmd --reload

Finally, just in case, check if you can connect with ssh


$ ssh -p 56789 -i ~/.ssh/id_rsa jun1@IP address of VPS

apache installation


$ sudo yum install httpd 

Start apache


$ sudo systemctl start httpd
$ systemctl status httpd
#Check if it is displayed as Active

Firewall settings


$ sudo firewall-cmd --add-service=http --zone=public --permanent
$ sudo firewall-cmd --add-service=https --zone=public --permanent
$ sudo systemctl restart firewalld

Sakura VPS packet filter settings

Sakura VPS Control Panel> Settings> Packet Filters> Allow WEB

Checking Apache operation from a browser

Enter the IP address of the VPS in the browser, and if the following test page is displayed, it is OK


Apache autostart settings


$sudo systemctl enable httpd

Permission settings

Change ownership of the document root to apache.


$sudo groupadd web #Creating a group
$sudo usermod -aG web jun1 #Add user to group


$sudo chown apache:web /va/www/html/
$sudo chmod -R 775 /var/www/html/

Create an html file and check the operation of Apache


$ vim /var/www/html/index.html
#Edit and save as appropriate

Open from a browser and check

Domain settings

Purchase from domain acquisition site

This time, register as a member of the value domain and purchase.

DNS settings

Log in to your value domain and set up your DNS Check the details from each domain site.

Value domain setting screen

a VPS IP address

Enter the domain in the browser and check if it is displayed

Repository settings

Install two repositories.

epel repository (Linux repository) remi repository (PHP repository)

epel repository


$sudo yum repolist
#If there is no epel repository, execute the following
$sudo yum install epel

remi repository

Copy the remi repository URL from your browser



$sudo yum localinstall remi url

php installation

Check the version that can be installed


$ yum list available | grep php-

Check php71-common.x86_64


$ sudo yum --enablerepo=remi-php71 install php php-devel php-mysql php-gd php-mbstring

Apache restart


$ sudo systemctl restart httpd

PHP settings


$ sudo cp /etc/php.ini /etc/php.ini.org #Backup of configuration file
$ sudo vim /etc/php.ini

Change file upload limit


post_max_size = 128M #8M -> 128M
upload_max_filesize = 128M #2M -> 128M

Apache restart


$ sudo systemctl restart httpd

PHP operation check


echo 'Hello World';

Enter the domain name in your browser and check index.php

Install mysql

MariaDB removal


$ sudo yum remove mariadb-libs
$ sudo rm -rf /var/lib/mysql

MySQL installation

Install MySQL 5.7


$ sudo yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm 
$ sudo yum install mysql-community-server

MySQL settings


$ sudo systemctl start mysqld
$ sudo cat /var/log/mysqld.log | grep 'temporary password' #Check the initial connection password


$ mysql_secure_installation
#Below, set as instructed


$ mysql -u root -p
#Check if you can log in

Change character code to UTF


$ sudo vim /etc/my.conf




$ sudo systemctl restart mysqld

Auto start settings


$ sudo systemctl enable mysqld

ssl settings

Set up a virtual host to use certbot


$ sudo vim /etc/httpd/conf.d/Domain name.conf

Domain name.conf

<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName Domain name

Install certbot

Select software and OS from the certbot website


$ sudo vim install certbot-apache

Get a certificate


$ sudo certbot --apache

Operation check

Enter the domain name in the browser and check if it is https

install wordpress

DB preparation


$ mysql -u root -p 
mysql> create database myblog;
mysql> create user 'myblog_user'@'localhost' identified with mysql_native_password by 'Any password'
mysql> grant all privileges on myblog.* to 'myblog_user'@'localhost';
mysql> flush privileges;

download wordpress


$ wget https://ja.wordpress.org/latest-ja.tar.gz

$ sudo tart -zxvf latest-ja.tar.gz
-C /var/www/
#Extract the compressed file

$sudo chown -R apache:web wordpress/

$sudo vim /etc/httpd/conf/httpd.conf


DocumentRoot "/var/www/wordpress"

<Directory "/var/www/wordpress">

Domain name.conf

DocumentRoot /var/www/wordpress

Domain name-le-ssl.conf

DocumentRoot /var/www/wordpress

Wordpress confirmation

Access the domain and check if the following page is displayed image.png

At the end

This time, I summarized the contents of learning to build a LAMP environment on Sakura VPS.

I learned Linux commands.

Recommended Posts

Summary of how to build a LAMP + Wordpress environment with Sakura VPS
How to build a sphinx translation environment
How to build a LAMP environment using Vagrant and VirtulBox Note
Here's a brief summary of how to get started with Django
How to build a development environment for TensorFlow (1.0.0) (Mac)
How to build a Python environment on amazon linux 2
Summary of how to share state with multiple functions
Build a LAMP environment [CentOS 7]
Install LAMP on Amazon Linux 2 and build a WordPress environment.
How to build a new python virtual environment on Ubuntu
How to develop in a virtual environment of Python [Memo]
How to display a list of installable versions with pyenv
Build a LAMP environment with Vagrant (Linux + Apache + MySQL + PHP)
Summary of how to use pandas.DataFrame.loc
Summary of how to use csvkit
[Hugo] Summary of how to add pages to sites built with Learn
Node.js: How to kill offspring of a process started with child_process.fork ()
How to build Python and Jupyter execution environment with VS Code
[Python] Summary of how to use pandas
Easily build a development environment with Laragon
How to add a package with PyCharm
I want to build a Python environment
Build a Fast API environment with docker-compose
[Python2.7] Summary of how to use unittest
Build WordPress on CentOS 8 in LAMP environment
[Linux] Build a jenkins environment with Docker
Build a python virtual environment with pyenv
Summary of how to use Python list
[Python2.7] Summary of how to use subprocess
Build a modern Python environment with Neovim
Summary of how to write AWS Lambda
[Linux] Build a Docker environment with Amazon Linux 2
[EC2] How to take a screen capture of your smartphone with selenium
[Introduction to Python] How to sort the contents of a list efficiently with list sort
Steps to build a Django environment with Win10 WSL Ubuntu18.04 + Anaconda + Apache2
How to calculate the volatility of a brand
Build a LAMP environment on your local Docker
Build a LAMP environment in a very short time
How to read a CSV file with Python 2/3
Build a C language development environment with a container
A simple example of how to use ArgumentParser
How to share a virtual environment [About requirements.txt]
Build a WardPress environment on AWS with pulumi
How to create a Python virtual environment (venv)
Summary of how to import files in Python 3
[Latest] How to build Java environment on Ubuntu
Build a python environment with ansible on centos6
How to build an environment for using multiple versions of Python on Mac
How to develop a cart app with Django
Find out how to divide a file with a certain number of lines evenly
How to make a dictionary with a hierarchical structure.
I tried to build an environment of Ubuntu 20.04 LTS + ROS2 with Raspberry Pi 4
[Python] Build a Django development environment with Docker
Create a python3 build environment with Sublime Text3
Summary of how to use MNIST in Python
Build a Django environment with Vagrant in 5 minutes
How to apply updlock, rowlock, etc. with a combination of SQLAlchemy and SQLServer
How to specify attributes with Mock of python
How to implement "named_scope" of RubyOnRails with Django
[Memo] Build a virtual environment with Pyenv + anaconda
Build a virtual environment with pyenv and venv