우분투에서 가상호스팅으로 워드프레스 설치하기

우분투에서 가상호스팅으로 워드프레스 설치하기

Directory Structure

.
`-- var/
    `-- www/
        `-- example.com/
            |-- public_html/
            |   `-- index.html
            `-- logs

Virtualhost

cp -r /var/www/wordpress /var/www/example.com

Permission for owner (single user)

chown -R www-data:www-data /var/www/example.com/
chmod -R 755 /var/www/example.com/

Permission for group

chown -R www-data:www-data /var/www/example.com/
usermod -a -G www-data ubuntu
chmod -R 775 /var/www/example.com/
cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
vim /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
        ServerName example.com
        ServerAlias www.example.com
        ServerAdmin webmaster@example.com
        DocumentRoot /var/www/example.com/public_html
        ...
        <Directory /var/www/example.com/public_html>
                Options FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>
        ...
        ErrorLog /var/www/example.com/logs/error.log
        CustomLog /var/www/example.com/logs/access.log combined
</VirtualHost>

apache2ctl configtest

Disable the new virtualhost.

a2dissite 000-default

Enable the new virtualhost.

a2ensite example.com.conf

Reload Apache

systemctl reload apache2

Currently only shows the virtualhost settings

a2query -s

Reference

Scroll to Top