Debian apache2.4 Virtual Host use

Source: Internet
Author: User

It says Debian Apache2 and PHP7 are installed under the GNU. But it does not reflect that apache2 has been able to use PHP7, and here we record with virtual host.

Go to the directory where Apache is located:

If a friend who has worked with Wamp may find that the directory is not the same as under Windows, I used the same directory structure of the Apache under CentOS as the Windows, Debian is a bit different, as was the case when installing Apache in Pixelos.

Take it back, we know that the directory under Debian is a little different, what's the difference? The main is to conf site mods separate induction.

The sites-enabled here is just a soft connection to sites-available, Conf, and mods in the same vein.

After reading the directory structure, we'll see apache2.conf

The biggest difference between apache2.conf and the previous conf is here:

We can see that Apache will automatically load these folders under the. Load and. conf, which facilitates a lot. Mods are basically automatic installation, but vhost before if you want to set up a number of sites is all written in a vhost, so it is not easy to manage, if you want to divide the words are also manually set multiple, now can each site a conf file, very clear.

Here apache2.conf has turned on the vhost by default, so we just create a new site1.conf under the Sites-enabled folder and edit

Nano sites-enabled/site1.conf
<VirtualHost*:80>ServerName Site1.test.dev ServerAdmin [email protected] Documentroot/web/htdocs<Directory/web/htdocs>Options Indexes followsymlinks rewriteengine on Rewritecond%{request_filename}!-d Rewritecond%{request_filename}!-f rewriterule ^ index.php [L] allowoverride all Req Uire all granted</Directory>errorlog ${apache_log_dir}/error.log customlog ${apache_log_dir}/access.log combined #Include Co Nf-available/serve-cgi-bin.conf</VirtualHost>

Save exit.

I need to use address rewriting here, so I joined rewrite, so I'm going to open the rewrite module:

sudo a2enmod rewrite

Restart the service now:

sudo service apache2 restart

Then there is the first pit:

This pit does not have anything to do with Apache's service, purely Linux permissions.

Then there are pits, such as my directory is/web/htdocs, permissions to start from the Web open, or 403.

Okay, first, we'll find Apache's running users.

PS grep apache2

You can see that Apache2 's username is www-data, and now we're going to use Www-data.

Locate the directory (here is/web/htdocs) and then execute

chown -R www-data/Webchgrp -R www-data/Webchmod755 /web

Now try again (already under/web/htdocs/new index.php inside has <?php phpinfo ();?>)

Then go to thinkphp's official online download thinkphp_5.0_full.zip, put on the server to unzip.

To this, apache2.4 virtual host completes.

Debian apache2.4 Virtual Host use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.