How to set up an Apache server (complete guide)

Help with VPS, service, network, Linux, Nginx and WordPress problems and system administration.
rychy
Site Admin
Мнения: 132
Регистриран на: Вто Окт 20, 2026 10:45 am

How to set up an Apache server (complete guide)

Мнение от rychy »

🇧🇬 Прочети на български

1. Installing Apache

sudo apt update

sudo apt install apache2 -y

2. Start and enable

sudo systemctl start apache2

sudo systemctl enable apache2

3. Check the status

sudo systemctl status apache2

4. Open the firewall (if there is one)

sudo ufw allow 'Apache Full'

5. Default folder

/var/www/html

6. Create a new site

sudo mkdir -p /var/www/mysite

sudo chown -R $USER:$USER /var/www/mysite

7. Create an index file

nano /var/www/mysite/index.html

Virtual Host (IMPORTANT)

sudo nano /etc/apache2/sites-available/mysite.conf

<VirtualHost *:80>

ServerName mysite.com

ServerAlias www.mysite.com

Код: Избери целия код

DocumentRoot /var/www/mysite

<Directory /var/www/mysite>
    AllowOverride All
    Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

🔗 Enabling it

sudo a2ensite mysite.conf

sudo a2enmod rewrite

sudo systemctl restart apache2

✅ This gives you:

a working Apache

your own site

a ready base for WordPress / Laravel / whatever you want