I'm finally (sparsely) around the infrastructure, I tried to build a LAMP environment to overcome it, so it is a memorandum.
【environment】 ・ A 2-week trial server borrowed from Sakura's VPS ・ CentOS8 ・ MariaDB ・ PHP
LINUX OS ** Apache ** web server ** MySQL / MariaDB ** database ** PHP, Perl ** program Happy set.
It's like a classic figure that creates a dynamic site.
We use the popular web server Apache. https://httpd.apache.org/
Install with the following command.
$ sudo yum -y install httpd
The Apache configuration file is
If you look at this file, you can see that the setting file is written in the format of
setting item name setting value.
Those starting with "#" are commented out.
Let's edit the ** Server Name ** item below. This is an item for setting the web server name.
$ sudo vim /etc/httpd/conf/httpd.conf
The ServerName is commented out, so remove the "#" to enable it. Basically, it seems to describe the host name here.
When you are done, check the syntax with the following command.
$ httpd -t
If Syntax is OK, it's okay. If it fails, an error message will appear, so make corrections referring to it.
$ sudo systemctl start httpd.service $ sudo systemctl enable httpd.service
It is a command to set to start automatically when the system starts with start and enable.
First, set the firewall. Initially, access to number 80 is not allowed.
$ sudo firewall-cmd --permanent --add-service=http $ sudo firewall-cmd --reload
Reloading is completed after setting with the above command.
You can open the initial Apache page with
http: // VPS IP address /.
.. .. .. .. I had a hard time not opening here. Sakura's VPS people should be careful. By default, Sakura's VPS has a service called "packet filter". If you do not allow number 80 here, it will be played even if the firewall settings are allowed.
Click here Control Panel After logging in, click the Packet Filter tab. Add the connection permission port. This explanation was easy to understand. https://vps-news.sakura.ad.jp/vps-pf/
If the initial page is displayed without any problem, please try arranging various html.
If you place html directly under
/ var / www / html, it will be viewable according to the routing.
Next is the database.
$ sudo yum -y install mariadb-server mariadb
The above will download the complete set of things you need for mariaDB. Next, edit the configuration file so that it can handle Japanese.
$sudo vim /etc/my-cnf
Since there is a description like the above at the beginning, please add the following immediately after.
$ sudo systemctl start mariadb $ sudo systemctl enable mariadb
As with Apache, set it to start automatically.
MariaDB comes standard with interactive commands for initial setup.
$ sudo mysql_secure_installation
Basically you can answer with y, but
On the way, you will be asked to set a password with
Enter the character string you want to use as the administrator password.
PHP Next is the installation of PHP, the programming language.
sudo -y install php php-mbstring php-gd php-mysql
There are a lot of things, so I will summarize them roughly. -** php ** ・ ・ ・ PHP itself -** php-mbstring ** ・ ・ ・ Package for multi-byte support such as Japanese -** php-gd ** ・ ・ ・ Package for handling image library -** php-mysql ** ・ ・ ・ Package for linking with MySQL / MariaDB
If you hit the following and the version comes out, you have successfully installed it.
$ php -v
You also need to restart Apache once to get Apache and PHP working together.
$ sudo systemctl restart httpd.service
To check if PHP is working properly, create and edit the file with the following command.
sudo vim /var/www/html/test.php
<?php echo phpinfo(); ?>
http: // VPS IP address /test.php on the web and
It's OK if PHP information comes out safely. After checking, please delete test.php for security.
First, connect to MariaDB.
$ mysql -u root -p
You will be asked for the password, so I set it when executing the
Enter your password.
Once the database operation is possible, use the SQL language to create the database user.
CREATE DATABASE db;
Create a database called "db" above.
GRANT ALL PRIVILEGES ON db.* TO "dbuser"@"localhost" IDENTIFIED BY "jfei0a3laas";
Set the user "dbuser" and the password "jfei0a3laas" above. These are optional.
Reload the permission table above.
If the command input is successful, Query OK will be displayed. After entering all of the above, enter ʻexit` to exit MariaDB.
Finally install wordpress.
$ curl -LO http://ja.wordpress.org/latest-ja.tar.gz
Unzip and unpack the installed tar.gz data.
$ tar zxf latest-ja.tar.gz
Move these installed to
/ var / www / html
Make it viewable.
$ sudo mv wordpress /var/www/html
Use the following command to set the right holder. With the -R option You can change the right holder of the files under wordpress at once.
$ sudo chown -R apache:apache /var/www/html/wordpress
Below, wp-config is generated from the template.
$ cd /var/www/html $ sudo mv wp-config-sample.php wp-config.php
$ sudo vim wp-config.php
There are three changes below.
define ('DB_NAME','/ * enter here * /');
define ('DB_USER','/ * fill in here * /');
define ('DB_HOST','/ * fill in here * /');
Originally it is not good for security, but Disable SELinux for study purposes. (Wordpress will not work if it is enabled)
sudo setenforce 0
If you access the route where wordpress is placed, you will see the familiar wordpress screen. You did it!
[Linux server construction / operation guide starting from scratch How to make a web server to learn while running](amazon.co.jp/ Amazon.co.jp/ Linux server construction / operation guide to start from zero-How to make a web server to learn while running-Nakajima- Nowa / dp / 4798146374)
How to use the packet filter [What is the lamp environment? Benefits of building a lamp environment](https://forthewin.co.jp/ikeda_blog/lamp%E7%92%B0%E5%A2%83%E3%81%A3%E3%81%A6%E4%BD% 95% EF% BC% 9Flamp% E7% 92% B0% E5% A2% 83% E3% 82% 92% E6% A7% 8B% E7% AF% 89% E3% 81% 99% E3% 82% 8B% E3% 83% A1% E3% 83% AA% E3% 83% 83% E3% 83% 88) Mysql related memorandum Qiita