Skip to content

Instantly share code, notes, and snippets.

@esparta
Last active February 13, 2023 14:37
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save esparta/9490477 to your computer and use it in GitHub Desktop.
Save esparta/9490477 to your computer and use it in GitHub Desktop.
Meneame en desarrollo

Aquí algunos pasos para una instalación mínima de meneame en desarrollo

Requisitos

Haré uso de una máquina virtual con VirtualBox, usando Vagrant, por lo que ambos son necesarios. Para clonar meneame necesitarás git.

Instrucciones

1.- Clonar el repositorio de meneame

git clone git@github.com:gallir/Meneame.git meneame

2.- Crear en el repositorio recién clonado, la máquina de Vagrant

cd meneame
vagrant init

3.- Copiar los archivos necesario para el inicio de tu máquina virtual

wget -O Vagrantfile https://gist.githubusercontent.com/esparta/9490477/raw/Vagrantfile
wget -O bootstrap.sh https://gist.githubusercontent.com/esparta/9490477/raw/bootstrap.sh

4.- Iniciar la máquina virtual.

vagrant up

Esto hará varias cosas:

  • Crear la máquina virtual en VirtualBox
  • Crear un directorio en la máquina virtual llamado /meneame , apuntando al directorio /branches/version5
  • Actualizar la máquina virtual (basada en Ubuntu 12.04) vía apt-get update
  • Instalar los paquetes mínimos para el funcionamiento de meneame (todo lo que hay en bootstrap.sh)
    • Instalar nginx
    • Instalar php-fpm, php5-curl, php5-mcrypt
    • Instalar mysql-server 5.5 con un password fijo
  • Hacer un "port forwarding" de la máquina virtual a la computadora cliente.

A partir de este momento ya puedes navegar a meneame desde tu máquina de desarrollo: http://localhost:8080

También puedes acceder al mysql de la máquina virtual desde tu máquina de desarrollo:

mysql -u meneame -pmeneame meneame -h 127.0.0.1 -P 33066 

Los cambios que realices en el directorio de desarrollo (/branches/version5/*) se verán reflejados inmediatamente en la máquina virtual.

## Use the closest mirror
#sudo sed -i "s/http:\/\/us.archive.ubuntu.com\/ubuntu\//mirror:\/\/mirrors.ubuntu.com\/mirrors.txt/g" /etc/apt/sources.list
#Proxy aware
# just set the http_proxy environment variable on your dev machine
if [ ! -z $1 ]; then
## We have a proxy...
BASH_FILE=/home/vagrant/.bashrc
proxy=$1
# First, the bash environment variable
echo "Configuring proxy: $proxy"
export http_proxy=$proxy
export https_proxy=$proxy
## Make it permanent (on vagrant's profile)
echo "export http_proxy=$proxy" >> $BASH_FILE
echo "export https_proxy=$proxy" >> $BASH_FILE
## Config the apt file for the apt-get update
echo "Acquire::http::proxy \"$proxy\";" >> /etc/apt/apt.conf
echo "Acquire::https::proxy \"$proxy\";" >> /etc/apt/apt.conf
fi
## Update the ubuntu/debian box
sudo apt-get update
sudo apt-get install nginx php5-mcrypt php5-fpm php5-curl \
php5-mysql -y
sudo debconf-set-selections <<< \
'mysql-server-5.5 mysql-server/root_password password rootpass'
sudo debconf-set-selections <<< \
'mysql-server-5.5 mysql-server/root_password_again password rootpass'
sudo apt-get install mysql-server-5.5 python-mysqldb -y
## Configuring mysql to be able to access this mysql server from the developer box
sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
sudo service mysql restart
echo "Deploying..."
echo "Getting minimal nginx configuration file\n"
wget -O /etc/nginx/sites-available/default \
https://gist.githubusercontent.com/esparta/9490477/raw/default
## Fixing some anoying Bug nginx + VirtualBox
## http://wiki.nginx.org/Pitfalls
## http://jeremyfelt.com/code/2013/01/08/clear-nginx-cache-in-vagrant/
sed -i 's/sendfile on;/sendfile off;/g' /etc/nginx/nginx.conf
sudo service php5-fpm restart
sudo service nginx restart
echo "Configuring mySQL database\n"
echo "Creating Meneame database\n"
mysql -u root -p"rootpass" <<-CREATE_DATABASE
CREATE DATABASE meneame;
GRANT ALL ON meneame.* TO meneame@localhost IDENTIFIED BY 'meneame';
GRANT ALL ON meneame.* TO meneame@'%' IDENTIFIED BY 'meneame'
CREATE_DATABASE
echo "Creating tables\n"
mysql -u meneame -p"meneame" meneame < /meneame/sql/meneame.sql
mysql -u meneame -p"meneame" meneame < /meneame/sql/categories.sql
echo "Creating initial data"
mysql -u meneame -p"meneame" meneame <<-INITIAL_DATA
INSERT INTO subs (name, enabled, parent, server_name, base_url, name_long, visible)
VALUES ('mnm', 1, 0, '', 'localhost:8080', 'Meneame', 1);
INSERT INTO sub_categories
SELECT LAST_INSERT_ID(), category_id, 1, 1, 1, category_calculated_coef FROM categories;
INITIAL_DATA
echo "Configuring Meneame settings\n"
sed -i "s/\$globals\['db_password'] = ''/\$globals\['db_password'] = 'meneame'/g" \
/meneame/www/config.php
sed -i "s/\$globals\['static_server'] = ''/\$globals\['static_server'] = 'http:\/\/localhost:8080'/g" \
/meneame/www/config.php
echo "Meneame - Bootstraping finished"
CREATE DATABASE meneame;
GRANT ALL ON meneame.* TO meneame@localhost IDENTIFIED BY 'meneame';
GRANT ALL ON meneame.* TO meneame@'%' IDENTIFIED BY 'meneame'
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /meneame/www;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
rewrite /v_\d+/(.+)$ /$1 last;
try_files $uri $uri/ /index.html;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
deny all;
}
# Only for nginx-naxsi : process denied requests
#location /RequestDenied {
# For example, return an error code
#return 418;
#}
error_page 404 = /ooops.php;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/www;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_intercept_errors on;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
INSERT INTO subs (name, enabled, parent, server_name, base_url, name_long, visible)
VALUES ('mnm', 1, 0, '', 'localhost:8080', 'Meneame', 1);
INSERT INTO sub_categories
SELECT LAST_INSERT_ID(), category_id, 1, 1, 1, category_calculated_coef FROM categories;
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise32"
config.vm.provision "shell" do |s|
s.path = "bootstrap.sh"
s.args = ENV['http_proxy']
end
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :forwarded_port, guest: 3306, host: 33066
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder ".", "/meneame"
end
@piotrrojek
Copy link

Thanks for this!
I have some issues though.

When I open up the site on development machine on port :8080 there's no css, images etc.
I discovered it's because of /v_5/ (version control in config.php).
I tried to disable it and I failed...

the frontpage is working if I copy all data from www to www/v_5, but other links aren't working. Could you help me disable this version control? I tried modifying it in nginx also...
I don't know where to search.

Gracias por ayuda :-) si quieres puedes escribir en español, lo entiendo bien, pero no me va escribiendo sobre las cosas técnicas.

@cristiannsc
Copy link

Thanks for this!
I have some issues though.

When I open up the site on development machine on port :8080 there's no css, images etc.
I discovered it's because of /v_5/ (version control in config.php).
I tried to disable it and I failed...

the frontpage is working if I copy all data from www to www/v_5, but other links aren't working. Could you help me disable this version control? I tried modifying it in nginx also...
I don't know where to search.

Gracias por ayuda :-) si quieres puedes escribir en español, lo entiendo bien, pero no me va escribiendo sobre las cosas técnicas.

¿Pudiste resolver el problema? tengo el mismo problema y no he podido arreglarlo @piotrrojek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment