trinithunder / ltek_systems

0 stars 0 forks source link

Apache Configuration for Each User’s Rails App #2

Open trinithunder opened 1 week ago

trinithunder commented 1 week ago

For each user that creates an account, your app should: Create the directory structure for the app (/var/www/project_name). Generate the Apache virtual host configuration dynamically.

Example: File.open("/etc/apache2/sites-available/#{project_name}.conf", "w") do |f| f.write <<-CONFIG <VirtualHost *:80> ServerName #{user_domain} DocumentRoot /var/www/#{project_name}/public <Directory /var/www/#{project_name}/public> AllowOverride all Require all granted </Directory> </VirtualHost> CONFIG end

trinithunder commented 1 week ago

Enable the site:

sudo a2ensite #{project_name} sudo systemctl reload apache2