How to build your own web server

Time:2020-9-29

Nowadays, with the development of computer and Internet technology, it is no longer difficult to surf the Internet. By opening the browser, we can visit various forum sites, such as CSDN, blog Garden, and various video websites, such as iqiyi, station B, etc. On the Internet, we can write articles, watch videos, shop, play games, chat and so on. But have you ever thought about how these things are made? Do you need to master more knowledge? Can ordinary people do it? After a lot of exploration, we finally understand such a set of process. At present, there are more and more open source projects, and many novices can also use these resources to build their own web service sites.
At present, there are many ways to build web server, one of which is called lamp, namely Linux system + Apache server + MySQL + PHP. The following will record how I built our own web server under the Linux system. In the future, I will sort out how to build our personal website, community forum, interest community and other interesting projects on our own web server platform.

[step 1] install Linux system
Linux system is open source and can be downloaded, installed and used for free. To be exact, Linux is a kind of kernel, and the operating systems based on this kernel include Ubuntu, RedHat, CentOS, Fedora, etc. Based on habits, we call these operating systems Linux systems.
  Note: the above views are purely personal understanding
There are two ways to install Linux system
1: Replace the computer operating system or install dual systemInstalling Ubuntu system — Baidu experience
2: Install the VMware virtual machine and install the Ubuntu system in the virtual machine
[step 2] install the Apache server
Enter the Ubuntu system, press the shortcut key Ctrl + Alt + T to open the terminal and enter the command
① Update resource pack
    sudo apt update
② Update software
    sudo apt upgrade
③ Update system software
    sudo apt dist-upgrade
④ Install Apache server
    apt install apache2
Do you want to continue? [y / N] enter y and press enter.
Wait for the installation to complete. This is the interface you see. It’s cool. It feels like a hacker.
Note: operating Apache server related instructions
Check server status: systenctl status apache2
Start the server: systemctl start apache2 or sudo / etc / init.d/apache2 start
Shut down the server: systemctl stop apache2 or sudo / etc / init.d/apache2 stop
Restart the server: systemctl restart apache2 or sudo / etc / init.d/apache2 restart
Test
It’s one thing to open a browser and enter your IP address on your host, or 127.0.0.1 or localhost. Not surprisingly, the Apache 2 Ubuntu default page, the Apache 2 Ubuntu default page, will appear.

 

In depth study, this page is actually an HTML page. Search for this file in the terminal and input the command: sudo find / – name index.html
By default, this file is placed in the / var / www / HTML folder. That is to say, if we want to build our own website, we just need to name the actual page of our website as index.html And put it in this folder. Of course, this is changed in the corresponding configuration file.
This concludes the Apache server installation tutorial.

[step 3] install MySQL database
① Check whether MySQL database is installed on your Ubuntu system before installation
    dpkg -l | grep mysql
If the system has installed MySQL database, the following message will appear

 

   ② Install database
    apt install mysql-server
sameDo you want to continue? [y / N] enter y and press enter.
The next thing is the same. Just wait.
③ Check whether the database is installed successfully
    netstat -tap | grep mysql
If the following prompt appears, the database installation is successful

 

 Note: operation database related instructions
Please refer to the blog Garden article – >Installing MySQL under Ubuntu 18.04
[step 4] install PHP
PHP added support for dynamic web page server web page processing function, is a common writing back-end language, this language is easy to learn, difficult to master, you plan to learn PHP partners to prepare for the psychological.
① Install PHP
    sudo install php
sameDo you want to continue? [y / N] enter y and press enter.
The next thing is the same. Just wait.
② View PHP version instructions
    php -v
③ Create a new file named / var / www / HTML index.php
    sudo nano /var/www/html/index.php
④ Write the following code in it
    <?php
      phpinfo();
    ?>
⑤ Press Ctrl + O > Enter to save > Ctrl + X to exit
Open the browser and enter the IP address in the address bar/ index.php Or enter 127.0.0.1/ index.php Or enter localhost/ index.php
Without exception, you’ll see the default information page for PHP.

 

[step 5] select the installation module and software
The above four steps have already set up the web server, and there is already a foundation. Now you can make great use of it.
Installation and use of phpMyAdmin
    apt install phpmyadmin
sameDo you want to continue? [y / N] enter y and press enter.
The next thing is the same. Just wait.
There will be some selection boxes, select in turn
Apache2 > Yes > set password
After completion, enter IP address / phpMyAdmin in the browser. No accident, the following interface will appear.

 

Complete, so that we can manage our database data with a graphical interface!

At this point, our web server is basically set up, we can build our own site in the HTML folder of Linux system. In the later stage, we can improve our website, add various small tools, and then apply for an IP and domain name, so that we can visit our site anytime and anywhere, which is very convenient.

  Warm reminder: please find a place to record the database account password, if forgotten will be a very headache!

Recommended Today

Java security framework

The article is mainly divided into three parts1. The architecture and core components of spring security are as follows: (1) authentication; (2) authority interception; (3) database management; (4) authority caching; (5) custom decision making; and;2. To build and use the environment, the current popular spring boot is used to build the environment, and the actual […]