Sample Web Page

Configuring a Fedora Linux Based Web Server

In this chapter we will explain how to configure a Fedora Linux system to act as a web server.

Contents

Requirements for Configuring a Web Server

To set up your own web site you need a computer, an operating system, a web server, a domain name, a name server and an IP address.

The computer can be any system capable of running Linux. In terms of an operating system, we will assume you are using Fedora Linux. Fedora Linux supports the Apache web server which can easily be installed once Fedora is up and running. A domain name can be registered with any domain name registration service.

If your ISP provides static IP addresses then you will need to associate your domain with your static IP address. This is achieved using a name server. Some domain registration services will provide this service for you. If yours does not, you can create a free account at http://www.zoneedit.com and use their name servers to point your domain name at your static IP address.

If you do not have a static IP address (i.e. your ISP provides you with a dynamic address which changes frequently) then you can use one of a number of free services which map your dynamic IP address to your domain name. One such service is provided by http://www.dnsExit.com.

Once you have your domain name and your name server configured the next step is install and configure your web server.

Installing the Apache Web Server on Fedora Linux

The standard web server on Linux is Apache. The web server is the technology that receives requests from web browsers and servers up the requested web pages to those browsers.

The desktop version of Fedora Linux does not install the Apache web server by default. Unless you specifically requested the Apache web server during installation, therefore, the first step in setting up a web server may be to install the Apache server. To check whether the server is already installed, open a Terminal window (Applications->System Tools->Terminal) and run the following command:

If rpm generates output similar to the following, the apache server is already installed:

Alternatively, if rpm generates a «package httpd is not installed» then the next step, obviously, is to install it. This can be performed either from the command-line or using the Add/Remove Software tool. To use this tool, open the System->Administration desktop menu and select Add/Remove Software. Enter your password if prompted to do so. Click in the Find text field and search for httpd. After the search completes the Apache HTTP Server should be listed in the search results. Click on the toggle next to the httpd server. Finally, click on Apply in the toolbar to begin the installation.

Читайте также:  Автовыполнение команды linux при загрузке

To install Apache from the command-line start a terminal window (Applications->System Tools->Terminal) and run the following command at the command prompt:

Starting the Fedora Linux Web Server

Once the Apache server is installed, the next step is to verify that the server is running and, if it is not yet running, to start it.

The status of the server can be verified from the command-line or via the GUI Service Configuration tool. To check the status of the Apache httpd service from the command-line, enter the following command in a Terminal window:

If the above command indicates that the httpd service is not running, it can be launched from the command-line as follows:

su - /sbin/service httpd start

If you would like the Apache httpd service to start automatically when the system boots, this can be achieved by running the following command:

/sbin/chkconfig --level 3 httpd on

To configure the Apache service using the Service Configuration tool, select the System->Administration->Services menu option and scroll down the list of services until you find httpd. Select the item in the list and click on the Start button. To ensure the services starts automatically on reboot, also click in the Enable toolbar button.

Testing the Web Server

Once the installation is complete the next step is to verify the web server is up and running. To do this fire up the web browser by clicking on the Firefox logo in the top desktop panel and enter 127.0.0.1 in the address bar (127.0.0.1 is the loop-back network address which tells the system to connect to the local machine). The browser should load the Fedora Test Page.

Congratulations, you have now installed the web server and served up what will hopefully be the first of many web pages.

Configuring the Apache Web Server for Your Domain

The next step in setting up your web server is to configure it for your domain name. This is performed in the /etc/httpd directory. To configure the web server open a terminal window and change directory to /etc/httpd. In this directory you will find a number of sub-directories. Change directory into conf sub-directory where you will find an ‘httpd.conf’ file which contains the configuration settings for the Apache server.

Edit the httpd.conf file using your favorite editor using the su command to ensure you have write permission to the file. Once loaded, there are a number of settings that need to be changed to match your environment:

The ServerAdmin directive defines an administrative email address for people wishing to contact the webmaster for your site. Change this to an appropriate email address where you can be contacted:

Читайте также:  Linux user memory usage

Next it the ServerName and ServerAlias directives need to be defined so that the web server knows which virtual host this configuration file refers to:

Next, we need to define where the web site files are going to be located using the DocumentRoot directive. The tradition is to use /var/www/domain-name:

DocumentRoot /var/www/myexample.com

Next, create the /var/www/myexample.com directory and place an index.html file in it. For example:

  Welcome to MyExample.com  

The last step is to restart the apache web server to make sure it picks up our new settings:

su - /sbin/service httpd restart

Web Server and Firewall Issues

If your Fedora Linux system is configured to use a firewall, you will need to ensure that HTTP traffic on port 80 is permitted in order for external systems to be able to access your web server. Refer to the Basic Fedora Linux Firewall Configuration and Using Firestarter to Configure a Fedora Linux Firewall chapters of this book for details on configuring Fedora Linux Firewalls.

If the Fedora Linux system hosting your web server sits on a network protected by a firewall (either another computer running a firewall, or a router or wireless base station containing built in firewall protection) you will need to configure the firewall to forward port 80 to your web server system. The mechanism for performing this differs between firewalls and devices so check your documentation to find out how to configure port forwarding.

Once everything is configured it should be possible to enter the domain name of your web site into a browser anywhere in the world and access your web server.

Take your Fedora Linux Skills to the Next Level
Fedora 31 Essentials book is now available in Print ($36.99) and eBook ($24.99) editions. Learn more.

Источник

How to install Apache web server on Fedora

One of the most common uses for any Linux system is as a web server. By far the most prevalent and famous web server is Apache. Apache is readily available in Fedora in pre-packaged form. You can use it to host content and applications for free anywhere you have a server.

Installing Apache

First, install the software packages for the Apache server, using the sudo command. The recommended way to install the server is in a group of related packages.

sudo dnf group install "Web Server"

This command installs the entire Web Server package group. The group includes other commonly used tools such as:

  • PHP and Perl support
  • The squid caching proxy
  • Documentation
  • Traffic analysis tools

If for some reason you don’t want these helpful packages, you can install the web server by itself. Use this command:

The web server package, httpd, depends on some other packages. They must be installed for the web server to function. This command installs those dependencies.

Configuring the system

Next, you may need to configure the system so other computers can contact the web server. You can skip this step if you only want to test a web server on the same computer you’re on.

Fedora systems have a protective firewall by default. Therefore, you must open specific service ports in that firewall to let other computers connect. To open the specific firewall ports for the web server, run these commands:

sudo firewall-cmd --add-service=http --add-service=https --permanent sudo firewall-cmd --reload

The two service ports opened are:

  • http — Port 80, used for standard, non-secure web communications
  • https — Port 443, used for secure web communications
Читайте также:  Linux skip first line

Also note the reload command makes these services active. Therefore, if you haven’t made other firewall changes permanent, those changes are lost when you reload. If you only want to open these services temporarily, use this command:

sudo firewall-cmd --add-service=http --add-service=https

Testing the web server

Open a web browser on your system. Go to http://localhost and a web page like this appears:

Apache web server test page on Fedora

Apache web server test page on Fedora

This page confirms your web server is running correctly.

Now what?

The next steps are entirely up to you. Here is one article with ideas for what to do with your new web server.

Источник

Как установить сервер Apache в Fedora 35/34/33/32/31

hosting.energy недорогой хостинг сайтов

hosting.energy недорогой хостинг сайтов

В этом руководстве мы покажем вам, как установить Apache Server на Fedora 35. Для тех из вас, кто не знал, Apache HTTP — популярный веб-сервер для серверов Linux. Это бесплатный кроссплатформенный веб-сервер, поддерживаемый различными операционными системами. Разработчики предпочитают Apache за его скорость, безопасность, надежность, надежность и простоту настройки. Кроме того, Apache может удовлетворить потребности многих сред, поскольку позволяет устанавливать различные расширения и модули.

В этой статье предполагается, что у вас есть хотя бы базовые знания Linux, вы знаете, как использовать оболочку, и, что наиболее важно, вы размещаете свой сайт на собственном VPS. Установка довольно проста и предполагает, что вы работаете с учетной записью root, в противном случае вам может потребоваться добавить ‘ sudo ‘ к командам для получения привилегий root. Я покажу вам пошаговую установку веб-сервера Apache на Fedora 35.

Установите Apache Server в Fedora 35

Шаг 1. Прежде чем продолжить, обновите операционную систему Fedora, чтобы убедиться, что все существующие пакеты обновлены. Используйте эту команду для обновления пакетов сервера:

sudo dnf upgrade sudo dnf update

Шаг 2. Установка сервера Apache в Fedora 35.

По умолчанию Apache доступен в базовом репозитории Fedora 35. Затем мы можем установить веб-сервер Apache с помощью следующей команды:

После завершения установки нам нужно запустить сервер Apache, чтобы начать работу. Мы делаем это с помощью следующей команды:

sudo systemctl start httpd sudo systemctl enable httpd sudo systemctl status httpd

Шаг 3. Настройте основные параметры Apache:

Теперь редактируем файл конфигурации и устанавливаем: /etc/ httpd / conf / httpd . conf

nano etc/httpd/conf/httpd.conf

Добавьте следующую конфигурацию:

ServerAdmin admin@your-domian.com ServerName your-domian.com ServerTokens Prod

Шаг 4. Настройте брандмауэр.

Если у вас запущен firewalld, разрешите службы HTTP и HTTPS:

sudo firewall-cmd --add-service= --permanent sudo firewall-cmd --reload

Шаг 5. Доступ к тестовой веб-странице Apache.

После успешной установки убедитесь, что веб-сервер запущен и доступен, получив доступ к IP-адресу вашего сервера:

Как установить сервер Apache в Fedora 35

Поздравляю! Вы успешно установили Apache . Благодарим за использование этого руководства для установки веб-сервера Apache в вашей системе Fedora 35. Для получения дополнительной помощи или полезной информации мы рекомендуем вам посетить официальный сайт Apache .

Источник

Оцените статью
Adblock
detector