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 #
- New site file
cd /var/www/html mkdir web1 && cd web1 vim index.html
Add Web content
<h1 style="color:#D81B60">Hello Multisite! </h1>
- 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>
- Restart Apache
# Check configuration file httpd -t # Restart service systemctl restart httpd
Using port access #
Configure multisite profiles
- New site file
cd /var/www/html mkdir web2 vim index.html
Add Web content
<h1 style="color:#D81B60">Hello Multisite! </h1>
- 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>
- Add listening port
vim /etc/httpd/conf/httpd.conf # Add a line after Listen 80 Listen 8899
- 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:
- Modify the preferred DNS of the network card to the local server
- 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 #
- Download PHP7 source package
wget -P /opt/software https://www.php.net/distributions/php-7.4.27.tar.gz
- decompression
tar -zxvf php-7.4.27.tar.gz
- Install dependent packages
yum -y install libxml2-devel sqlite-devel httpd-devel
- 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
- Compile and install
make && make install
- PHP configuration file
cd /opt/software/php-7.4.27 cp php.ini-development php.ini
- Link executable
ln -s /usr/local/php7/bin/php /usr/local/bin
php -v
Configuring Apache to support PHP7 #
- 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>
- Check configuration file
httpd -t
- Enter the site and create a new index php
vim index.php
<?php phpinfo();
-------------------------------------------------------------------------------- transferred from: https://www.cnblogs.com/LzsCxb/p/15716510.html ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------