Redhat7.6. Build LAMP environment

Posted by msgcrap on Tue, 04 Jan 2022 22:53:11 +0100

Turn off firewall and selinux #

systemctl stop firewalld
systemctl disable firewalld

Disable Selinux

vim /etc/selinux/config

Change to disabled

SELINUX=disabled

Note: the above configuration takes effect only after restart, so it is necessary to temporarily close selinux firewall

setenforce  0

Install Apache #

yum -y install httpd

Start Apache

systemctl start httpd //Start apache

systemctl enable httpd //Set apache startup

systemctl status httpd //View service status

After startup, you can access the host IP in an external browser to see the Apache page

Catalog details #

  • Program directory: / usr/sbin/httpd
  • Default home page storage directory: / var/www/html/
  • Log file storage directory: / var/log/httpd/
  • Main configuration file: / etc / httpd / conf / httpd conf
  • From the configuration file: / etc/httpd/conf.d/

Check whether the configuration file is correct #

httpd -t

If you have the following prompts, you can ignore them

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message

Three ways to configure a site #

IP based approach #

  1. New site file
cd /var/www/html
mkdir web1 && cd web1
vim index.html

Add Web content

<h1 style="color:#D81B60">Hello Multisite! </h1>
  1. Multisite profile
vim /etc/httpd/conf.d/http-vhost.conf


<VirtualHost *:80>
    ServerAdmin feng@gmail.com
    DocumentRoot /var/www/html/web1
    ServerName web1.frg.com
    ErrorLog logs/web1-frg-com-error_log
    CustomLog logs/web1-frg-com-access_log common
</VirtualHost>
  1. Restart Apache
# Check configuration file
httpd -t
# Restart service
systemctl restart httpd

Using IP access

Using port access #

Configure multisite profiles

  1. New site file
cd /var/www/html
mkdir web2
vim index.html

Add Web content

<h1 style="color:#D81B60">Hello Multisite! </h1>
  1. Multisite profile
vim /etc/httpd/conf.d/http-vhost.conf


<VirtualHost *:8899>
    ServerAdmin feng@gmail.com
    DocumentRoot /var/www/html/web2
    ServerName web2.frg.com
    ErrorLog logs/web2-frg-com-error_log
    CustomLog logs/web2-frg-io-access_log common
</VirtualHost>
  1. Add listening port
vim /etc/httpd/conf/httpd.conf

# Add a line after Listen 80
Listen 8899
  1. Restart Apache
# Check configuration file
httpd -t
# Restart service
systemctl restart httpd

The browser is accessed through the domain name: 8899

Local DNS resolution access #

CentOS7 installing and configuring a local DNS server https://www.cnblogs.com/LzsCxb/p/15713510.html

Add forward and reverse resolution on DNS server #

vim /etc/named.rfc1912.zones


zone "frg.com" IN {
        type master;
        file "feng.io.zone";
        allow-update { none; };
};

Forward data area file #

cd /var/named

cp -p named.localhost frg.com.zone

vim named.localhost frg.com.zone

Restart DNS server

systemctl restart named

Add DNS server resolution in client #

Linux:

sudo vim /etc/resolv.conf 

Add your local DNS server address to the top
Restart the network to access using the domain name

window:

  1. Modify the preferred DNS of the network card to the local server
  2. Modify the host file
192.168.139.100 frg.com

Mysql8 installation #

CentOS7 installing Mysql8 and configuring remote login https://www.cnblogs.com/LzsCxb/p/15366225.html

PHP installation and configuration #

Compile and install #

  1. Download PHP7 source package
wget -P /opt/software https://www.php.net/distributions/php-7.4.27.tar.gz
  1. decompression
tar -zxvf php-7.4.27.tar.gz
  1. Install dependent packages
yum -y install libxml2-devel sqlite-devel  httpd-devel
  1. precompile

--Enable FPM -- with apxs2 = / usr / bin / apxs call Apache's apxs to generate PHP module, which depends on the package httpd devel

cd /opt/software/php-7.4.27
./configure --prefix=/usr/local/php7 --enable-fpm --with-apxs2=/usr/bin/apxs

  1. Compile and install
make && make install
  1. PHP configuration file
cd /opt/software/php-7.4.27
cp php.ini-development php.ini
  1. Link executable
ln -s /usr/local/php7/bin/php /usr/local/bin
php -v

Configuring Apache to support PHP7 #

  1. Edit httpd conf
vim /etc/httpd/conf/httpd.conf

Navigate to < ifmodule dir_ Module > add index php

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

Add at the end of the file
If it already exists, you do not need to add it

LoadModule php7_module modules/libphp7.so
<FilesMatch \.php$>
        SetHandler application/x-httpd-php
</FilesMatch>

  1. Check configuration file
httpd -t
  1. Enter the site and create a new index php
    vim index.php
<?php

phpinfo();
Copy full screen

Visit Site
1

 

-------------------------------------------------------------------------------- transferred from: https://www.cnblogs.com/LzsCxb/p/15716510.html     ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

Topics: Linux