Advertisement
ale12

virtual host

May 6th, 2016
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. ####################
  2. Bash
  3. ####################
  4. #!/bin/bash
  5. echo -n "masukin nama webnya : "
  6. read vhost
  7. export host=$vhost
  8. sudo mkdir /var/www/html/$host
  9. sudo chown -R www-data.www-data /var/www/html/$host
  10. sudo chmod -R 0755 /var/www/html/$host
  11. cat >>$host.conf<<eof
  12. <VirtualHost *:80>
  13. ServerAdmin admin@$host
  14. ServerName $host
  15. ServerAlias www.$host
  16. DocumentRoot /var/www/html/$host/
  17. ErrorLog ${APACHE_LOG_DIR}/error.log
  18. CustomLog ${APACHE_LOG_DIR}/access.log combined
  19. </VirtualHost>
  20. eof
  21. sudo cp $host.conf /etc/apache2/sites-available/$host.conf
  22. sudo nano /etc/hosts
  23. sudo a2ensite $host
  24. sudo service apache2 reload
  25.  
  26.  
  27.  
  28. ############################################
  29. Make a virtualhost using cpp
  30. @41enurhi74z
  31. contact : https://facebook.com/ale.gautama
  32. compile this source:
  33. c++ virtual_host.cpp -o vhost
  34.  
  35. <VirtualHost *:80>
  36. ServerAdmin admin@41enurhi74z.id
  37. ServerName 41enurhi74z.id
  38. ServerAlias www.41enurhi74z.id
  39. DocumentRoot /var/www/41enurhi74z.id/
  40. ErrorLog ${APACHE_LOG_DIR}/error.log
  41. CustomLog ${APACHE_LOG_DIR}/access.log combined
  42. </VirtualHost>
  43. #############################################################
  44.  
  45. #include<iostream>
  46. #include<string>
  47. #include<stdlib.h>
  48. using namespace std;
  49. int main(){
  50. string nama_web_dir;
  51. cout<<"Masukan nama direktory web: \n";
  52. cin>>nama_web_dir;
  53. string mkdir_web = "sudo mkdir /var/www/"+nama_web_dir;
  54. system(mkdir_web.c_str());
  55. string _chown = "sudo chown -R www-data.www-data /var/www/"+nama_web_dir;
  56. system(_chown.c_str());
  57. string prmsion;
  58. cout<<"value for permision folder web:\n";
  59. cin>>prmsion;
  60. string _chmod ="sudo chmod -R "+prmsion+" /var/www/"+nama_web_dir;
  61. system(_chmod.c_str());
  62. string _conf = "sudo cp _.conf /etc/apache2/sites-available/"+nama_web_dir+".conf";
  63. system(_conf.c_str());
  64. string edit_conf = "sudo nano /etc/apache2/sites-available/"+nama_web_dir+".conf";
  65. system(edit_conf.c_str());
  66. string _actif = "sudo a2ensite "+nama_web_dir;
  67. system(_actif.c_str());
  68. string _index = "sudo cp index.php /var/www/"+nama_web_dir+"/index.php";
  69. system(_index.c_str());
  70. system("sudo nano /etc/hosts");
  71. system("sudo service apache2 reload");
  72. cout<<"success make a virtual host \ncoded : 41enurhi74z";
  73. return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement