📜 ⬆️ ⬇️

Install and configure LAMP and Trac + SVN on Ubuntu

After reading this article , I realized that Trac + SVN will be very helpful in my work and decided to set up this bundle on my machine.

Recently, I have been using Ubuntu Linux , because the installation and configuration took place taking into account the features of this system. I had LAMP installed earlier, just like inadyn . As a result, I received a fairly flexible and convenient system for managing my projects, which is accessible via the network. I wonder how to do? (at the end waiting for a bonus;)

Beginners advise to go the Seven Steps from mdevils
')

Install Apache + PHP + MySQL


Open the console and write:

sudo aptitude update
sudo aptitude install apache2 php5 php5-mysql mysql-server

Now you have the Apache web server, PHP and MySQL installed, as well as the database module. If you need additional modules for PHP, then installing them is quite easy, for example:

sudo aptitude install php5-gd php5-imagick php5-xsl - installs the GD, Imagick, XSL libraries.

mysqladmin -u root password ___root - sets the password for the administrator account for accessing the database.

Customization


To manage Apache modules and virtual hosts, there are commands: a2enmod (turns on the module), a2ensite (turns on the host), a2dismod and a2dissite (turns off the module and the host).

sudo a2enmod php5 - sudo a2enmod php5 php module

sudo /etc/init.d/apache2 force-reload - restart apache

Alt + F2 gksu gedit /var/www/phpinfo.php

there we write the familiar <?php phpinfo() ?> , save and close.
Open the browser:
http: // localhost - for testing Apache
http: //localhost/phpinfo.php - for checking PHP

Our favorite mod_rewrite


sudo a2enmod rewrite - activate the module itself

Alt + F2 gksu gedit /etc/apache2/sites-available/default
Change AllowOverride None to AllowOverride All , like this:
  <Directory />
         Options FollowSymLinks
         AllowOverride All
 </ Directory> 

sudo /etc/init.d/apache2 force-reload - yes, the server needs to be restarted after making changes in the settings :)

Do you need SSL? You are welcome


sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/apache.pem - create a certificate

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ssl - we copy settings for a future host

Alt + F2 gksu gedit /etc/apache2/sites-available/default
change the first two lines to:
NameVirtualHost *:80
<VirtualHost *:80>


Now access to it will occur only on the 80th port.

Alt + F2 gksu gedit /etc/apache2/sites-available/ssl
  NameVirtualHost *: 443
 <VirtualHost *: 443>
         ...
         DocumentRoot ...
         SSLEngine on
         SSLCertificateFile /etc/apache2/apache.pem 

And here on 443, port SSL

a2enmod ssl - a2enmod ssl SSL module
a2ensite ssl - we include a host

sudo /etc/init.d/apache2 force-reload - it's time to remember, restart apache.

https: // localhost - we check (most likely it will say that the certificate is incorrect)

And in order for Apache not to swear when rebooting:
Alt + F2 gksu gedit /etc/apache2/httpd.conf

ServerName localhost

So, we now have a ready web server with PHP and MySQL.

What about Trac and SVN?


There are several approaches to the organization of repositories; you can use a new repository for each project, or you can use one repository for several projects. The first method is better suited for large companies and for the work of an average group of developers on a project, so as not to be confused in a large data stream; the second is simpler and better suited for freelancers and small studios, I stopped at it.

Subversion


sudo apt-get install trac libapache2-svn subversion python-subversion libapache2-mod-python - install the necessary components

sudo a2enmod mod_python - sudo a2enmod mod_python module to work with Python

sudo groupadd svn - create a group to work with SVN
sudo usermod -a -G svn __ - add your user to the created group
sudo usermod -a -G svn www-data - add the Apache user to the group

sudo mkdir /var/svn - folder for future repository
sudo svnadmin create /var/svn - create the repository itself
sudo chown -R www-data:svn /var/svn - change permissions for a folder to be accessed by users from the SVN group
sudo chmod -R g+ws /var/svn
sudo htpasswd -c -m /etc/apache2/svn.htpasswd __ - create a password that will later be used in Apache to access the folder
Now create a rule for Apache:

Alt + F2 gksu gedit /etc/apache2/conf.d/svn
  <Location "/ svn">
         DAV svn
         Svnpath / var / svn
         AuthType Basic
         AuthName "SVN Repositories"
         AuthUserFile /etc/apache2/svn.htpasswd
         Require valid-user
 </ Location> 

Trac


Repeat almost identical operations, only for Trac

sudo mkdir /var/trac
sudo trac-admin /var/trac initenv
sudo chown -R www-data:svn /var/trac
sudo chmod -R g+ws /var/trac
sudo htpasswd -c -m /etc/apache2/trac.htpasswd __

Alt + F2 gksu gedit /etc/apache2/conf.d/trac
  <LocationMatch "/ trac / login">
         AuthType Basic
         AuthName "Projects"
         AuthUserFile /etc/apache2/trac.htpasswd
         Require valid-user
 </ LocationMatch>
 <Location / trac>
         SetHandler mod_python
         PythonInterpreter main_interpreter
         PythonHandler trac.web.modpython_frontend
         PythonOption TracEnv / var / trac
         PythonOption TracUriRoot / trac                                           
 </ Location> 


That's all. I think I did not forget anything :)
Total:
http: // localhost - normal access
https: // localhost - secure access
http: // localhost / svn - SVN, requires authorization
http: // localhost / trac - Trac himself
http: // localhost / trac / login - login to Trac, requires authorization

Promised Bonus


Many of us have broadband internet, you can use your ip address to access your uploaded server. But I, for one, don't like that. For such purposes there is a fairly convenient service DynDNS . After registration, you can create your domain and link it to your address. My address changes dynamically, I don't want to edit it every time on the site. There is a small inadyn client for this.

sudo aptitude install inadyn - install

Alt + F2 gksu gedit /etc/inadyn.conf - create a configuration file
  --username your_dynDNS_name
 --password your_varol
 --update_period 60000
 --alias name.your.host
 --background

sudo /usr/sbin/inadyn - run the client

Now you need to add it to the crontab to start automatically.
export EDITOR=gedit
sudo crontab -e


add row
@reboot /usr/sbin/inadyn
save and exit

sudo crontab -l - check if
ps -A | grep inadyn ps -A | grep inadyn - we look, it is started or not

Thanks for attention


In one of the following articles I will talk about setting up Eclipse for working with PHP and Subverion.

PS thanks to people from this topic for raising karma to the level of writing posts;)

Source: https://habr.com/ru/post/20525/


All Articles