Ubuntu 16.04 64bit Apache2 installation and configuration

Ubuntu install Apache2, apache is one of the most widely used web servers, configuration is relatively simple.

一,Install

sudo apt-get update

sudo apt-get install apache2

二,Configuration

1, Root directory configuration

sudo vi /etc/apache2/sites-available/000-default.conf

Open apache default configuration file, the default root directory is:

DocumentRoot /var/www/html

Change to your own Path, such as my path is /var/www/work

DocumentRoot /var/www/work

2, modify the apache2.conf file

sudo vi /etc/apache2/apache2.conf

find "<Directory /var/www>" and change it to "<Directory /var/www/work/ >"

3, restart

sudo /etc/init.d/apache2 restart

三, test

in the resource root directory /var/www/work (here is the directory defined above, my directory is /var/www/work Create a test document

If you don't have the directory, create

cd /var/www/

mkdir work

Create a test document

sudo vi test.txt

Enter http://local ip/test.txt in your browser to access the file, such as My ip is 192.168.2.200, and the corresponding link is http://192.168.2.200/test.txt

Ubuntu 16.04 64bit Apache2的安装及配置 - War - zhanxi1992

. Of course, one problem found here is Chinese garbled. The default file encoding format and apache configuration default encoding is UTF-8. It is recommended to set it to UTF-8. You can also modify the Chinese encoding format such as GBK according to your needs. Configuration file path: /etc/apache2/sites-available/000-default.conf, add

AddDefaultCharset UTF-8

Ubuntu 16.04 64bit Apache2的安装及配置 - War - zhanxi1992

in the configuration file to restart apache after refreshing, refresh the browser to see the normal display

Ubuntu 16.04 64bit Apache2的安装及配置 - War - zhanxi1992

Reference link: