Setup of LAMP Environment
Install DNS Server
Install DNS Service
yum install bind -y
Configuration of DNS
Create Forward Resolution
For example, create a forward lookup zone named "lsy.com": Step 1: Create a lookup zone in the main configuration file/etc/named.conf. vim /etc/named.conf listen-on port 53{any;}; allows any user to use DNS allow-query {any;}; allows any user to query Dnssec-enable no; Is DNS security on zone "zlt.com." IN { type master; there are three types: hint root master primary area secondary area file "zlt.com.zone"; }; Step 2: Generate a zone profile in the /var/name directory. copy named.localhost zlt.com.zone chown :named zlt.com.zone vim lsy.com.zone $TTL 1D IN SOA zlt.com. root.gxa.com.( 0; serial is a ten-digit serial number 1D; refresh refresh time 1H; retry retry time 1W; expire expire time 3H; minimum cache time NS dns.gxa.com. @Partially fill in the domain name DNS A 192.168.0.1 A denotes the address of IPV4 A A denotes the address of IPV6 www A 192.168.0.1 ftp A 192.168.0.1 Step 3: Restart the service [root@teacher mnt]#systemctl start named.service [root@teacher mnt]#systemctl enable named.service Step 4: Configure the client Step 5: Test your DNS server nslookup
Install apache server
Configure YUM Source
1. Configure YUM source files # cd /etc/yum.repos.d/ Back up system default YUM source files # mkdir bak # mv *.repo bak Configure local sources Step 1: Load the system disc Step 2: Create a folder under / mnt / directory: cdrom Step 3: Mount the disc into the cdrom directory # mount -t iso9660 /dev/sr0 /mnt/cdrom # vim /etc/fstab # mount -a Step 4: Configure the yum source file # vim dvd.repo [media] name=CentOS7 baseurl=file:///mnt/cdrom enabled=1 gpgcheck=0 Step 5: Check that the yum source is configured successfully
Install apache
yum install httpd httpd-devel
Start apache service
systemctl start httpd
Set httpd service startup
systemctl start httpd open systemctl stop httpd stop systemctl status httpd detection systemctl restart httpd restart Systemctl enable httpd startup
Firewall settings open port 80/443
[root@nmserver-7 ~]# firewall-cmd --permanent --zone=public --add-service=http success [root@nmserver-7 ~]# firewall-cmd --permanent --zone=public --add-service=https success [root@nmserver-7 ~]# firewall-cmd --reload success
Publish Web Site
Default directory for site storage: /var/www/html [root@teacher myweb]# cd /var/www/html/ [root@teacher html]# echo 'welcome to leshanshiyuan.com!' > index.html [root@teacher html]# ls index.html How can I access the website without putting it in the default directory? Modify configuration file: vim/etc/httpd/conf/httpd.conf Position to 119 lines::119 119 #DocumentRoot'/var/www/html'to a directory where Web pages are stored Restart httpd service: systemctl restart httpd
Install mysql database
Install mysql
[root@nmserver-7 ~]# yum install mariadb mariadb-server mariadb-libs mariadb-devel root@nmserver-7 ~]# rpm -qa |grep maria mariadb-libs-5.5.52-1.el7.i686 mariadb-5.5.52-1.el7.i686 mariadb-server-5.5.52-1.el7.i686 mariadb-devel-5.5.52-1.el7.i686
Open mysql service
[root@nmserver-7 ~]# systemctl start mariadb [root@nmserver-7 ~]# systemctl enable mariadb
Database Security Settings
mysql_secure_installation
Logon Database Test
mysql -u root -p
Creation and Use of Database
Operation of the database
view the database
MariaDB [(none)]> show databases;
Create a database
Create a database: (The created database is stored in the / var/lib/mysql directory) MariaDB [(none)]> create database couman; Query OK, 1 row affected (0.00 sec)
Select Database
MariaDB [(none)]> use couman; Database changed
Delete database
MariaDB [(none)]> drop database couman; Query OK, 0 rows affected (0.00 sec)
Backup of database
[root@teacher mnt]# mysqldump couman --user=root --password=123456>db-01.mysql;
Database recovery
Create an empty database memory
MariaDB [(none)]> create database couman; Query OK, 1 row affected (0.00 sec)
Restore database storage from backup files
[root@teacher mnt]# mysql -u root -p couman<db-01.mysql Enter password:
Install PHP environment
Install php
[root@nmserver-7 ~]# yum -y install php [root@nmserver-7 ~]# rpm -ql php/etc/httpd/conf.d/php.conf/etc/httpd/conf.modules.d/10-php.conf/usr/lib/httpd/modules/libphp5.so/usr/share/httpd/icons/php.gif/var/lib/php/session
Associating php with mysql
[root@nmserver-7 ~]# yum install php-mysql [root@nmserver-7 ~]# rpm -ql php-mysql/etc/php.d/mysql.ini/etc/php.d/mysqli.ini/etc/php.d/pdo_mysql.ini/usr/lib/php/modules/mysql.so/usr/lib/php/modules/mysqli.so/usr/lib/php/modules/pdo_mysql.so
Install common PHP modules
[root@nmserver-7 ~]# yum install -y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-bcmath
Test PHP
[root@nmserver-7 ~]# cd /var/www/html/ [root@nmserver-7 html]# ls [root@nmserver-7 html]# pwd /var/www/html [root@nmserver-7 html]# vi info.php <?php phpinfo(); ?>
Restart apache server
systemctl restart httpd
Test PHP
Enter 192.168.8.9/info.php in your computer browser and you will see the installed modules
Domain Name Based Virtual Host
Domain name registration
Domain name registration, append a line to / etc/hosts: 192.168.75.128 exam.excesoft.com Domain name test: ping exam.excesoft.com
Put in Web Page
Place both websites in / var/www/html/directory
Modify Main Profile
Modify the main configuration file: vim/etc/httpd/conf/httpd.conf Listen 80 DirectoryIndex index.html Add at the end: Include conf/vhost/*.conf Location of vhost directory: /etc/httpd/conf vhost needs to be created by itself
Create Domain Name Profile
(4)stay/etc/httpd/conf New under Catalog vhost Catalog and create a new one below exam.conf and attendance.conf Two //Domain name profile and edit as follows. #vim exam.conf <VirtualHost 192.168.75.128> //Configure access ip address ServerName exam.excesoft.com //Set up a domain name DocumentRoot /var/www/exam/ //set up path <Directory "/var/www/exam/"> //set up path Options Indexes FollowSymLinks //Show Web Page File List AllowOverride NOne //Ignore.htaccess files Require all granted //Allow all </Directory> </VirtualHost>
Check that the settings are correct
Use httpd-t to check that the virtual host is configured correctly
Restart Service
Restart the Apache service and test it