亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home System Tutorial LINUX How to Host A Website On Your Home Linux System for Free

How to Host A Website On Your Home Linux System for Free

Jun 21, 2025 am 10:10 AM

The term web server can be used to refer to both hardware and software, or both working together. For the purpose of this guide, we will focus on the software side and see how you can host a website on your Linux box.

A web server is a software program that receives and responds to client requests via the HTTP/HTTPS protocols. Its primary purpose is to display website content which, oftentimes, is in the form of text, images, and video.

A web server can either serve static or dynamic content. Static content, as the name infers, refers to content that hardly changes and is bound to remain the same. The server sends back content to the user’s browser as is.

Dynamic content is content that often changes or is constantly updated. To serve dynamic content, a web server must also work alongside a database server and server-side scripting languages.

This guide will demonstrate how to set up an Apache web server to host a website on your Linux system for free.

Table of Contents

Requirements

To follow along in this guide, ensure you have the following in place.

  • A dedicated Public IP address can be obtained from your ISP.
  • A Linux box, which can be a Linux server installation of your preferred OS variant. For this guide, we will use Debian 11.

Check out a few guides that can give you insights on installing a Linux server.

  • How to Install a Debian 11 (Bullseye) Minimal Server
  • How to Install a Debian 10 (Buster) Minimal Server
  • How to Install Ubuntu 20.04 Server
  • How to Install Rocky Linux 9 Server
  • How to Install AlmaLinux 9 Server
  • How to Install RHEL 9 for Free

You also required a LAMP server installed, which is an acronym for Linux, Apache, and MySQL (this can also be MariaDB). Here are a few guides on how to install the LAMP stack in Linux.

  • How to Install LAMP on Debian 11 Server
  • How to Install LAMP on Debian 10 Server
  • How to Install LAMP Stack in Ubuntu 20.04
  • How to Install LAMP on Rocky Linux 9/8
  • How to Install LAMP Stack in AlmaLinux 9/8
  • How to Install LAMP on RHEL 9/8

How to Host A Website on Linux Server

In this section, we will proceed and discuss the main components of a web server.

What is Apache?

Apache is a popular free and open-source cross-platform web server that is released under Apache License 2.0. It’s one of the most widely used web servers accounting for nearly 32.2% of the web server market share.

To check the latest version of Apache available, and if it is installed on your server, run the command:

# apt-cache policy apache2 (On Debian-based OS)

From the output, you can see the parameter Installed: (none) implying that it is not installed yet. You also get information about the latest version being offered by Debian / Ubuntu repository, which in this case is 2.4.52.

How to Host A Website On Your Home Linux System for Free

On modern Red Hat distributions, you can check for the availability of Apache using the following dnf command as follows.

# dnf search httpd

How to Host A Website On Your Home Linux System for Free

From the above output, you can see that the Apache httpd package is available for download. If Apache is not installed on your system, use the ‘a(chǎn)pt‘ or ‘dnf‘ package managers to install Apache as shown.

On Debian-based systems:

$ sudo apt install apache2 -y 	 
$ sudo systemctl start apache2	 
$ sudo systemctl enable apache2	 
$ sudo systemctl status apache2

How to Host A Website On Your Home Linux System for Free

On Red-Hat-based systems:

# dnf install httpd -y 	 
# systemctl start httpd	 
# systemctl enable httpd	 
# systemctl status httpd

How to Host A Website On Your Home Linux System for Free

What is MariaDB?

A fork of MySQL, MariaDB is one of the most popular and open-source relational database management systems. Nowadays, it’s preferred to MySQL due to its faster speeds in replication and performing queries as well as security and a vast array of storage engines.

To install MariaDB, On Debian-based systems:

	 
$ sudo apt install mariadb-server mariadb-client -y	 
$ sudo systemctl start mariadb	 
$ sudo systemctl enable mariadb	 
$ sudo systemctl status mariadb	 

The following output shows that MariaDB is installed and running as expected.

How to Host A Website On Your Home Linux System for Free

To install MariaDB, On RHEL-based systems:

	 
# dnf install mariadb-server -y	 
# systemctl start mariadb	 
# systemctl enable mariadb	 
# systemctl status mariadb	 

How to Host A Website On Your Home Linux System for Free

What is PHP?

PHP is a recursive acronym for PHP Hypertext Preprocessor, which is a popular general-purpose scripting language that is mostly used in web development.

To install PHP, On Debian-based systems:

	 
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install  ca-certificates apt-transport-https software-properties-common
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt update
$ sudo apt install php8.0 libapache2-mod-php8.0 

To install PHP, On RHEL-based systems, you need to first enable the EPEL repository.

$ sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm  [RHEL 9]
$ sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm  [RHEL 8]

Next, enable the Remi repository, which offers the latest version of PHP on RHEL-based systems.

$ sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm  [RHEL 8]
$ sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm  [RHEL 8]

Once EPEL and Remi repositories are enabled on the system, you can install PHP as shown.

# dnf module list php
# dnf module enable php:remi-8.0 -y 
# dnf install php php-cli php-common

With all the components installed, you can now build your website using WordPress CMS, which is software that makes it easy or users to develop and manage a website without necessarily having knowledge of web design languages such as HTML, CSS, PHP, and Javascript.

Creating a Simple Website Using WordPress in Linux

For demonstration, we will install WordPress on Debian 11 and RHEL 9 systems, which will provide a sample website that can be further customized to your preference.

This section assumes that you already have the LAMP stack installed.

Step 1: Install Additional PHP Modules

To proceed, install additional PHP modules that are required by WordPress as shown.

To install PHP modules, On Debian-based systems:

$ sudo apt install php libapache2-mod-php php-pear php-cgi php-common php-mbstring php-zip php-net-socket php-gd php-mysql php-bcmath

To install PHP modules, On RHEL-based systems:

# dnf install php-gd php-soap php-intl php-mysqlnd php-pdo php-bcmath php-curl php-zip php-xmlrpc wget

Step 2: Create a Database for WordPress

Written in PHP, WordPress is a data-driven, free, and open-source content management system. A database is an essential component of WordPress.

The database is used to store all the blog posts, pages, categories, comments, themes, plugins as well as WordPress configuration files.

To create a database for WordPress, login to the MariaDB database server:

$ sudo mysql -u root -p

Next, create a database as shown

CREATE DATABASE wordpress_db;

Next, create a database user and assign all privileges to the user on the database.

GRANT ALL PRIVILEGES ON wordpress_db.* to wordpress_user@localhost identified by 'P@ssword321';

Then finally reload the grant tables to save the changes made and exit the database.

FLUSH PRIVILEGES;
QUIT;

Step 3: Download WordPress

With the database in place, proceed and download the latest WordPress tarball file using the wget command.

$ wget https://wordpress.org/latest.tar.gz

Once downloaded, extract the compressed file using the tar command.

$ tar -xvzf latest.tar.gz

The command extracts the contents of the file into a folder called wordpress. Move or copy the folder into the Document Root for the Apache webserver.

$ sudo mv wordpress/ /var/www/html/

Next, assign the following permissions and ownership rights. $ sudo chmod 755 -R /var/www/html/wordpress/ $ sudo chown -R www-data:www-data /var/www/html/wordpress/

Step 4: Create an Apache Virtual Host for WordPress

The terminology virtual host refers to the practice of hosting multiple websites on a single server. If you intend to host multiple websites on a single server, you need to create a virtual host for each website.

In this case, you need to create a Virtual host for the WordPress website as follows.

$ sudo nano /etc/apache2/sites-available/wordpress.conf  [On Debian]
# vi /etc/httpd/conf/httpd.conf [On RHEL]

Paste the following lines of code to define the virtual host. For the ServerName directive, provide the server’s IP address or Fully Qualified Domain Name, which should point to the dedicated public IP address.

<virtualhost>
     ServerAdmin admin@your_domain.com
     DocumentRoot /var/www/html/wordpress
     ServerName 192.168.0.100

     <directory>
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     </directory>

     ErrorLog ${APACHE_LOG_DIR}/your-domain.com_error.log
     CustomLog ${APACHE_LOG_DIR}/your-domain.com_access.log combined

</virtualhost>

Save the changes and exit the file.

To connect to the database, some additional modifications are needed. So, navigate into the wordpress folder.

$ cd /var/www/html/wordpress/

Next, update the wp-config.php file with the contents of the wp-config-sample.php file.

$ cp wp-config-sample.php wp-config.php
$ sudo nano wp-config.php

Next, update the database name, db username, and password directives with the database details.

Next, enable the new WordPress site as follows on Debian-based systems.

$ sudo ln -s /etc/apache2/sites-available/wordpress.conf /etc/apache2/sites-enabled/wordpress.conf
$ sudo a2ensite wordpress
$ sudo a2enmod rewrite
$ sudo a2dissite 000-default

To effect the changes, restart Apache.

$ sudo systemctl restart apache2   [On Debian]
# systemctl restart httpd  [On RHEL]

Step 4: Complete WordPress Setup on a Browser

To complete the setup, browse your web server’s IP address as shown:

http://server-ip

You should get the WordPress welcome page displayed as shown. Select your preferred language and click ‘Continue’.

How to Host A Website On Your Home Linux System for Free

Next, fill in the site details.

How to Host A Website On Your Home Linux System for Free

Then click ‘Install WordPress’ to complete the WordPress setup.

How to Host A Website On Your Home Linux System for Free

If everything went right, you will get a confirmation that the installation was successful. To log in, click the ‘Log In‘ button.

How to Host A Website On Your Home Linux System for Free

This ushers you to the WordPress dashboard as you can see. At this point, you can experiment with various themes to enhance the appearance of your sample website.

How to Host A Website On Your Home Linux System for Free

Step 5: Access WordPress Using Port Forwarding

Since you are self-hosting your web server from a Linux system at home or your Local Area Network (LAN), the next step is to make it accessible to external users or users outside your LAN (Local Area Network). This is where port forwarding comes in.

Port forwarding, also referred to as port mapping, is a technique that allows external devices to access servers or resources within a private network over the internet. The whole idea is to access private networks from outside, without which it would be impossible since external devices cannot communicate with internal IP addresses.

In your setup, you need to forward the port on which the web server is listening, (in most cases, this is port 80 for HTTP traffic or 443 for HTTPS) as well the static private IP address of the web server.

So, log in to your router and head over to the Port forwarding section. In our example, we are using the DLink router to port forward the web server’s ports (80 and 443) and private IP (192.168.0.100) to the Dedicated IP Public IP assigned by the ISP.

In your case, specify the ports and private IP of the web server and save the changes.

How to Host A Website On Your Home Linux System for Free

To save the changes, you might be required to reboot the router. So, go ahead and do exactly that.

Once the port forwarding is properly carried out, you can now reach your web server outside your network via the Public IP address.

Conclusion

In this guide, we have demonstrated how you can self-host your web server using Apache on a Linux box. Your feedback on this guide is welcome.

The above is the detailed content of How to Host A Website On Your Home Linux System for Free. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72
Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux Jul 05, 2025 am 09:25 AM

LXD is described as the next-generation container and virtual machine manager that offers an immersive for Linux systems running inside containers or as virtual machines. It provides images for an inordinate number of Linux distributions with support

How to troubleshoot DNS issues on a Linux machine? How to troubleshoot DNS issues on a Linux machine? Jul 07, 2025 am 12:35 AM

When encountering DNS problems, first check the /etc/resolv.conf file to see if the correct nameserver is configured; secondly, you can manually add public DNS such as 8.8.8.8 for testing; then use nslookup and dig commands to verify whether DNS resolution is normal. If these tools are not installed, you can first install the dnsutils or bind-utils package; then check the systemd-resolved service status and configuration file /etc/systemd/resolved.conf, and set DNS and FallbackDNS as needed and restart the service; finally check the network interface status and firewall rules, confirm that port 53 is not

How would you debug a server that is slow or has high memory usage? How would you debug a server that is slow or has high memory usage? Jul 06, 2025 am 12:02 AM

If you find that the server is running slowly or the memory usage is too high, you should check the cause before operating. First, you need to check the system resource usage, use top, htop, free-h, iostat, ss-antp and other commands to check CPU, memory, disk I/O and network connections; secondly, analyze specific process problems, and track the behavior of high-occupancy processes through tools such as ps, jstack, strace; then check logs and monitoring data, view OOM records, exception requests, slow queries and other clues; finally, targeted processing is carried out based on common reasons such as memory leaks, connection pool exhaustion, cache failure storms, and timing task conflicts, optimize code logic, set up a timeout retry mechanism, add current limit fuses, and regularly pressure measurement and evaluation resources.

Install Guacamole for Remote Linux/Windows Access in Ubuntu Install Guacamole for Remote Linux/Windows Access in Ubuntu Jul 08, 2025 am 09:58 AM

As a system administrator, you may find yourself (today or in the future) working in an environment where Windows and Linux coexist. It is no secret that some big companies prefer (or have to) run some of their production services in Windows boxes an

How to Burn CD/DVD in Linux Using Brasero How to Burn CD/DVD in Linux Using Brasero Jul 05, 2025 am 09:26 AM

Frankly speaking, I cannot recall the last time I used a PC with a CD/DVD drive. This is thanks to the ever-evolving tech industry which has seen optical disks replaced by USB drives and other smaller and compact storage media that offer more storage

How to find my private and public IP address in Linux? How to find my private and public IP address in Linux? Jul 09, 2025 am 12:37 AM

In Linux systems, 1. Use ipa or hostname-I command to view private IP; 2. Use curlifconfig.me or curlipinfo.io/ip to obtain public IP; 3. The desktop version can view private IP through system settings, and the browser can access specific websites to view public IP; 4. Common commands can be set as aliases for quick call. These methods are simple and practical, suitable for IP viewing needs in different scenarios.

How to Install NodeJS 14 / 16 & NPM on Rocky Linux 8 How to Install NodeJS 14 / 16 & NPM on Rocky Linux 8 Jul 13, 2025 am 09:09 AM

Built on Chrome’s V8 engine, Node.JS is an open-source, event-driven JavaScript runtime environment crafted for building scalable applications and backend APIs. NodeJS is known for being lightweight and efficient due to its non-blocking I/O model and

How to Setup MySQL Replication in RHEL, Rocky and AlmaLinux How to Setup MySQL Replication in RHEL, Rocky and AlmaLinux Jul 05, 2025 am 09:27 AM

Data replication is the process of copying your data across multiple servers to improve data availability and enhance the reliability and performance of an application. In MySQL replication, data is copied from a database from the master server to ot

See all articles