What is A2enMod on Linux
How to set up your Apache server on Linux
If you want to put websites online, you need a web server. To gain initial experience with it, simply install the necessary software, i.e. the Apache web server, on your Linux PC at home.
Depending on the survey, Linux has a market share of at least 40 percent in web servers. One of the most popular web servers is Apache. The Apache Software Foundation is more than 15 years old. It is therefore worthwhile to deal with this technology - whether for private or commercial websites. A Linux PC at home is sufficient for experimenting, for which we mainly describe the installation in this article. If you want more, you can rent a Linux server in the data center from around 30 euros per month. Virtual servers, whose computing power is shared by several users, are available from around five euros per month. The configuration here is similar to that on your own PC.
1. Preparations for your own Apache server: Install packages
The Apache web server is usually installed in combination with PHP and MySQL. Apache itself only delivers static HTML pages. Dynamic HTML pages, on the other hand, are generated from database contents using a script language such as PHP (PHP Hypertext Preprocessor).
Most content management systems (CMS) such as Wordpress or Joomla therefore also require PHP and the MySQL database. By the way, PHP is not considered to be particularly secure. Web administrators should therefore take some mandatory measures to increase security.
The required software packages are available for all common Linux distributions via the respective package management. Most web hosts offer Cent-OS, Open Suse, Debian or Ubuntu as operating systems. The following descriptions are for Ubuntu 14.04 LTS and relatives. For other distributions, the packages are likely to have a slightly different name and the installation paths may be different.
Open a terminal window on the local Linux PC or connect to the server via SSH:
Replace “[User]” with the login name, “[Server]” with the computer name or its IP address.
Then confirm the SSH key and log in with your password. Use the following two lines to update the package list and install the necessary software:
The system now sets up Apache, the Apache documentation, PHP and My SQL Server and My SQL Client. php5-mysql enables access to a My-SQL database via PHP. php5-gd is a frequently used module for accessing image files.
Finally, Phpmyadmin is a web application for convenient administration of My SQL. When installing My SQL Server, set a password for the administrative My SQL user "root" and select "apache2" for the automatic configuration. At Phpmyadmin you answer the question about “dbconfig-common” with “Yes” and then enter the My-SQL-root-password you selected previously. Then you have to define another password with which Phymyadmin should log in to My SQL in the future.
Speaking of terminal windows: Mastering the most important network commands under Linux is part of the basic craft of an Apache administrator under Linux. Make sure you get to know it once!
2. Apache web server: the first steps
You test the Apache installation by calling up the address "http: // localhost /" in the browser. The "Apache2 Ubuntu Default Page" appears with some information on the installation. Call up the Apache documentation installed on the hard disk via "http: // localhost / manual". When calling “http: // localhost”, Apache does nothing else than deliver the file “index.html” from the configured directory. In Ubuntu this is "/ var / www / html".
Set up websites: The Apache configuration files are located in the “/ etc / apache2” directory. The "sites-available" directory contains conf files for individual sites. Ubuntu has “000-default.conf” for the standard site and “default-ssl.conf” for an SSL-encrypted site. Under “/ etc / apache2 / sitesenabled” you will see a symlink to “/etc/apache2/sites-available/00-default.conf”. Only this symlink is taken into account by Apache. In this way it is possible to store several websites with different addresses in "sites-available" and to activate or deactivate them if necessary. To try out the site configuration, make a copy of “00-default.conf” under the name “test01.conf”. As with all of the following steps, this must be done with root rights in the terminal. A file manager like Midnight Commander (package name "mc") is helpful here.
1. Open "test01.conf" in an editor, in Midnight Commander for example via the F4 key (the MC is still doing its job - unfortunately its development has been stopped). Enter the value “test01.localhost” after “ServerName”. Change “Document Root” to “/ var / www / test01”, and after “ErrorLog” and “CustomLog” change the file names to “error_test01.log” and “access_test01.log”.
2. In the terminal, activate the site with a2ensite test01. As after every change, reload Apache afterwards with service apache2 reload so that the configuration is read in again.
3. In the directory “/ var / www / test01” create a file with the name “index.html” and a content like
4. Open the “/ etc / hosts” file in the editor and insert the following line: 127.0.0.1 test01.localhost “test01.localhost” now refers to the same internal IP address 127.0.0.1 of the computer as “localhost”. By specifying after “ServerName” in “test01.conf”, Apache can switch between queries to “localhost” and “test01.
localhost ”and deliver the appropriate“ index.html ”. For a server that can be reached on the Internet via its domain name, you do not have to adjust the "/ etc / hosts" file. Here the DNS server ensures that additional domains or subdomains can be reached.
Now call up the address "http: //test01.localhost" in the browser to see the new website. With a2dissite test01, you can remove the link in “/ etc / apache2 / sitesenabled” again and thus deactivate the site.
Activate modules: Apache has several modules that provide the web server with additional functions activated by default. You can recognize this by the links under "/ etc / apache2 / mods-enabled". Many CMS also need "mod_rewrite". This allows URLs to be changed dynamically according to certain patterns, especially for search engine optimization. You activate the module with
With a2dismod module name you can deactivate modules again if necessary. After changing the module configuration, you must run service apache2 reload. Another interesting module is “mod_userdir”, which you activate with a2enmod userdir. Every Linux user can then create the directory “public_html” in his home directory and store HTML files in it. Call up the sites via "http: // localhost / ~ [User]".
- What are the natural predators of jellyfish
- Why do people die of viruses
- What is Heroku tool belt
- Is IIHM good for hospitality management
- Can GTX 1060 run on MacBook
- How can I give an unbiased opinion
- What is ultralight backpack
- What are good social media strategists
- Are diseases made by humans
- Is the deletion of the IIT test not the end
- Why do I always eat too much
- Why is Hindi mandatory teaching in Maharashtra
- What is a two-plate shape
- Has it ever helped you to be crazy?
- How can i get carbon monoxide
- Why are convertible high heels not popular
- What should real estate agents blog about
- How much acetic acid does vinegar contain
- When will my period come
- Will DD win this 2018 IPL
- What do you dislike about SEO
- Why do cats have whiskers
- The character Wolverine could starve to death
- Who is Mats Wilander