Apache on linux or windows

Install Apache on Windows 10 WSL- HTTP Web Server

You can install Apache on Windows 10 very easily it is not a Sisyphean task anymore, you don’t need to need to go through multiple documentations to understand how to configure and up it to work with. As we know the Apache HTTP web server is part of Linux and work generally in LAMP (Linux, Apache, MySQL, PHP) environment to support any web application. Thus, on Windows Desktop or server, definitely, you are not looking for solely Apache installation, perhaps whole LAMP stack. Hence, it could be a very tedious job to install each part of LAMP on a system which is primarily not meant for it. Other options that left are XAMPP or WAMPServer, however, they are not meant to work for any production environment and also some times not so much performative. In such situation, WSL (Windows subsystem for Linux) is a boon on Microsoft Windows 10 and Windows 2016 servers.

You can use some Linux server such as Ubuntu 18.04 or Centos 7 on Windows subsystem for Linux to install Apache along with Mysql and PHP to get the same degree of performance as you except on some native Linux server or Desktop.

Moreover, with the announcement of WSL 2 (Windows subsystem Linux second version) in which Microsoft has integrated full-fledged Linux kernel for WSL makes it better than before. Let’s see how to do this…

Install Apache HTTP web server on Windows 10 -WSL

Step 1: Enable WSL on Windows 10 or 2016 server

If you haven’t enabled the WSL yet, then simply search for “Turn Windows feature on or off” in the Windows search box and open it. From where select Windows subsystem for Linux to enable it. For more info on it, see our article: Enable WSL on Windows 10 or server.

Step 2: Download Ubuntu or Centos for WSL

To install Apache on Windows WSL we have to first enable the Windows subsystem for Linux which we already did in the first step of this article. Now, its time to install some Linux distro over it. If you want to use Ubuntu 18.04 then simply open the Microsoft Store and search for Ubuntu. When it appears, install it.

Currently, Centos 7 is not available on Windows store and to install it we have to download it manually. Here you can see how to do that: Centos 7 Linux on Windows Subsystem for Linux.

Читайте также:  Нет wifi кали линукс

Install Apcahe on Windows 1o via Ubuntu WSL

Step 3: Launch Linux OS on Windows WSL

After installing search and open Ubuntu, it will take some time to get ready. Once it is, a Command terminal window will appear and then move to the next step.

Note: The WSL doesn’t support graphical user interface by default, however, it is good to easily access and install Linux apps over it.

Install Apache HTTP web server Windows

Step 4: Install Apache on Windows 10 subsystem for Linux

Now from here, everything is same as installing Apache web server on some Linux operating system. Type the below-given command in Windows 10 WSL command Terminal.

sudo apt-get install apache2

Command For Ubuntu WSL

WIndows 10 centos WSL

Step 5: Enable Apache service on Windows

Once the Web server of our based on Apache installed on Windows 10 WSL, its time to enable its services other it won’t work at all. For starting the HTTP Services use below command:

sudo service apache2 start

start Apache services on Windows

Step 5: Test Windows Apache web server is running or not

The install of Apache HTTP web server on Windows 10 or 2016 servers is finally completed, its time to check whether it is working or not. For that simply open your system’s browser and type http://127.0.0.1:80.

Test Windows web server is running

In this way, you can install Mysql and PHP + PHPMyAdmin too for testing other Linux web applications on Windows using LAMP stack.

Источник

How to Set Up a Local Web Server (Windows, Mac, Linux)

How To Set Up A Local Web Server Featured

When developing a website, a web designer needs to be able to see his webpages in the same way the end user would. Sometimes simply clicking on and viewing your HTML files in the web browser is enough, but if you want to test dynamic content, you will need to set up a local web server. Doing this is quite simple and can easily be accomplished on Windows, macOS, and Linux. There are many types of web servers available, but we use Apache (check out our comparison of Nginx vs Apache to see which is better for you) in this tutorial, as it is the most common server around, very easy to set up, and compatible with all major operating systems.

If you are running a static website instead of a dynamic one, you can also check out our review of some of the best static website CMS out there.

Content

Set Up a Local Web Server on Linux

Apache was designed for Unix-like operating systems. Linux falls under this category, and the installation and configuration of an Apache webserver can be done in one step.

Here we deal with the command line. Most popular distributions allow you to install Apache without compiling it from source using one simple command.

For Debian, Ubuntu, and Ubuntu-based distro:

For Red Hat and CentOS

Once installed, navigate in your web browser to either “127.0.0.1” or “localhost.” If it displays “It Works!” that means your Apache installation is successful.

Web Server Ubuntu Install Apache

To better understand how Apache is serving this particular webpage, let’s edit it. To do this, navigate to the root web directory of your Linux local machine.

Open “index.html” as root with your favorite text editor.

Читайте также:  Объединить содержимое двух файлов linux

Search for “It Works!” and change the text to something random like “Make Tech Easier!” (It could be anything really.) Make sure to save the file.

Now refresh the webpage on 127.0.0.1. You should see “Make Tech Easier!” where “It Works!” was formerly.

Web Server Ubuntu Edit Default

Now that you have set up a simple web server, you can play with the configuration settings in “apache2.conf.”

sudo nano /etc/apache2/apache2.conf

Note: be aware that every time you make a configuration change, you will need to restart Apache for it to apply.

sudo systemctl restart apache2

If this does not work, you can restart it by directly executing the upstart file.

sudo /etc/init.d/apache2 restart

Set Up a Local Web Server on macOS

The good thing about macOS is that Apache is installed on it by default. All you need to do is turn it on.

In Finder, go to “Applications -> Utilities,” then double-click on Terminal to open it.

Macos Open Terminal App

To turn on your already pre-installed Apache web server, run the following command:

To test that our web server is running, navigate to “127.0.0.1” or “localhost” in your web browser.

Macos Web Server It Works

We can change the content of the webpage by simply navigating to the document root the same way we did in Linux. The only thing that is different is the path location.

cd /Library/WebServer/Documents/

Now edit the “index.html.en” file using your favorite text editor. Change “It works!” to “Hello World!”

mac-nano-open-index-html

If we refresh our webpage hosted on 127.0.0.1, we now see the changes reflected.

Macos Web Server Hello World

To further configure Apache web server under macOS, navigate to the “httpd.conf” file.

sudo nano /etc/apache2/httpd.conf

Like Linux, you can easily restart the Apache service using the apachectl command with root privileges.

Set Up a Local Web Server on Windows

Unlike Linux and macOS, Windows is not Unix-based, so there is no one-liner to install it. Fortunately, there are several install wizards that bundle things like Apache, MySQL, and PHP together to make our lives easier. One of them is XAMPP.

Note: XAMPP is available for Linux and macOS, too.

Download the Windows version of XAMPP and begin the installation. Execute the installer when prompted. You can select only Apache if all you need is a web server. However, if you are planning on using a database, you may want to select MySQL as well.

How To Set Up A Local Web Server Install Windows

Continue through the installation and click “Finish” when complete. By default, the XAMPP control panel will be launched.

How To Set Up A Local Web Server Xampp Control

Click “Start” for Apache and MySQL, if needed.

If you navigate to “127.0.0.1” or “localhost” in your web browser, you should see the XAMPP configuration page.

How To Set Up A Local Web Server Xampp Config

To create a new webpage, the procedure is the same. Open notepad and create a sample HTML file. Name it “hello.html.”

How To Set Up A Local Web Server Windows Notepad

Save it in the document root located in “c:\xampp\htdocs\”.

Navigate to it using your web browser by going to 127.0.0.1/hello.html . You’ll be able to see the webpage you created.

How To Set Up A Local Web Server Windows Hello

Setup a LAN Server in Windows

Another option is to setup a LAN server in Windows. You don’t need to install anything for this method. However, you will need Ethernet cables for a direct connection to your router or router/modem combo.

  1. Connect your computer via Ethernet cable to your router.
  2. Open Start and search for “Control Panel.” Open the result.
  3. Select “Network and Sharing Center.”
Читайте также:  Linux все usb устройства

How To Set Up A Local Web Server Network Sharing

How To Set Up A Local Web Server Network Sharing New

How To Set Up A Local Web Server Network Sharing New Internet

  1. You can connect other devices to the LAN via Ethernet or Wi-Fi. Obviously, for Wi-Fi, you’ll need to setup a Wi-Fi password and use that to connect other devices. You can also create a Homegroup to share resources from Network and Sharing Center.

If you what you want is to connect to a remote folder, you don’t have to setup a web server to access it. You can easily do it by mapping a WebDAV drive to Windows.

Additional Devices

Frequently Asked Questions

Is Apache the only option for a web server?

Apache is an excellent web server solution, but it is not the only option. You may want to look at IIS as an option for Windows, as it supports many Windows authentication features that Apache does not.

Another option is Python for a simple local HTTP server. It’s already installed on macOS and Linux, but you can install it for Windows from Python.org.

Why am I getting warnings that Apache won’t work with my antivirus?

The purpose of antivirus is to keep others out of your computer. When setting up a local web server, you’re opening up your computer to outside connections. Your antivirus can work together with Apache. You just need to allow Apache access via your antivirus. You should get a warning from your antivirus along with a prompt to either deny or allow access. The exact steps vary greatly based on the antivirus you use.

Depending on how you’ll use your server, you may want to take extra steps to secure it. For example, there are a variety of open source tools to secure Linux servers.

Should I use my main computer or a dedicated computer for setting up a web server?

If you’re just doing basic local testing, you’re not going to have much traffic coming to your computer. It’s fine to just use your main computer and turn the server on/off as needed.

If you’re hosting a website or other resource from your computer, it’s better to use a dedicated computer as the server. You’ll be dealing with more traffic, which uses more resources. This makes it harder for your computer to perform as well for your everyday tasks.

Does my ISP mind if I set up a local web server?

Some ISPs do have bandwidth restrictions and may prohibit you from hosting your own server, especially for high traffic sites and P2P downloading or torrents. Also, if you have hard data limits, you’ll probably want to avoid setting up a server outside of basic testing purposes.

Most ISPs don’t mind local servers as they don’t have extreme usage. For instance, basic testing or hosting a calendar server using Baikal. If you’re not sure, contact your ISP to ask and explain what you’re trying to accomplish. If you do need more bandwidth without restrictions, they may set you up with a business account.

Crystal Crowder has spent over 15 years working in the tech industry, first as an IT technician and then as a writer. She works to help teach others how to get the most from their devices, systems, and apps. She stays on top of the latest trends and is always finding solutions to common tech problems.

Our latest tutorials delivered straight to your inbox

Источник

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