Changes between Version 13 and Version 14 of faq/setup-development-workstation
- Timestamp:
- Jun 3, 2012, 6:26:40 PM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
faq/setup-development-workstation
v13 v14 10 10 == Installing and configuring critical helper packages == 11 11 12 Being able to send and receive email is often part of the web application development process. 12 Being able to send and receive email is often part of the web application development process. However, you don't want emails that are sent to be delivered to their actual recipients - but instead, delivered to you (this allows you to safely test web applications that send mail without the risk of accidentally sending a test email to thousands of people). 13 14 For starters, follow the [wiki:email_setup_postfix_debian instructions for configuring postfix to relay email for you]. 15 16 Once you have a working postfix installation, you may want to further configure it to relay ''all'' email to your email address: 13 17 14 18 {{{ 15 0 fidel:~# aptitude install mailx esmtp-run19 0 fidel:~# aptitude install postfix-pcre 16 20 }}} 17 21 18 You will then want to edit the /etc/esmtprc file, modifying the following lines:22 Then, create the file /etc/postfix/recipient_canonical: 19 23 20 24 {{{ 21 # Config file for ESMTP sendmail 22 23 # The SMTP host and service (port) 24 hostname=chavez.mayfirst.org:587 25 26 # The user name 27 username= 28 29 # The password 30 password= 31 32 #qualifydomain=@mayfirst.org 33 #force sender=your-username@mayfirst.org 34 #force reverse_path=your-username@mayfirst.org 35 36 # Whether to use Starttls 37 starttls=enabled 25 /.*/ you@example.org 38 26 }}} 39 27 40 FIXME: I can't properly send mail with this configuration, I get the following error: 28 Replace {{{you@example.org}}} with your actual email address. 29 30 Then edit the /etc/postf file, adding the following lines: 41 31 42 32 {{{ 43 Invalid peer certificate (error 20) 44 0 (null) 45 jamie@mayfirst.org: 0 (null) 46 Can't send mail: sendmail process failed with error code 70 33 recipient_canonical_classes = envelope_recipient 34 recipient_canonical_maps = pcre:/etc/postfix/recipient_canonical 47 35 }}} 48 36 49 This could be related to a known [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=310968 bug in esmtp]. 37 Lastly, restart postfix: 50 38 51 == Installing PHP, Apache, and MySQL == 39 {{{ 40 /etc/init.d/postfix reload 41 }}} 42 43 == Installing PHP, Apache, MySQL, and sudo == 52 44 53 45 Install the required packages with: 54 46 55 47 {{{ 56 aptitude install mysql-server php5-cgi php5-cli libapache2-mod-php5 apache2-mpm-prefork php5-mysql 48 aptitude install mysql-server php5-cgi php5-cli libapache2-mod-php5 apache2-mpm-prefork php5-mysql sudo 49 }}} 50 51 You should be prompted to create a password for the MySQL root user. You can generate a random password with the command: 52 53 {{{ 54 pwgen 55 }}} 56 57 If you receive an command not found error, install pwgen: 58 59 {{{ 60 apt-get install pwgen 61 }}} 62 63 Once you have your MySQL root user setup with a good password, record that password in /root/.my.cnf: 64 65 {{{ 66 [client] 67 user=root 68 password=password-you-created-above 69 }}} 70 71 Fix permissions on the file: 72 73 {{{ 74 chmod 600 /root/.my.cnf 75 }}} 76 77 Now, create a non-privileged user that you will use for doing your normal development work: 78 79 {{{ 80 adduser jamie 81 }}} 82 83 Add that users to the sudo group: 84 85 {{{ 86 adduser jamie sudo 57 87 }}} 58 88 59 89 == Configuring the environment == 60 90 61 The goal of the configuration is to make it as easy as possible to setup a new development environment for a new project.91 The rest of the steps should done as the non-privileged user. We will use sudo when you need root access. 62 92 63 93 Each new project will have a unique, non-public domain name based on the name of the workstation. Each project will have a corresponding directory in your home directory where you can place php and other files to be served by apache. … … 71 101 }}} 72 102 73 Apache can be configured so that it dynamically sets the document root based on the domain name.74 75 To enable that feature, create a new file called virtual-document-roots in the /etc/apache2/sites-available directory with the following contents (replace your-username with your actual username).76 77 {{{78 <Directory /home/your-username/projects>79 AllowOverride All80 </Directory>81 VirtualScriptAlias /home/your-username/projects/%1/cgi-bin/82 VirtualDocumentRoot /home/your-username/projects/%1/web/83 }}}84 85 Next enable the vhost_alias module and the site configuration file you just created with:86 87 {{{88 a2enmod vhost_alias89 a2enmod rewrite90 a2ensite virtual-document-roots91 }}}92 93 Reload Apache so these changes take effect:94 95 {{{96 /etc/init.d/apache2 reload97 }}}98 99 NOTE: If you are developing a Drupal project, you will need to edit your .htaccess file. There's a line that says the following:100 101 {{{102 # If your site is running in a VirtualDocumentRoot at http://example.com/,103 # uncomment the following line:104 RewriteBase /105 }}}106 107 You will want to uncomment the RewriteBase directive as shown above.108 109 103 == Steps to create a new project == 110 104 111 With your environment setup, you can easily start a new project by following these steps:112 113 105 * Choose a name for the project. In this example, we'll choose the name mfpl (and remember - in our example the computer name is fidel). 114 * C reate the mysql database with:106 * Choose a new random password: 115 107 {{{ 116 mysql -u root -p -e "CREATE DATABASE mfpl; GRANT ALL ON mfpl.* to 'mfpl'@'localhost' identified by 'mfpl';" 108 pwgen -s 15 1 117 109 }}} 118 * Add a new domain to your /etc/hosts file. Add it to the line that starts with 127.0.1.1 (you can safely create the line if it doesn't exist). For example: 110 * Create the mysql database. We're using sudo, which means we execute with root privileges. Since we have our root password stored in /root/.my.cnf, we don't have to specify a MySQL username and password. 111 {{{ 112 sudo mysql -e "CREATE DATABASE mfpl; GRANT ALL ON mfpl.* to 'mfpl'@'localhost' identified by 'your-random-password-goes-here';" 113 }}} 114 * Add a new domain to your /etc/hosts file. This step must be taken on the computer that runs your web browser. In other words, if you have Linux directly installed on your laptop/workstation, then add this file to your /etc/hosts file and use the IP address 127.0.1.2 (or any IP address that starts with 127). On the other hand, if your development environment is a virtual server on your workstation, then be sure to edit the /etc/hosts file on your host operating system, not on the virtual server. Also, instead of using 127.0.1.2, use the IP address assigned to your virtaul machine. For example: 119 115 {{{ 120 116 127.0.0.1 localhost 121 127.0.1.1 fidel.sunsetpark.mayfirst.org fidel mfpl.fidel 117 127.0.1.1 fidel.sunsetpark.mayfirst.org fidel 118 # linux environment installed directly on your workstation: 119 127.0.1.2 mfpl.fidel 120 # OR linux environment installed on a virtual machine: 121 192.168.1.2 mfpl.fidel 122 122 }}} 123 * Change into your pro ects directory:123 * Change into your projects directory: 124 124 {{{ 125 125 cd ~/projects 126 126 }}} 127 * C heckout your src files via svn127 * Create a project directory: 128 128 {{{ 129 svn co svn+ssh://svn.mayfirst.org/trunk/mfpl129 mkdir mfpl 130 130 }}} 131 * OR create your project folders with:131 * Create a web directory: 132 132 {{{ 133 mkdir ~/projects/mfpl 134 mkdir ~/projects/mfpl/web 135 mkdir ~/projects/mfpl/cgi-bin 133 mkdir mfpl/web 134 }}} 135 * Add an apache configuration by creating an apache sites file: 136 {{{ 137 sudo nano /etc/apache2/sites-available/mfpl.fidel 138 }}} 139 * With the contents (replace "jamie" with your actual username): 140 {{{ 141 <VirtualHost *:80> 142 ServerName mfpl.fidel 143 DocumentRoot /home/jamie/projects/mfpl/web 144 </VirtualHost> 145 }}} 146 * Enable the site: 147 {{{ 148 sudo a2ensite mfpl.fidel 149 }}} 150 * Reload apache: 151 {{{ 152 sudo /etc/init.d/apache2 reload 136 153 }}} 137 154 138 Now you are ready to begin. You can start placing files in your project's web directory and access your project at the URL: !http://mfpl.fidel/155 Done! Now you should be ready to download or create your web files in your web directory and access them via: http://mfpl.fidel/ 139 156 140 157 == Keeping files in sync == … … 147 164 #!/bin/bash 148 165 echo "Synchronizing database." 149 ssh <user>@<server> "mysqldump -u <remote-db-user> -p<remote-db-pass> <remote-db-name>" | mysql -u <local-db-user> -p<local-db-pass><local-db-name>166 ssh <user>@<server> "mysqldump -u <remote-db-user> -p<remote-db-pass> <remote-db-name>" | sudo mysql <local-db-name> 150 167 151 168 echo "Synchronizing files."