Initial setup of centos 7.


Installation and subsequent setting operating system CentOS 7 will take place on a virtual machine created in the VrtualBox program, these instructions are fully suitable for installation directly on a hardware server.

CentOS is a Linux distribution based on and compatible with Red Hat's commercial Red Hat Enterprise Linux. Each version of CentOS has a 10-year support period. CentOS is updated every 6 months to support new hardware.

In this article you will find a step-by-step description minimal installation of CentOS 7, for your convenience and visual structuring, the material is divided into several main parts.

Preparing for installation

Go to the official CentOS website

Click "Get CentOS Now"

On the page that opens, click on the “Minimal ISO” button

Upon completion of the download, we have an ISO image of the CentOS 7 installation disk. This image must be burned to disk (if installed on a hardware server) or used as is (if installed on a virtual machine). If you are planning to install the system on a virtual machine, you may also find the following articles useful:

Installing CentOS 7

Everything is ready for installationCentOS 7. Start your computer or virtual machine, having previously set it to boot from CD-Rom (if using a virtual machine, specify the ISO file directly). As a result of the download you will see the following menu:

Start the installation process.

Run diagnostics on the media and start the installation process.

Select the second item and press "Enter".

After verifying the media, the CentOS 7 installer will launch.

Select the Russian language and click on the “Continue” button.

We will carry out the settings in the following order: setting up the keyboard; network configuration; date and time; installation location.


Let's set up the keyboard; to do this, click on the "Keyboard" button and change the priority of the layouts by moving the English layout to the top (select it and move it using the arrows). You can change the key combination for switching keyboard layouts (for example, to Ctrl+Shift), to do this, click on the "Options" button and make the necessary changes. After completing all the settings, click “Finish”.

Click on the "Network and host name" button. By default, the network is disabled; to enable the network adapter, you need to click on the switch in the upper right corner of the screen. If your network has a configured DHCP server, then all settings will be picked up automatically. Also, if your network has a configured DNS server, a hostname will be generated. If there are no DHCP and DNS servers, then the settings must be specified manually. If you plan to use the installed system to solve server problems, I strongly recommend that you specify the network settings and host name manually! Specify the host name, and to configure the network you need to click on the "Configure..." button

On the “General” tab, be sure to check the box next to “Automatically connect to this network when available,” otherwise, after restarting the computer, the network connection will not be active.

On the "Ethernet" tab, in the "MAC address of the device" position, you must specify the network adapter.

On the "IPv4 Settings" tab, in the "Configuration method" drop-down menu, the default item is "Automatic (DHCP)", change to "Manual", then click on the "Add" button, specify: address (must be free!); netmask; Gateway; DNS servers are specified separated by commas; You can also specify the search domain (if you are using a domain network).

If you do not use IPv6 on your network, on the “IPv6 Settings” tab, in the “Configuration method” drop-down menu, select “Ignore”.

Setting the date and time. Select the appropriate section in the installation menu. We indicate the city and region, then activate the “Network time” switch in the upper right corner of the screen. We check that the time is successfully synchronized with the NTP server. Click "Finish" to return to the main installer menu.

Click "Select Programs". In this article we will look at the "Minimal installation" option. It seems to me that this concept is a more correct solution when setting up a server. All necessary programs and services that will be required on the server are installed and configured later. Select "Minimal installation" and click the "Finish" button.

Let's move on to the "Installation location" section. Select the disk on which we are going to produce installing CentOS 7. Check the “I will configure partitions” checkbox and click the “Finish” button.

I specifically use a disk that already has partitions, mark it and click on the “-” button to delete.

If the installer detects that the operating system is installed (on the partition being removed), you will be prompted to confirm the removal.

Click the "Delete" button.

After you have cleared the entire disk, click on the link "Click here to automatically create them." The disk partitioning program will automatically create the following partitions:

It is necessary to slightly change the created structure. I will not create a separate partition and mount point for the home directory. To do this, you need to select it and delete it:

After we deleted the home partition, we were left with free space on the disk. Let's increase the swap size and set it equal to the amount of RAM, in my case 2Gb. To do this, select a partition and in the “Desired Capacity” line set the required volume:

Let's increase the size of the root partition; to do this, select it and set the required volume in the "Desired Capacity" line (you can specify a size larger than the available space, so the partitioning program will automatically calculate and allocate all remaining free space to the partition):

You can also change the group name in the "Volume Group" drop-down menu. Select our disk in the “Name” field, indicate the name and save:

Click the "Finish" button to complete disk partitioning.

The markup program will display a list of changes, click the "Accept changes" button.

At this stage, you can create system users and set a password for the root user. In this example, I will not create any users, but instead use the root system user entry.

Click on the "ROOT PASSWORD" button:

Let's set a password for the root user. If the system considers the password weak, you must confirm it by double-clicking the “Finish” button.

We are waiting for the CentOS 7 installation process to complete. Upon completion, click “Reboot”.

On this installing CentOS 7 completed.

Setting up the CentOS operating system

First launch of CentOS.

Now we will not consider fine-tuning the system, but will focus on the necessary minimum for the correct operation of the OS.

The default download is uninformative. After starting the system, we are greeted with a standard prompt for entering a username and password. Then, as you wish, you can connect via ssh, or log in using the console.

It is also necessary to secure the remote connection to the server running CentOS 7 - .

After completing these steps, we will add the most popular repositories EPEL and rpmforge.

Yum -y install epel-release

Updating the base system after installation.

Let's add several useful utilities that may be useful during server operation.
iftop:

Yum -y install iftop

Two interesting task managers:

Yum -y install htop yum -y install atop

I'm used to working using Midnight Commander; I'm quite satisfied with both the ease of navigating the file system and the built-in mcedit editor.

Yum -y install mc

That's it for the basics setting up CentOS 7 after installation completed.

I often have to work with projects of various sites, having knowledge and experience in administering the Linux OS, it was decided to raise own web server based on CentOS 7, for testing and debugging projects. In this article, in addition to the minimum set of commands for installing LAMP on CentOS 7, I will talk about increasing the security of your server. We will not disable SELinux, instead let's configure it for use on a web server, in addition let's install and basic configure Firewalld.

Let's take a closer look installing and configuring an FTP server in CentOS 7 on the base ProFTPD. As always, for ease of perception, the material is divided into semantic blocks. In this article you will find solutions to the following problems:

  • Installing LAMP on CentOS 7
  • Setting up SELinux
  • Installing and configuring phpMyAdmin on CentOS 7
  • Creating and configuring virtual hosts
  • Creating databases for websites
  • Installing Joomla 3.6 on CentOS 7
  • Installation and configuration of FTP server
  • Installing and configuring Firewalld
Preparing the system

Connecting the EPEL repository:

Sudo yum -y install epel-release

Let's update the system:

Sudo yum -y update

Let's install a file manager. I'm used to working using Midnight Commander; I'm quite satisfied with both the ease of navigating the file system and the built-in mcedit editor. Run in terminal:

Sudo yum -y install mc

Setting up SELinux

SELinux is a forced access control system designed to increase the security level of your server. In some cases, using SELinux may cause problems during the installation and configuration of system components. There are two solutions to this situation: properly configure SELinux or simply disable it. In any case, you need to weigh the risks. If you are setting up a test server on a local network for personal tasks, then you can simply disable SELinux, but if you are using the server in combat on the Internet, I recommend that you make the most of all available security measures. Which way to go is your decision. I don't disable SELinux.

Setting permissions in SELinux

To work with the SELinux context, we need the semanage utility included in the policycoreutils-python package, let's install it:

Sudo yum -y install policycoreutils-python

It is possible to set as temporary permissions (will work until the system is rebooted):

Sudo chcon -R -t httpd_sys_content_t /path/to/www sudo chcon -R -t httpd_sys_rw_content_t /path/to/www

So are permanent permissions:

Sudo semanage fcontext -a -t httpd_sys_content_t "/path/to/www(/.*)?" sudo semanage fcontext -a -t httpd_sys_rw_content_t "/path/to/www(/.*)?" sudo restorecon -R /path/to/www

These permissions must be specified after creating the home directory for your site (discussed in detail below).

Where /path/to/www is the path to the root directory of your site

httpd_sys_content_t – allow read access

httpd_sys_rw_content_t – allow write access.

Disabling SELinux

To disable, run in the terminal:

Sudo sed -i "s/\(^SELINUX=\).*/\SELINUX=disabled/" /etc/sysconfig/selinux sudo sed -i "s/\(^SELINUX=\).*/\SELINUX=disabled /" /etc/selinux/config

To apply the settings you need to reboot the system:

Sudo systemctl reboot

After reboot, check the status with the command:

Sestatus

You should see the following information:

SELinux status: disabled

Installing and configuring MariaDB

Run to install:

Sudo yum -y install mariadb-server mariadb

Let's start the service:

Sudo systemctl start mariadb.service

Add to startup:

Sudo systemctl enable mariadb.service

Perform basic setup:

Sudo mysql_secure_installation

Let's take a closer look at the settings:

Enter current password for root (enter for none) leave the field empty press Enter Set root password Y New password: Set the password Re-enter new password: Confirm Remove anonymous users Y Disallow root login remotely Y Remove test database and access to it Y Reload privilege tables now? Y All done! If you"ve completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!

Installing and configuring Apache

To install Apache, run in a terminal:

Sudo yum -y install httpd

Apache is configured by editing the configuration file:

The following changes need to be made:

# Let's check if the line at the end of the file is uncommented: IncludeOptional conf.d/*.conf # Also add the following line below: ServerName 127.0.0.1

Launch Apache:

Sudo systemctl start httpd.service

Let's add the service to startup:

Sudo systemctl enable httpd.service

By going to:

http://xxx.xxx.xxx.xxx

(where xxx.xxx.xxx.xxx is the IP address of your server), you should see the Apache test page:

* If the Apache test page does not open for you, disable Firewalld for a while; detailed firewall settings will be discussed below:

Sudo systemctl stop firewalld

Let's hide information about the Apache version, modules and operating system (by default, this information is available to everyone from the outside world):

Sudo mcedit /etc/httpd/conf/httpd.conf

Add to the end of the file:

ServerSignature Off ServerTokens Prod

Restart the service:

Installing and configuring PHP

Install PHP:

Sudo yum -y install php php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-mcrypt php-pecl-apc

Edit the php configuration file:

Sudo mcedit /etc/php.ini # uncomment and make changes realpath_cache_size = 1024k

Restart Apache:

Sudo systemctl restart httpd.service

Installing phpMyAdmin, restricting access

Installation:

Sudo yum -y install phpmyadmin

Edit the configuration file:

Sudo mcedit /etc/httpd/conf.d/phpMyAdmin.conf

Make the following changes allowing connections from remote hosts::


# Apache 2.4

# Require ip 127.0.0.1
# Require ip::1

Require ip xxx.xxx.xxx.xxx (IP address of the client machine)

Require all granted




# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from::1

# phpMyAdmin setup page


# Apache 2.4

# Require ip 127.0.0.1
# Require ip::1
# Allow remote connection from a specific IP
Require ip xxx.xxx.xxx.xxx (IP address of the client machine)
# Allow all remote connections
Require all granted




# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from::1

Attention! In order to increase server security, I do not recommend that you use permissions for all remote hosts (i.e. Require all granted); these settings are provided in this article for your reference.

Restrict access to the directory /usr/share/phpMyAdmin/ to a specific IP address Require ip xxx.xxx.xxx.xxx(where xxx.xxx.xxx.xxx is the IP address of the client machine), and also, if fine-tuning is necessary, limit access to the directory /usr/share/phpMyAdmin/setup/ before Require ip 127.0.0.1 upon completion of all settings.

I do not encourage the use of phpMyAdmin on production servers. However, for a beginner or a test server, this web panel provides a certain level of convenience.

Restart Apache:

To access the phpMyAdmin web interface, type in the address bar:

User: root

Password: You set it during the MariaDB setup phase

To access the phpMyAdmin settings page, type in the address bar:

Http://server ip-address/phpmyadmin/setup

Don't forget to restrict access to the settings page once all installations are complete.

Creating a database for the site

Creating a database in the console

Connect to the MySQL server:

Mysql -u root -p

Enter the root user password (we set it at the beginning of the article) and press Enter.

Database creation:

CREATE DATABASE `site` CHARACTER SET utf8 COLLATE utf8_general_ci;

It is advisable to immediately select the mysql database, because... all further settings will be made in it.

Use mysql;

Create a site user with the password Zaq12wsx for the site database:

Attention! use complex passwords.

GRANT ALL PRIVILEGES ON site.* TO "site"@"localhost" IDENTIFIED BY "Zaq12wsx" WITH GRANT OPTION;

Disconnect from the MySQL server:

Creating a database using phpMyAdmin

Open in browser

Http://server ip address/phpmyadmin

Go to the "Databases" section

Specify the database name, quote and click "Create"

Go to the "Users" section, click "Add user"

Provide a username, limit local access, set a password and confirmation. Check the "Grant all privileges to the database "base name" (in our case, site)" checkbox. Click "Forward" to continue.

Attention! Use strong passwords.

Click on the "Exit" icon to exit phpMyAdmin.

You have successfully created a database and a privileged user for your site.

Creating a home directory, setting permissions, preparing Joomla

Create a home directory for the site:

Sudo mkdir /var/www/html/site.ru

Create a directory for storing logs:

Sudo mkdir /var/www/html/site.ru/logs

Go to the home directory of the site:

Cd /var/www/html/site.ru

For Joomla 3.6 installations You will need wget and unzip, run in the terminal:

Sudo yum -y install wget unzip

Let's download the latest version of Joomla from the official website, at the time of writing this is version 3.6.2:

Sudo wget https://github.com/joomla/joomla-cms/releases/download/3.6.2/Joomla_3.6.2-Stable-Full_Package.zip

Let's unpack:

Sudo unzip Joomla_3.6.2-Stable-Full_Package.zip

Let's set file permissions:

Sudo find . -type f -exec chmod 0644 () \;

Let's set directory rights:

Sudo find . -type d -exec chmod 0755 () \;

Let's change the owner to the Apache user:

Sudo chown apache:apache -R /var/www/html/site.ru

Attention! If you have not disabled SELinux, you need to enable read and write for Apache:

Sudo yum -y install policycoreutils-python sudo semanage fcontext -a -t httpd_sys_content_t "/var/www/html/site.ru(/.*)?" sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/site.ru(/.*)?" sudo restorecon -R /var/www/html/site.ru

Creating, configuring and testing virtual hosts

Create a virtual host site.ru:

Sudo mcedit /etc/httpd/conf.d/site.ru.conf

Specify virtual host settings:

ServerAdmin [email protected] ServerName site.ru ServerAlias ​​www.site.ru DocumentRoot /var/www/html/site.ru Options FollowSymLinks AllowOverride All Require all granted ErrorLog /var/www/html/site.ru/logs/error.log CustomLog /var/www/html/site.ru/logs/access.log common

Restart Apache:

Sudo systemctl restart httpd.service

Creating other virtual hosts is similar, but don't forget to create home directories for new sites.

To verify that the virtual host is configured correctly, you need to edit the hosts file on the client machine.

# Open with a text editor C:\Windows\System32\drivers\etc\hosts # Make the following changes xxx.xxx.xxx.xxx site.ru xxx.xxx.xxx.xxx www.site.ru

# Open with a text editor sudo mcedit /etc/hosts # Make the following changes xxx.xxx.xxx.xxx www.site.ru site.ru

*Where xxx.xxx.xxx.xxx is the IP address of your server

Save and reload your browser.

Installing Joomla and launching the site

Open in browser:

http://site.ru

http://www.site.ru

meets you Joomla installation wizard:

You need to select the installation language for Joomla 3.6.2. indicate the name of the site, administrator email, login, administrator password and password confirmation. Click "Next" to continue.

Database configuration. Specify the database type, leave the server name as default "localhost". Specify the username (in my case site), password (Zaq12wsx) and database name (site). You can also specify manually or automatically the "Table Prefix". A prefix can be used when storing data from several sites in one database; in this case, for each site you must specify a different prefix from others. Click "Next" to continue installing Joomla.

Complete installation. On this page you can see a summary of all site settings, as well as install demo data. Click on the "Install" button.

We are waiting for completion Joomla 3.6.2 installation process on CentOS 7 web server.

I offer you right away Russify Joomla 3.6.2. Click "Install language packs".

Select the required language from the list.

At the moment we will not be using multilingual functionality on our website. Specify the language of the control panel, as well as the language of the site, and click "Next".

Click "Remove 'installation' directory".

Installing Joomla 3.6.2 on your own web server CentOS 7 completed successfully.

Installation and configuration of ProFTPD

To install ProFTPD do:

Sudo yum -y install proftpd proftpd-utils

Start the service:

Sudo systemctl start proftpd

Enable proftpd in startup:

Sudo systemctl enable proftpd

Edit the server configuration file:

Sudo mcedit /etc/proftpd.conf

Change the "DefaultRoot" parameter to the following form:

DefaultRoot~

Comment out the default parameter "AuthOrder":

#AuthOrder mod_auth_pam.c* mod_auth_unix.c

Add the following parameters to the end of the file:

AuthUserFile /etc/ftpd.passwd RequireValidShell off AuthPAM off RootLogin off PassivePorts 30000 35000 ListOptions -a LoadModule mod_auth_file.c AuthOrder mod_auth_file.c

Let's look at the list of users:

Sudo cat /etc/passwd

Command output:

*** sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin apache :x:48:48:Apache:/usr/share/httpd:/sbin/nologin

In my case Apache has the following user and group IDs: UserId=48, GroupId=48.

We create a virtual ftp user with login site, user ID 48, group 48 and home directory /var/www/html/site.ru:

Sudo ftpasswd --passwd --file=/etc/ftpd.passwd --name=site --uid=48 --gid=48 --home=/var/www/html/site.ru --shell=/bin /false

After executing the command, the system will ask you to enter a password twice for the user being created (I strongly recommend using complex passwords). As a result of executing the command, the /etc/ftp.passwd file will be created with an entry about the user.

You can change the user password with the following command:

Sudo ftpasswd --file /etc/ftpd.passwd --passwd --name=site --change-password

Edit permissions for the file with users:

Sudo chgrp nobody /etc/ftpd.passwd sudo chmod 640 /etc/ftpd.passwd

SELinux. Allow full file access for proftpd:

Sudo setsebool -P allow_ftpd_full_access=1

Restart the proftpd service:

Sudo systemctl restart proftpd

Firewalld - increasing server security level

Firewalld is a new firewall included with CentOS 7. To install Firewalld, run:

Sudo yum -y install firewalld

Let's launch:

Sudo systemctl start firewalld

Include in autoload:

Sudo systemctl enable firewalld

Let's check:

Sudo systemctl status firewalld

If you go to the site now, nothing will open for you. Firewalld blocks network connections. Let's see what is allowed by default:

Sudo firewall-cmd --permanent --list-all

Command output:

Public (default) interfaces: sources: services: ssh dhcpv6-client masquerade: no forward-ports: icmp-blocks: rich rules:

Ssh is permanently allowed, as is the dhcp v6 client. I don’t use ip v6 on the server, so I’ll remove the corresponding rule:

Sudo firewall-cmd --permanent --zone=public --remove-service=dhcpv6-client

For the web server to work, you must enable the http service (port 80):

Sudo firewall-cmd --permanent --zone=public --add-service=http

If you plan to use https on your site, you must enable the https service (port 443):

Sudo firewall-cmd --permanent --zone=public --add-service=https

For the FTP server to work, it is necessary to open 21 ports, as well as ports 30000-35000 to use passive mode in FTP clients:

Sudo firewall-cmd --permanent --zone=public --add-port=21/tcp sudo firewall-cmd --permanent --zone=public --add-port=30000-35000/tcp

Let's reload the rules:

At this stage of Firewalld configuration, your site is accessible again. But I would like to suggest that you take a few more steps to increase the security level of your server. There is a fairly detailed written one. One of the setup steps is changing the standard port; let's look at the Firewalld settings in more detail when changing the ssh port.

Let's permanently allow (so that it doesn't get lost after a reboot) the connection to port 2220/tcp (we'll hang sshd on it):

Sudo firewall-cmd --permanent --zone=public --add-port=2220/tcp

Let's reload the rules:

Sudo firewall-cmd --reload

Let's check:

Sudo firewall-cmd --zone=public --list-ports

Command output:

2220/tcp

The port is open. Editing the sshd config:

Sudo mcedit /etc/ssh/sshd_config

We make changes:

*** # If you want to change the port on a SELinux system, you have to tell # SELinux about this change. # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER # In the file you only need to specify the port Port 2220 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress:: ***

Let's restart ssh:

Sudo systemctl restart sshd.service

Also, if you use SELinux (I hope you haven’t disabled it), you need to make additional settings. This is due to the fact that SELinux will not allow you to connect to ssh on a non-standard port (2220):

Sudo semanage port -a -t ssh_port_t -p tcp 2220

After checking the ssh connection on the new port, close access to port 22:

Sudo firewall-cmd --permanent --zone=public --remove-service=ssh

Reload the rules:

Sudo firewall-cmd --reload

Let's check the Firewalld settings:

Sudo firewall-cmd --list-all

Command output:

Public (default) interfaces: sources: services: http https ports: 2220/tcp 21/tcp 30000-35000/tcp masquerade: no forward-ports: icmp-blocks: rich rules:

We have opened access to the server via the http, https, ftp protocol, as well as port 2220 on which the ssh service now runs.

In this guide, we will install the CentOS 7 operating system on a server that supports 64bit architecture, since the developers have not released a distribution for the 32bit architecture, at least I haven’t found it anywhere.

Recently the new operating system CentOS 7 was released, so I decided to make installation instructions with detailed screenshots in order to guide those who want to learn how to install and configure Linux CentOS 7 when I am asked to teach or give advice.

CentOS is a Linux distribution based on and compatible with Red Hat's commercial Red Hat Enterprise Linux. Red Hat Enterprise Linux consists of free and open source software, but is available as binary package discs for paid subscribers only. As required by the GPL and other licenses, Red Hat provides all source code. The CentOS developers use this source code to create a final product that closely resembles Red Hat Enterprise Linux and is available for download.

Download CentOS 7 from the official website for x64 architecture:
Download the distribution kit in a size convenient for you using the links:

Let's take a short break and watch the extreme descent from the mountain on a bicycle, it will take your breath away:

Hi all! Today in the article we will look at the installation CentOS 7 Minimal, initial network setup and installation of a graphical interface called Mate. We already have an article and video about it, but there are several subtleties when installing Minimal, more on them below.

The first difference is that the image is slightly larger - 700 MB, but this is still incomparable with the volume of a DVD or Full edition. The next difference, which follows from the previous one, is that there is no option to select additional software for installation (screenshot below):

CentOS 7 also added the ability to enable the network interface directly during installation - this was not the case in version 6, however, I will additionally demonstrate the most visual way to configure the network interface in version 7.

Installation process

So, we perform all the steps sequentially, wait 15-30 minutes and enter your login/password (after connecting through the terminal).

The first desire was to check whether the network interface was working and whether an address had been assigned to it - I entered the ifconfig command, and, as it turned out, this command in version 7 is outdated and instead it is necessary to use the ipaddr command to display information about interfaces and the iplink command to display statistics on them.

But since everyone is accustomed to the standard commands of the net-tools package, it will need to be installed using the yum install net-tools command. However, remembering the first feeling of misunderstanding when my network did not work in the minimal installation on version 6, I want to additionally show a very simple way to configure it - more on that below.

Important! The ifconfig command is deprecated. For network interaction with the server, we recommend using the “ip” command (ip -a), which is superior in functionality (from the point of view of L2 and L3) to “ifconfig”.

Configuring network interfaces using nmtui

We enter the nmtui command - as a result, a simple graphical interface for setting up the network should start (screenshot below):


For example, I want to change the settings of a single interface - select the first option Edit a connection and we see the following picture:


Choose Edit... and do whatever we want with the interface :) As you can see in the screenshot below, our server received an IP address via DHCP - this suits me and I will leave everything as it is. The main goal was to demonstrate this utility - nmtui


Installing MATE and required packages

So why MATE? The answer is simple - it is much lighter, very undemanding of resources and extremely easy to install. So, we take a few simple steps to install packages (below):

  • yum groupinstall "Development Tools" - installation of the necessary set of packages for the GUI to work (only if not already installed);
  • yum install epel-release - installing the EPEL repository;
  • yum groupinstall "X Window system" - installs the X Window System group package, this will take about 5 minutes. The package itself has a volume of 73 MB;
  • yum groupinstall "MATE Desktop" - installation directly Mate - quite a large package - 506 MB;
Installing and configuring Web-Server in CentOS 7

Installing and configuring Web-Server in CentOS 7

Installing MySQL

in CentOS 7, instead of MySQL, a free copy called MariaDB is used,

First, let's install the MariaDB server; to do this, on the command line you need to run:

# yum -y install mariadb-server mariadb

After installation, add the MariaDB server to startup:

# systemctl start mariadb.service

# systemctl enable mariadb.service

Installing Apache

To install the Apache web server you need to run the command:

# yum -y install httpd

After installation, add the Apache server to startup:

# systemctl start httpd.service

# systemctl enable httpd.service

CentOS 7 uses a firewall Firewall-cmd. Let's add a setting that allows connections to port 80 (http) and port 443 (https)

# firewall-cmd —permanent —zone=public —add-service=http

# firewall-cmd —permanent —zone=public —add-service=https

# firewall-cmd --reload

Afterwards, open http://ip-address in your browser, and the standard Apache web server page will be displayed on the screen

By default, in the Apache web server, the root directory for sites (document root) is located in the /var/www/html directory

The configuration file (file with settings) of the Apache web server is located in the file /etc/httpd/conf/httpd.conf

Additional configuration files are located in the directory: /etc/httpd/conf.d/

Installing PHP

To install PHP you need to run the command:

# yum -y install php

After installation, you need to restart the apache web server:

To test the operation of PHP in the root directory (document root) of the apache web server /var/www/html, you can create a file pi.php that will contain the phpinfo() function

(phpinfo() function displays a lot of useful information about web server and PHP settings).

To do this you need to run the command:

# echo "» > /var/www/html/pi.php

Then you can open the page in the browser:

http://ip-address/pi.php

This page displays all the necessary information about the Apache web server and PHP settings

Setting up MySQL support in PHP

To support MariaDB in PHP you need to install the package php-mysql. You can also install some other packages for PHP to work with various modules that may be needed. To do this, run the command:

# yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

# systemctl restart httpd.service

Now you can re-open the http://ip-address/pi.php page and see the new information.

Installing phpMyAdmin

phpMyAdmin is a program that provides a web interface through which you can manage MySQL and MariaDB databases

To install, you need to initialize the EPEL repository since the official CentOS 7 repository does not contain phpMyAdmin.

# yum -y install epel-release

After adding the repository, it is possible to install phpMyAdmin:

# yum -y install phpmyadmin

After installation, phpMyAdmin will be available at: http://ip-address/phpmyadmin/

Installing WordPress

First, let's create a temp directory into which we will upload the latest version of WordPress:

#mkdirtemp

# cd temp

# yum install wget unzip net-tools

# wget http://wordpress.org/latest.zip

# yum -y install php-gd

# systemctl restart httpd.service

Extract the WordPress zip file to the following folder:

# unzip -q latest.zip -d /var/www/html/

Now let's give the directory the appropriate access rights:

# chown -R apache:apache /var/www/html/wordpress

# chmod -R 755 /var/www/html/wordpress

# mkdir -p /var/www/html/wordpress/wp-content/uploads

Now you need to allow the web server to write to this directory. This can be done by making the apache group the owner. This will allow the server to create files and other directories within the original directory, so we can upload content to the server in the future using the WordPress engine (without FTP). Enter the following:

# chown -R:apache /var/www/html/wordpress/wp-content/uploads

Then we need to check the configuration file, for this we need to copy it (the standard example file is taken as the base). The test configuration file is located at /var/www/html/wordpress:

# cd /var/www/html/wordpress/

# cp wp-config-sample.php wp-config.php

# mcedit wp-config.php

Change the values ​​to those you created when initializing the databases.

Now let’s access our website through the web interface; to do this, go to the address: http://ip-address/wordpress/wp-admin/install.php:

First select your language and click Continue:

Site Title = WordPress-testsite Admin Email = [email protected] Username = admin Admin password = testpassword Confirm Admin Password = testpassword

Values ​​may vary, you can set any values ​​of your choice. After that click Install WordPress:

You must provide the username/password pair that we chose when installing WordPress.







2024 gtavrl.ru.