0x01 Install apache
1. Install apache
yum install -y httpd
2. Modify the configuration file
Configure ServerName and enter the httpd.conf file:
vim /etc/httpd/conf/httpd.conf
Apache uses port 80 by default
3. Open port 80 on the firewall
to open the firewall
systemctl start firewalld
View firewall status
systemctl status firewalld
Seeing green active (running) means that the firewall is successfully enabled
Set the firewall to start automatically at boot
systemctl enable firewalld
Add port 80
firewall-cmd --permanent--zone=public --add-port=80/tcp
Make firewall configuration effective
firewall-cmd --reload
View the list of open ports
firewall-cmd --permanent--zone=public --list-ports
4. Start apache
Start apache
systemctl start httpd.service
View apache status
systemctl status httpd.service
test open state
curl http://127.0.0.1
apache installation complete
0x02 Install mysql database
1 Download the mysql source installation package
wget https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2 安装MySQL
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
3 Install the mysql service
First enter the cd /etc/yum.repos.d/ directory.
cd /etc/yum.repos.d/
Install the MySQL service (this process may be a bit slow)
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum -y install mysql-server
4 Start MySQL
Start the MySQL service
systemctl start mysqld
View the startup status of MySQL
systemctl status mysqld
Set MySQL to start at boot
systemctl enable mysqld
systemctl daemon-reload
5 Modify the root default password
Find the root default password
grep'temporary password'/var/log/mysqld.log
# Enter the mysql console and enter the default password found in the above query
mysql -u root -p
# Set the root administrator's password
set password for'root'@'localhost'=password('vHVdXeIvpjK028R.');
0x03 Install php
1. Install php
yum install -y php php-devel
2. Restart apache to make php take effect
systemctl restart httpd.service
3. To test php,
you can create a PHP file under the directory: /var/www/html/
1.php
<?phpphpinfo();?>
Access in browser: http://ip/1.php
4. Anso php installation
yum install -y php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
After installing the extension, you need to restart apache again
systemctl restart httpd.service
PHP code to test whether mysql link is successful
<?php
$servername="localhost";
$username="root";
$password="vHVdXeIvpjK028R."; // create connection
$conn=newmysqli($servername, $username, $password); // detect connection
if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error);} echo "Connected successfully";?>