cryptocurinfo

Deploying a web server noob's guide

Nov 28th, 2015
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 12.47 KB | None | 0 0
  1.                                This guide will show you how to deploy your very own webserver!! YAY
  2.  
  3.  
  4.  
  5.                                   ###########################################################################
  6.                                   #1st step How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu #
  7.                                   ###########################################################################
  8.  
  9.  
  10.  
  11. useradd -m -s /bin/bash -g sudo username
  12.  
  13. passwd username
  14. ##############################################################
  15. To install apache, open terminal and type in these commands: #
  16. ##############################################################
  17.  
  18. sudo apt-get update
  19. sudo apt-get install apache2
  20.  
  21. #############################################################
  22. To install MySQL, open terminal and type in these commands: #
  23. #############################################################
  24.  
  25. sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
  26.  
  27. #########################################################################
  28. Once you have installed MySQL, we should activate it with this command: #
  29. #########################################################################
  30.  
  31. sudo mysql_install_db
  32.  
  33. ###############################################
  34. Finish up by running the MySQL set up script: #
  35. ###############################################
  36.  
  37. sudo /usr/bin/mysql_secure_installation
  38.  
  39. The prompt will ask you for your current root password.
  40.  
  41. Type it in.
  42.  
  43. #########################################################
  44. To install PHP, open terminal and type in this command. #
  45. #########################################################
  46.  
  47. sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
  48.  
  49. After you answer yes to the prompt twice, PHP will install itself.
  50.  
  51. #################################################################################################
  52. It may also be useful to add php to the directory index, to serve the relevant php index files: #
  53. #################################################################################################
  54.  
  55. sudo nano /etc/apache2/mods-enabled/dir.conf
  56.  
  57. Add index.php to the beginning of index files. The page should now look like this:
  58.  
  59. <IfModule mod_dir.c>
  60.  
  61.          DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm
  62.  
  63. </IfModule>
  64.  
  65. ##############################################
  66. Once you decide to install the module, type: #
  67. ##############################################
  68.  
  69. sudo apt-get install php5-cgi php5-cli php5-common php5-curl php5-dbg php5-dev  php5-gd php5-gmp php5-ldap php5-mysql php5-odbc php5-pgsql php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-adodb
  70.  
  71. ########################################################
  72. Restart apache so that all of the changes take effect: #
  73. ########################################################
  74.  
  75. sudo service apache2 restart
  76.  
  77. #######################
  78. Done fuck bitches!!!! #
  79. #######################        
  80.  
  81.  
  82. Now for some way to modify the sql tables :)
  83.  
  84.  
  85.                                                      #################################
  86.                                                      #2nd step installing phpmyadmin #
  87.                                                      #################################
  88.  
  89. #############################
  90. Install service PhpMyAdmin: #
  91. #############################
  92.  
  93. sudo apt-get install phpmyadmin
  94.  
  95. This will ask you a few questions in order to configure your installation correctly.
  96.  
  97. For the server selection, choose apache2. Note: If you do not hit "SPACE" to select Apache, the installer will not move the necessary files during installation. Hit "SPACE", "TAB", and then "ENTER" to select Apache.
  98. Select yes when asked whether to use dbconfig-common to set up the database
  99. You will be prompted for your database administrator's password
  100. You will then be asked to choose and confirm a password for the phpMyAdmin application itself
  101. The installation process actually adds the phpMyAdmin Apache configuration file into the /etc/apache2/conf-enabled/ directory, where it is automatically read.
  102.  
  103. #########################################################################################################
  104. The only thing we need to do is explicitly enable the php5-mcrypt extension, which we can do by typing: #
  105. #########################################################################################################
  106.  
  107. sudo php5enmod mcrypt
  108.  
  109. ##############################################################################
  110. Afterwards, you'll need to restart Apache for your changes to be recognized: #
  111. ##############################################################################
  112.  
  113. sudo service apache2 restart
  114.  
  115. ##########################################################################################
  116. We will edit the linked file that has been placed in our Apache configuration directory: #
  117. ##########################################################################################
  118.  
  119. sudo nano /etc/apache2/conf-available/phpmyadmin.conf
  120.  
  121. #############################################################################################
  122. We need to add an AllowOverride All directive within the <Directory /usr/share/phpmyadmin>: #
  123. section of the configuration file, like this:                                               #
  124. #############################################################################################
  125.  
  126. <Directory /usr/share/phpmyadmin>
  127.     Options FollowSymLinks
  128.     DirectoryIndex index.php
  129.     AllowOverride All
  130.     . . .
  131.  
  132. When you have added this line, save and close the file.
  133.  
  134. ####################################################
  135. To implement the changes you made, restart Apache: #
  136. ####################################################
  137.  
  138. sudo service apache2 restart
  139.  
  140. ###########################
  141. Create an .htaccess File: #
  142. ###########################
  143. Now that we have enabled .htaccess use for our application, we need to create one to actually implement some security.
  144.  
  145. In order for this to be successful, the file must be created within the application directory. We can create the necessary file and open it in our text editor with root privileges by typing:
  146. ###########################################################
  147.  
  148. sudo nano /usr/share/phpmyadmin/.htaccess
  149.  
  150. ###############################################################
  151. Within this file, we need to enter the following information: #
  152. ###############################################################
  153.  
  154. AuthType Basic
  155. AuthName "Restricted Files"
  156. AuthUserFile /etc/phpmyadmin/.htpasswd
  157. Require valid-user
  158.  
  159. #################################################################################################################################
  160. Let's go over what each of these lines mean: #
  161. ##############################################
  162. AuthType Basic: This line specifies the authentication type that we are implementing. This type will implement password authentication using a password file.
  163. AuthName: This sets the message for the authentication dialog box. You should keep this generic so that unauthorized users won't gain any information about what is being protected.
  164. AuthUserFile: This sets the location of the password file that will be used for authentication. This should be outside of the directories that are being served. We will create this file shortly.
  165. Require valid-user: This specifies that only authenticated users should be given access to this resource. This is what actually stops unauthorized users from entering.
  166. ################################################################################################################################
  167.  
  168. ###############################################################################################################################
  169. Create the .htpasswd file for Authentication: #
  170. Now that we have specified a location for our password file through the use of the AuthUserFile directive within our .htaccess file, we need to create this file.
  171.  
  172. We actually need an additional package to complete this process. We can install it from our default repositories:
  173. ###############################################################################################################################
  174.  
  175. sudo apt-get install apache2-utils
  176.  
  177. Afterward, we will have the htpasswd utility available.
  178.  
  179. ###############################################################################################################################
  180. The location that we selected for the password file was "/etc/phpmyadmin/.htpasswd". Let's create this file and pass it an initial user by typing:
  181. ################################################################################################################################
  182.  
  183. sudo htpasswd -c /etc/phpmyadmin/.htpasswd phpuser
  184.  
  185. ################################################################################################################################
  186. You will be prompted to select and confirm a password for the user you are creating. Afterwards, the file is created with the hashed password that you entered.
  187.  
  188. If you want to enter an additional user, you need to do so without the -c flag, like this:
  189. #################################################################################################################################
  190.  
  191. sudo htpasswd /etc/phpmyadmin/.htpasswd additionaluser
  192.  
  193.  
  194. #######################
  195. Done fuck bitches!!!! #
  196. #######################
  197.  
  198.  
  199.  
  200.  
  201. Now we need to be able to upload files and be able to edit them on your new webserver
  202.  
  203.  
  204.  
  205.                                               #################################
  206.                                               #3rd step vsftpd install Ubuntu #
  207.                                               #################################
  208. ####################################################################################
  209. You can quickly install vsftpd on your virtual private server in the command line: #
  210. ####################################################################################
  211.  
  212. sudo apt-get install vsftpd
  213.  
  214. #################################
  215. Open up the configuration file: #
  216. #################################
  217.  
  218. sudo nano /etc/vsftpd.conf
  219.  
  220. #######################################################################################
  221. The biggest change you need to make is to switch the Anonymous_enable from YES to NO: #
  222. #######################################################################################
  223.  
  224. anonymous_enable=NO
  225.  
  226. Prior to this change, vsftpd allowed anonymous, unidentified users to access the server's files. This is useful if you are seeking to distribute information widely, but may be considered a serious security issue in most other cases.
  227.  
  228. After that, uncomment the local_enable option, changing it to yes and, additionally, allow the user to write to the directory.
  229.  
  230. local_enable=YES
  231. write_enable=YES
  232. Finish up by uncommenting command to chroot_local_user. When this line is set to Yes, all the local users will be jailed within their chroot and will be denied access to any other part of the server.
  233.  
  234. chroot_local_user=YES
  235. Save and Exit that file.
  236.  
  237. ##########################################################
  238. Create a new directory within the user's home directory: #
  239. ##########################################################
  240.  
  241. sudo mkdir /home/username/files
  242.  
  243. ############################################
  244. Change the ownership of that file to root: #
  245. ############################################
  246.  
  247. chown root:root /home/username
  248.  
  249. ######################################################################################
  250. Make all necessary changes within the "files" subdirectory Then, as always, restart: #
  251. ######################################################################################
  252.  
  253. sudo service vsftpd restart
  254.  
  255. #######################
  256. Done fuck bitches!!!! #
  257. #######################
  258.  
  259.  
  260. This next step will help you install Openssh so you can remote into your Webserver :)
  261.  
  262.  
  263.                                                   ##################################
  264.                                                   #4th step how to install openssh #
  265.                                                   ##################################
  266.  
  267. ####################
  268. #Always run updates#
  269. ####################
  270.  
  271. sudo apt-get update
  272.  
  273. #################
  274. #install openssh#
  275. #################
  276.  
  277. sudo apt-get install openssh-server.
  278.  
  279. #######################
  280. Done fuck bitches!!!! #
  281. #######################
Add Comment
Please, Sign In to add comment