- Creating database
- Connect database to website
- Сервер Apache2 для сайтов на vps-ubuntu >>
- << Настройка Apache завершена, далее создаем пользователя сайтов, и добавляем сайт на сервер Apache
- Настраиваем каталоги
- Добавляем первый сайт на сервер Apache
- Install SSL
- Next, install the NGINX server
- Nginx server installed and configured.
- Add site to NGINX server
- Database installation
- Creating a database user
- Importing large databases via ssh terminal
- FTP Server Installation
- Mail server
- Change time zone
- Post navigation
- What is MySQL
- Creating a MySQL database and a user for it on the example of Beget hosting
- Where can I set up a connection to MySQL in my CMS
- Video tutorial on how to create a MySQL database on Beget hosting
- Step by step instruction in pictures how to create a MySQL database.
Creating database
To create a MySQL database you need to define a Database name, which consisting of (system login)_ (database name) indicated by you, for example begetguide_example. Also you need to create a Password for your connection. You can generate it clicking by
By default the database access is created from the local machine (IP: 127.0.0.1 or localhost). You can also add a database access from a different IP. To do this press the button
next to the respective database. A suggestion to indicate a password for the new database access will then be displayed.
For access to DB from different IP you have to use Host name from Server for external connections in the Connection parameters
Next to each database you will also find three further buttons:
You will also find two buttons next to each access:
— change password;
— delete access.
Connect database to website
If you connect to the database from a remote host, you need to create an appropriate database access and indicate your server name as host in the connection, for example:
host = begetguide.beget.tech
You will find your server name on the main page of the Control Panel in the «Technical information», also you can find it at MySQL in the «Connection parameters».
sudo apt update
sudo apt -y upgrade
Сервер Apache2 для сайтов на vps-ubuntu >>
Установка сервера Apache
sudo apt -y install apache2
Изменяем настройки Apache для дальнейшей установки Nginx
Освободив стандартный порт 80 (на любой свободный)
Если вам будет достаточно одного Apache, то эти настройки менять не нужно. Однако, описанная установка SSL подразумевает наличие и сервера Nginx
Откроем конфигурационный файл настройки портов
sudo nano /etc/apache2/ports.conf
В файле изменим параметр «Listen 80» на другой
Остановим стандартный сайт
sudo a2dissite 000-default
Откроем конфигурационный файл стандартного сайта
sudo nano /etc/apache2/sites-available/000-default.conf
В файле изменим порт «80» на наш новый (который объявлен в теге VirtualHost)
Запускаем стандартный сайт
sudo a2ensite 000-default
Открываем порты в браундмандере
sudo ufw allow 8080
sudo ufw allow «Apache Full»
<< Настройка Apache завершена, далее создаем пользователя сайтов, и добавляем сайт на сервер Apache
Добавление пользователя (замените на ваш пароль и имя пользователя)
Создаем нужные каталоги
Настраиваем каталоги
передаем каталог нашему пользователю
sudo chown ИМЯ:www-data -R /var/www/ИМЯ
chmod -R u=rw,g=r,o=r,a+X /var/www/ИМЯ
Добавляем первый сайт на сервер Apache
Создаем конфигурационный файл с расширением .conf
sudo nano /etc/apache2/sites-available/FIRST_SITE. RU.conf
Записываем в конфигурационный файл минимальные настройки
укажите правильно:
1 выбранный порт
2 ваш домен
3 в путях замените на вашего пользователя
Запускаем новый сайт
sudo a2ensite FIRST_SITE. RU
Проверяем синтаксис в файлах .conf (должно быть: . O K)
sudo apachectl -t
sudo systemctl reload apache2
Install php for Apache
sudo apt -y install libapache2-mod-php
Install SSL
sudo apt -y install certbot
Next, install the NGINX server
Installing the latest NGINX server, tools first:
sudo apt install curl
sudo apt install gnupg2
sudo apt install ca-certificates
sudo apt install lsb-release
enable stable version repository
or connect the repository of the main version
import the official key
curl -o /tmp/nginx_signing.key https://nginx.org/keys/nginx_signing.key
you can check the key (in response you will receive a string of capital characters)
gpg —dry-run —quiet —import —import-options import-show /tmp/nginx_signing.key
transfer the key to the trusted list
sudo mv /tmp/nginx_signing.key /etc/apt/trusted.gpg.d/nginx_signing.asc
sudo apt install nginx
In the latest version, the configuration differs from the older version, there are no sites-available and sites-enabled directories, we will create them manually
sudo mkdir /etc/nginx/sites-available
sudo mkdir /etc/nginx/sites-enabled
sudo nano /etc/nginx/nginx.conf
Nginx server installed and configured.
sudo apt -y install php-fpm
(here it is desirable to have a separate «run.sock» interpreter for each domain)
Transfer sites from Apache to identify them on the standard port 80
Let’s create a configuration file
sudo nano /etc/nginx/sites-available/apache.conf
we write in it
! here:
1 list domains that are powered by Apache
2 specify the ip of your vps server
3 specify the port set for Apache
Create a symbolic link to the ./sites-enabled/ directory.
sudo ln -s /etc/nginx/sites-available/apache.conf /etc/nginx/sites-enabled/apache.conf
Add site to NGINX server
sudo nano /etc/nginx/sites-available/SECOND_SITE. EN.conf
Let’s create a configuration file with minimal settings
specify correctly:
1 your domain
2 in the paths replace with your user
fastcgi_index index.php;
try_files $uri $uri/ =404;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
sudo ln -s /etc/nginx/sites-available/SECOND_SITE. EN.conf /etc/nginx/sites-enabled/SECOND_SITE. EN.conf
check the syntax of nginx .conf files
(There are two lines in the answer, the first should end with .is ok
the second must end with .is successful)
sudo nginx -t;
sudo systemctl reload nginx
Install the required module
sudo apt -y install python3-certbot-nginx
Requesting encryption for a domain
Attention! on the first request there will be 3 setup questions:
1 — specify the email to which notifications will be sent (Enter your email and press «Enter»)
2 — Do you accept the terms (press «A» and «Enter»)
3 — Whether to send you alerts (press «N» or «Y» key, press «Enter»)
sudo certbot certonly —nginx -d SECOND_SITE. RU -d www. SECOND_SITE. EN
At the end you can see where the ssl config files were placed
Next, in nginx, you need to create a configuration file for the ssl port
sudo nano /etc/nginx/conf.d/domain-zone-ssl.conf
write the minimum settings into it
Restarting the nginx server
sudo systemctl restart nginx
site SECOND_SITE. RU must be opened in a browser using the https:// protocol
Database installation
Installing accessory tools
sudo apt -y install mysql-server
sudo apt install mysql-client
sudo apt -y install php-mbstring
or any of your websites
if you see an error on the /phpmyamdin page (screenshot) restart the server
and reconnect to the ssh terminal
Creating a database user
sudo mysql -u root -p
create a user in mysql mode and assign privileges (don’t forget to put a semicolon «;» at the end of sql commands)
to enter from mysql mode, hold down the combination Ctrl + Z
Importing large databases via ssh terminal
Enter mysql mode (you will need to enter a password)
Choose a database
start import from a file on the server
exit mysql mode with Ctrl + Z
FTP Server Installation
sudo apt install vsftpd
sudo systemctl enable vsftpd
open the configuration file in the editor
sudo nano /etc/vsftpd.conf
set the following parameters: (change the values and add the missing ones)
sudo systemctl restart vsftpd
open a file in which we specify ftp-users
register our user
add the necessary ports to the firewall
sudo ufw allow 20/tcp
sudo ufw allow 21/tcp
sudo ufw allow OpenSSH
sudo ufw allow 990/tcp
sudo ufw allow 40000:50000/tcp
sudo ufw disable
Turn on (you need to specify «y» and press «Enter»)
sudo ufw enable
Mail server
Installation of utilities and programs
sudo apt -y install mailutils
sudo apt -y install exim4
sudo dpkg-reconfigure exim4-config
sudo systemctl restart exim4
encryption of emails with exim4
Go to the big configuration file and:
before «.ifdef MAIN_TLS_ENABLE» parameter
add line MAIN_TLS_ENABLE = yes
(this can be found around line 300)
sudo nano /etc/exim4/exim4.conf.template
sudo apt -y install opendkim
sudo apt -y install opendkim-tools
Create a catalog for keys
go to the catalog of keys
generate a key for the domain
openssl genrsa -out SECOND_SITE. RU.key 1024
make a public key
openssl rsa -pubout -in SECOND_SITE. RU.key -out SECOND_SITE. RU.public
grant rights to all keys
chown -R Debian-exim:Debian-exim /etc/exim4/dkim
Change time zone
On the example of Beget hosting, using Git bash or PowerShell
1! Registering an account and creating a new server
2. Connecting to the server via SSH
$ ssh-keyscan -t rsa server_ip
Commands for restarting Nginx, MySQL, PHP-FPM services
Use the following commands to restart services:
Updating and installing additional applications (modules)
You must use sudo to execute commands with superuser privileges.
Checking the operation of nginx
Read more about setting up https://nginx.org/ru and see https://www.youtube.com (from about 15:40).
MySQL database installation (LEMP already contains it)
Deploy (deploy) applications on NodeJS + Express + MySQL
SSL certificate installation (Nginx + Ubuntu)
Install certbot (manual) to automatically renew Let’sEncrypt certificates.
Post navigation
Today we will talk about working with the mysql database, using Beget hosting as an example.
What is MySQL
MySQL is a database management system from Oracle Corporation, under the GNU General Public License. Included in AppServ, WAMP, LAMP servers and portable builds of XAMPP servers, Denver. The flexibility of MySQL is provided by supporting a large number of table types: MyISAM, InnoDB, EXAMPLE and others. In this regard, most cms developers use MySQL, and for many novice webmasters at the first stages of site building, the question arises of how to create a database.
Creating a MySQL database and a user for it on the example of Beget hosting
and get to the page “MySQL database management”,
on this page fill in the Database Name and Username and Password to the database (an administrator for the database is created automatically — he will have the same name as the database and the same password) well, that’s basically all)
Attention, be sure to write down the password from the database data.
Where can I set up a connection to MySQL in my CMS
List of main CMS with paths to their configuration files, which contain details for connecting to the database.
Web designer and SEO optimizer. I have been creating websites since 2010 and promoting them since 2012!
( No ratings yet )
Fellow site builders may immediately object — why create a database with pens at all, if WordPress can be installed with a couple of mouse clicks in the hosting control panel, for example, Beget. By the way, you can read about it in our article How to install WordPress from the Beget hosting panel
To which I will answer that if you want to become a real website builder, then you just need to know how to create a database yourself or upload files to hosting via FTP. So let’s learn to do everything with our own hands.
Video tutorial on how to create a MySQL database on Beget hosting
You can watch a short video instruction or use its text version.
Step by step instruction in pictures how to create a MySQL database.
We go to the control panel of our hosting Beget. If you use the services of another host, then the process of creating a database is similar there.
Press Base Management
Adding the end of the database. For other hosts, you may have to come up with the name of the base entirely on your own, for Beget, it is enough to attribute the tip after the underscore following the name of your account.
I am adding the letters db — data base, you can come up with your own.
Then we write the password to the database.
And click Add. That’s it, your database has been created.
Attention! Be sure to write down somewhere the name of the created database, password and username. I draw your attention to the fact that Beget has a username, that is, the name of the creator (aka administrator) is the same as the name of the database, which is quite convenient.
If you have any questions after reading this article, feel free to ask me in private messages on VKontakte
By the way, would you like to read what a landing site is? You can also learn how to create a business card website with your own hands.