Apache virtual host configuration and pseudo-static operation

One,

The default path: cd / etc / httpd cd conf

vim httpd.conf

Code default on DocumentRoot

They can also define their own path to store, search on virtual vim, and in the following configuration

<VirtualHost *: 80>
  ServerName www.elian.test ---- domain
  DocumentRoot / data / www ---- directory
</ VirtualHost>

Configuration finished, restart httpd

two,

Clip establish the appropriate source file in the source directory files.

When Vim a file, save when inserted, tips and the like can not be saved without permission.

To use this command chown -R      

three,

Then visit the domain name, this time certainly can not be accessed because the domain name did not go on the record or registration.

At this point the Hosts file to go to the machine to modify the access point name can ping the IP -------- Linux and Mac hosts file in / etc folder below, Windows is in the Windows / System32 / drivers / etc below

After you configure the domain name is not registered can be visited.

But this time the visit is, httpd default access address.

four,

cd / etc / httpd httpd folder into the folder below a logs

logs folder that only the root user can access sudo su -p ---- quickly switch to the root user

Error Log Viewer logs folder cat, tail, head

Fives,

httpd.conf file like / etc / httpd / conf / under configuration

vim Directory Search label in the corresponding virtual disposed directory

According to configure the default virtual tag

<VirtualHost *:80>
  ServerName www.elian.test
  DocumentRoot /data/www
      <Directory "/data/www">
      Options Indexes FollowSymLinks
      AllowOverride None
      Require all granted
      </Directory>
</VirtualHost>

You can access the complete configuration

Sixth, the pseudo-static configuration

Httpd.conf enter again. Search elements LoadModule # LoadModule foo_module modules / mod_foo.so

The line above is modified like this LoadModule rewrite_module modules / mod_rewrite.so ---- rewrite_module as httpd / module files in the folder of files

Service httpd restart

Seven,

Continue to httpd.conf configuration file,

<VirtualHost *:80>
ServerName www.elian.test
DocumentRoot /data/www
  <Directory "/data/www">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteRule ^(.*)$ index.html
    </IfModule>
  </Directory>
</VirtualHost>

Guess you like

Origin www.cnblogs.com/elian91/p/11257348.html