I give an example from the “from and to” series how to launch a working version of rubyonrails on a win-local server, since I myself spent enough time searching for such solutions, I think someone should come in handy.
After reading the beginning of the cycle, a flock of "
pans on glass " still wanted to join this language.
Prelude
There are several "official", ready-made solutions:
Instant Rails - “somewhat outdated” build + not the best interface.
RubyStack is not a very bad and professional solution, and this company makes similar “kits” for a lot of languages, as well as CMS, but unfortunately the current build uses the version of mysql which causes errors some discomfort when working (for example: when working with scaffold).
')
Instead of ready-made solutions, the choice fell on an independent assembly of components.
Cocktail
Ingredients
Recipe
(it is assumed that we are building a local server for the developer machine and not a working configuration)
Centralized installation in a single directory of three components,
for example d: / local /
Respectively:- d: / local / apache
- d: / local / mysql
- d: / local / ruby
Install in order and do not forget opens the ports for the firewall (80, 3306 by default).
We mix
Apache Open apache / conf / httpd.conf
uncomfortable (remove # at the beginning of the line) LoadModule rewrite_module modules / mod_rewrite.so
do the same for LoadModule env_module modules / mod_env.so
go to the very end of the file and append the following lines (description below):
<VirtualHost rails>
SetEnv RAILS_ENV development
ServerName rails
DocumentRoot "d:/local/apache/htdocs/prj_name/public"
<Directory "d:/local/apache/htdocs/prj_name/public/">
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
VirtualHost rails (as actually below) - here rails is the name of the virtual host to which you will access in the address bar of the browser, for example:
railsSetEnv RAILS_ENV - choose the current development environment (you can choose development / test / production to enter, the details of the “environment” can be found in the documentation)
prj_name - the name of your rails application that you will create later
Save the file and restart apache.
MysqlAt the last stage of the installation, you will be asked to pre-configure the mysql server, I recommend choosing the “server machine” model
- server machine
- multifunctional database
- ...
- online transaction processing
- ...
- best support for multilingualism (all the same, utf is now our everything)
- do not forget to tick the include bin directory in windows PATH
- we register the password for root of the user
As a client for mysql, DreamCoder for MySQL was chosen (just like that, and even there is a free version), but you can do with the console
At this stage, you should have three apache, mysql and ruby applications installed and running.
Go to the console (start> run> cmd)
Enter the commands to connect:
gem install rails - include-dependencieswaiting ... and we hope for no mistakes;)
ruby mysqlwait and do not pay attention to the error with doc
The installation should have gone without complications and we proceed to the final stage.
Pouring
in the console:
rails -d mysql d: / local / apache / htdocs / prj_nameThis is in our case, and you have to enter the full path to the directory of your project (the directory should be placed in the server root, as shown above), this command indicates to the project creation coma that we will use the mysql database, as sqlite is used by default.
After the completion of this command, go to the directory of our project and find the config / database.yml where in the string "Password" we enter our password for the user specified there (root by default, but you can change it if you wish).
Next, go to the directory of our project and find there / public / in which we create the .htaccess file in which we write:
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
Everything.
Open the browser and in our case go
railsEnjoy!
UPDI completely forgot to remind you that in order for alias to work on the server you need to create an entry in the file C: \ Windows \ System32 \ drivers \ etc \ hosts
127.0.0.1 rails
or similar based on your settings and wishes ...)