Run PHP application in Apache server using PHP-FPM - php

We have a php application which was running fine using
Docker Image :
php:7.2-apache-stretch
We now have to make use of the below image for better performance and make the application work as it was before .
php:7.2.17-fpm-stretch
As this image does not have apache in it . I updated the Dockerfile starting from the installation of apache2 and related packages based on various forums .
There is many other steps . I have just added the instructions which I have updated in the Dockerfile.
FROM php:7.2.17-fpm-stretch
RUN apt-get update && apt-get install -y apache2 wget
RUN cd /tmp && wget http://mirrors.kernel.org/ubuntu/pool/multiverse/liba/libapache-mod-fastcgi/libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb && dpkg -i libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb;apt-get install -f
RUN a2enmod actions proxy_fcgi fastcgi
COPY 000-default.conf /etc/apache2/sites-available/000-default.conf
COPY info.php /var/www/html/info.php
COPY run.sh /app/run.sh
# EXPOSE 9000
RUN chmod 755 /app/run.sh
CMD "/app/run.sh"
The info.php contains <?php phpinfo( ); ?> . In the run.sh script , we start the php-fpm service and apache2 as below
php-fpm -D
/usr/sbin/apachectl -D FOREGROUND
previously I was trying to access the app from the port which was mapped to 9000 ( fpm ) . When I accessed the correct port where apache was running , I was able to view info.php .
The Content in the vhost.conf file.
<FilesMatch \.php$>
SetHandler "proxy:fcgi://localhost:9000"
</FilesMatch>

I got it working making a few modifications.
I used this slightly modified dockerfile:
FROM php:7.2.17-fpm-stretch
RUN apt-get update; apt-get install -y apache2 wget
RUN cd /tmp && wget http://mirrors.kernel.org/ubuntu/pool/multiverse/liba/libapache-mod-fastcgi/libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb && dpkg -i libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb;apt-get install -f
RUN a2enmod actions proxy_fcgi fastcgi
COPY run.sh /app/run.sh
RUN chmod 755 /app/run.sh
CMD "/app/run.sh"
I also added the following snippet (the same modification you did) to /etc/apache2/sites-available/000-default.conf:
<FilesMatch \.php$>
SetHandler "proxy:fcgi://localhost:9000"
</FilesMatch>
Here is the output I get:
[09-Apr-2019 21:23:06] NOTICE: fpm is running, pid 9
[09-Apr-2019 21:23:06] NOTICE: ready to handle connections
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
Also, did you try building the dockerfile without the cache? Sometimes, caching can cause issues with package installation (see here for more details). To do a clean build of an image, just use:
docker build --no-cache

I got your new configuration working using this dockerfile:
FROM php:7.2.17-fpm-stretch
RUN apt-get update && apt-get install -y apache2 wget
RUN cd /tmp && wget http://mirrors.kernel.org/ubuntu/pool/multiverse/liba/libapache-mod-fastcgi/libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb && dpkg -i libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb;apt-get install -f
RUN a2enmod actions proxy_fcgi fastcgi
COPY 000-default.conf /etc/apache2/sites-available/000-default.conf
COPY info.php /var/www/html/info.php
COPY run.sh /app/run.sh
RUN chmod 755 /app/run.sh
EXPOSE 80
CMD "/app/run.sh"
The command I ran was:
docker run -P -d --rm <php-image>
The exposed ports are:
0.0.0.0:32773->80/tcp, 0.0.0.0:32772->9000/tcp
I was able to access info.php using http://localhost:32773/info.php

I was able to access the php page . Everything was working fine . But I was looking in the wrong direction . When I run the container .
docker run -P -d --rm php:test-fpm
The output was
82071c9ff023 php:test-fpm "docker-php-entrypoi…" 2 seconds ago Up 1 second 0.0.0.0:32778->80/tcp, 0.0.0.0:32777->9000/tcp practical_mclean
I was accessing localhost:32777/info.php . But I should I accessed the 32778 where apache is exposed and localhost: 32778/info.php worked !!! .
Is there a way to avoid the port mapping of 9000. ???

Related

PHP-FPM is not being restarted properly from a Dockerfile

I am having this weird problem with PHP-FPM. First of all, I am not an expert on PHP. I'm builing an app, and PHP will only communicate with MySQL to push and pull data.
The problem:
I have a Dockerfile where I'm making some changed in PHP-FPM config, and one of the lines is to reload PHP-FPM. Actually when you install PHP-FPM, it is not running, so I do:
RUN service php7.3-fpm start
When the app starts and I check PHP-FPM, it is not running. I had this issue before (with php7-0-fpm), I had resolved it by doing:
service php7.0-fpm stop && service php7.0-fpm start
But now, when I do it, it is still stopped.
So, I started reading and someone advised to put it in the CMD command, along with the main command. I did, and it worked:
CMD service php7.3-fpm start && nginx -g "daemon off;"
Now, the problem is that it is not taking the new configuration. When I access the machine, and I manually do service php7.3-fpm reload it starts working.
I tried putting it in the Dockrfile as well, but no luck. Any idea? I would like to resolve the first issue as well (I don't want to restart PHP-FPM from the CMD. It would be preferable to do it with a RUN layer in docker).
EDIT
Another weird thing is that when I do service php7.3-fpm start manually, it doesn't work, but it works when I do /etc/init.d/php7.3-fpm start. Seems to work, when I do it in the CMD line:
CMD /etc/init.d/php7.3-fpm start && nginx -g "daemon off;"
Dockerfile
FROM debian:buster
LABEL maintainer="me"
RUN apt-get update && apt-get install -y \
nginx \
default-mysql-client \
php7.3-fpm \
php7.3-mysql
RUN sed -i.bak "s/;clear_env = no/clear_env = no/g" /etc/php/7.3/fpm/pool.d/www.conf && \
sed -i.bak "s/;php_flag\[\display_errors\]\ = off/php_flag\[\display_errors\]\ = on/g" /etc/php/7.3/fpm/pool.d/www.conf
COPY ./html/ /var/www/html/
RUN rm /var/www/html/index.nginx-debian.html
WORKDIR /var/www/html/
EXPOSE 80
CMD service php7.3-fpm start && nginx -g "daemon off;"
Execute a command or restart php-fpm using RUN directive will not effect because each layer runs in a separate shell.
The best way is to copy the config file from host, rebuild the image and then run the container.
for Example
FROM debian:buster
COPY config/php7.ini /usr/local/etc/php/conf.d/
COPY config/fpm/php-fpm.conf /usr/local/etc/
COPY config/fpm/pool.d /usr/local/etc/pool.d
Also better to run the separate container for each process, rule of thumb single process per container.
You CMD seem fine it starts PHP and Nginx both.
To verify process inside your container add
RUN apt-get update && apt-get install procps -y
then run
docker exec -it your_container_id bash -c "ps -aux"

How to write the right instructions on dockerfile in order to increase PHP resources?

My WordPress theme is complaining about max_execution_time (30), max_input_vars (1000) and WP Memory Limit (40). I really need to increase PHP resources and memory on the docker container that my website lives in.
I tried manually altering php.ini and .htaccess files, with no success. As I could understand, these settings need to be done on the dockerfile, as instructions.
Here is my dockerfile:
# ========== STAGE FOR BUILDING THE JS/CSS ASSETS
FROM node:9.11.1-slim AS builder
WORKDIR /var/www/
# Install the required packages for building the assets
COPY src/package*.json src/gulpfile.js ./
RUN npm install
# Build the assets
COPY src/wp-content/themes/tsc ./wp-content/themes/tsc
RUN npm run build-prod
# ========== PRODUCTION IMAGE
FROM wordpress:5.0.3-php7.2-fpm
# ---------- Configure PHP
# RUN docker-php-ext-install sockets
# RUN sed -i "s|;pid =.*|pid = /var/run/php-fpm.pid|" /usr/local/etc/php-fpm.conf
# RUN sed -i "s|listen =.*|listen = /var/run/php/php-fpm.sock|" /usr/local/etc/php-fpm.d/www.conf
# RUN sed -i "s|;listen.mode =.*|listen.mode = 0666|" /usr/local/etc/php-fpm.d/www.conf
COPY ./conf/php/* ./conf/php-fpm.conf /usr/local/etc/
COPY ./conf/php-fpm.d/* /usr/local/etc/php-fpm.d/
# ---------- Configure blog files and directories
WORKDIR /var/www/html/
COPY src ./tsc/
COPY --from=builder /var/www/wp-content/themes/tsc/build/ ./tsc/wp-content/themes/tsc/build/
COPY bin /usr/local/bin/
RUN chmod +x /usr/local/bin/start-server.sh
# ---------- Install and configure Nginx
RUN apt-get update && apt-get install -y wget gnupg
RUN wget -O- http://nginx.org/keys/nginx_signing.key > nginx.key && apt-key add nginx.key && rm nginx.key
RUN echo deb http://nginx.org/packages/debian/ stretch nginx > /etc/apt/sources.list.d/nginx.list && \
echo deb-src http://nginx.org/packages/debian/ stretch nginx >> /etc/apt/sources.list.d/nginx.list
RUN apt-get update
RUN apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages nginx
# Copy nginx and default site conf
COPY conf/nginx.conf /etc/nginx/nginx.conf
COPY conf/nginx-site.conf /etc/nginx/conf.d/default.conf
# ---------- Configure environment
COPY conf/setup-env-vars.sh /tmp/setup-env-vars.sh
RUN chmod +x /tmp/setup-env-vars.sh
# ---------- Run
EXPOSE 80
CMD ["start-server.sh"]
# ---------- Configure debug
RUN sed -i "s|;error_log =.*|error_log = /var/log/fpm-php.www.log|" /usr/local/etc/php-fpm.conf
RUN echo "\ncatch_workers_output = yes" >> /usr/local/etc/php-fpm.d/www.conf
RUN echo "\nphp_flag[display_errors] = on" >> /usr/local/etc/php-fpm.d/www.conf
# RUN echo "\nphp_admin_value[error_log] = /var/log/fpm-php.www.log" >> /usr/local/etc/php-fpm.d/www.conf
RUN echo "\nphp_admin_flag[log_errors] = on" >> /usr/local/etc/php-fpm.d/www.conf
# RUN touch /var/log/fpm-php.www.log && chmod 777 /var/log/fpm-php.www.log
# Forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log
So, I need help with some instructions to achieve the following values on my docker container:
max_input_vars = 5000
max_execution_time = 300
post_max_size = 50M
upload_max_filesize = 50M
So, you can explore the docker image in this way:
docker pull wordpress:5.0.3-php7.2-fpm
docker run -t -i wordpress:5.0.3-php7.2-fpm /bin/bash
Once you've done that, you can explore to locate how the docker image is laid out, and determine if you're updating the correct files.
The php.ini files for this image are located at /usr/local/etc in php-fpm.conf and ./php-fpm.d/www.conf. I would recommend putting your 4 variables into a file that gets copied into .../php-fpm.d/<mystuff>.conf.
The start-server.sh file that you use to launch PHP is not listed here, so I can't tell what command line arguments you're sending to PHP in this case. It's probably not a good idea to override the default launch**. By default this image will run the php-fpm engine. If you just want an all-in-one image, you might consider the wordpress:5.0.3-apache which is preconfigured to handle HTTP traffic.
** Note: in fact, you're copying in nginx into the docker image as well. That would be an antipattern for docker too. Each docker container should have exactly one service - this one would run php-fpm to execute the wordpress engine, and there should be another that runs your front-end (e.g. nginx or whatever) and connects by name to the php-fpm image to run the PHP. But I digress.

Docker LAMP stack - where is the location to keep PHP projects?

I have my LAMP stack installed already before Docker's. And I am using this image to build and run my Docker's LAMP stack:
$ docker pull linuxconfig/lamp
After all are downloaded and installed:
$ docker run -it linuxconfig/lamp /bin/bash
root#2e80dfd55a6e:/# service apache2 start
[....] Starting web server: apache2AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
So at my http://172.17.0.2/, I can see this default page:
But where can I locate its location so that I can put my PHP projects in there?
This the DockerFile from that image:
FROM linuxconfig/apache
MAINTAINER Lubos Rendek <web#linuxconfig.org>
ENV DEBIAN_FRONTEND noninteractive
# Main package installation
RUN apt-get update
RUN apt-get -y install supervisor libapache2-mod-php5 php5-mysql mysql-server
# Extra package installation
RUN apt-get -y install php5-gd php-apc php5-mcrypt
# Configure MySQL
RUN sed -i 's/bind-address/#bind-address/' /etc/mysql/my.cnf
# Include supervisor configuration
ADD supervisor-lamp.conf /etc/supervisor/conf.d/
ADD supervisord.conf /etc/supervisor/
# Include PHP Info page
ADD index.php /var/www/html/index.php
# Create new MySQL admin user
RUN service mysql start; mysql -u root -e "CREATE USER 'admin'#'%' IDENTIFIED BY 'pass';";mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'#'%' WITH GRANT OPTION;";
# Allow ports
EXPOSE 80 3306
# Start supervisor
CMD ["supervisord"]
EDIT:
$ sudo docker run --name=lamp -dP -v $PWD/html:/var/www/html linuxconfig/lamp
c2d1687aef21f8a12a7fbb31bf8cf71c1e5adabf381bc6d70e8804c6663f0bc0
And:
$ sudo docker port lamp
80/tcp -> 0.0.0.0:32769
3306/tcp -> 0.0.0.0:32768
I go to my browser at: http://172.17.0.2:32769/
I get this error:
See if this article can help: "LAMP ( Linux, Apache, MariaDB, PHP ) stack Docker image deployment"
Save index.php file and within a new html directory.
Alternatively, html directory may contain your desired PHP application:
$ mkdir html
$ vi html/index.php
$ ls html/
index.php
At this stage we are ready to deploy “linuxconfig/lamp” docker image:
sudo docker run --name=lamp -dP -v $PWD/html:/var/www/html linuxconfig/lamp
That means you are mounting your host directory html into the linuxconfig/lamp container folder /var/www/html. (see "Mount a host directory as a data volume")

Restart apache on Docker

I am trying to update my .htaccess file on a Docker container. After updating the file I need to restart Apache. Whenever I try to restart Apache: with the command service apache2 restart I get the following error:
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
...fail!
When I got to the error log it doesn't have any new errors.
This is what my Dockerfile looks like:
FROM ubuntu:12.04
# Install dependencies
RUN apt-get update -y
RUN apt-get install -y git curl apache2 php5 libapache2-mod-php5 php5-mcrypt php5-mysql php5-curl vim
# Install app
RUN rm -rf /var/www/ *
ADD src /var/www
# Configure apache
RUN a2enmod rewrite
RUN chown -R www-data:www-data /var/www
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
EXPOSE 80
CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]
Actually you don't need to restart Apache in order to apply changes defined in .htaccess - those are applied during runtime. If you're modifying apache config file (like virtual host definition or something in httpd.conf) you can also reload config without restarting apache using
sudo /etc/init.d/apache2 reload
It's because you are (correctly) not starting apache as a service when you docker run the container. The line:
CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]
Starts apache in the foreground.
I'm guessing you are then using docker exec to execute a shell in the container to edit the file and restart apache? If so this would explain why the second time you start apache it complains about the existing process.
I think if you are using containers in this way then you are really missing out on the benefit of containers which comes when you treat them as immutable and keep the data outside the container (either on your host or in volumes) so that you can easily replace the container.
In your case if you need to modify the .htaccess file I think it would be more normal to mount that file into the container by using a command like:
docker run -d --name apache -v $(pwd)/.htaccess:/path/to/.htaccess -p 80:80 image:tag
Then if you have to change the file and need to restart apache you can use:
docker restart apache
Although it may be worth investigating the suggestion from Charlotte Dunois that you might not even need to restart apache.

Changing case of controller name

I have an application on my own computer (Kubuntu 13.10).
When I use separate class to define routes everything works perfect. For instance, I have url backend/dictionaries which handled by module backend, DictionariesController and indexAction. View for this url was at views/dictionaries/index.phtml.
Then I've switch to Phalcon\Mvc\Router\Annotations() and mount module's routes like $router->addModuleResource('backend', 'MyApp\Backend\Controller\Dictionaries');
Starting from that point my view does not rendered until I rename views/dictionaries to views/Dictionaries, with capital D.
However, when I've transfered project to production server (Debian 7) to see my views I had to rename view-folder back to lowercase.
So, on my computer action view lays in Controllername/acitonname.php (Dictionaries/index.php, for example) but on production it should be controllername/actionname.php (dictionaries/index.php)
I've printed controller name from dispatcher - on my machine it starts with capital letter but on production it is lowercase.
The question is why it is happend and how it can be fixed without handling 'dispatch:beforeDispatchLoop'?
ADDED:
The problem with development and production was in different phalcon version. On dev I use 1.2.4, on production - 1.2.3
But there are still bug (or feature) with route vs annotation routing definition. If I use annotation the controller name is Capitalized whereas if I use something like $route->add('/:controller/:action') definition the controller name is lowercase.
You face a century old problem: works at localhost but not on server. The solution is simple as use server environment for development.
For example I have 3 computers, one is Mac, one Windows and one God knows what. One day Ubuntu, another kubuntu or any other fancy named OS. If your server is Debian 7, no matter what OS you use at your working machine, your code always must be handled by Debian 7 and PHP configuration should be as close as your real machine's. Then you will not have such bugs like different paths to file, different end of line symbols and some other crazy stuff.
I suggest you trying Vagrant form https://www.vagrantup.com/downloads.html
You steps are like this:
Download https://www.virtualbox.org and install
Download https://www.vagrantup.com/downloads.html and install
Configure vagrant to your needs. Debian 7 with some php extensions or whatever you have at your production server.
Just navigate with terminal, command line or windows power shell to the directory where your vagrant file is and type "vagrant up --provision"
edit your main OS hosts file (on most linux should be here: /etc/hosts) add line: xxx.xxx.xx.xxx domain.vm (xxx.xxx.xxx.xxx - your virtual box ip address from vagrant config file. domain.vm is your domain which will work for your local development. enter anything you wish, i just like to use .vm tld for virtual machine)
now vagrant will read your config file, download needed virtual box, install php, keep in sync your main OS's folder with virtual box folder. You will edit your files as usual, vagrant will make sure, that on virtual box you have same files.
you should be able to go to http://domain.vm/ and see your site running on virtual machine with debian 7 locally on your kubuntu, windows, mac... OS. And what is the best thing - you don't have to worry about difference between OSs you use locally and on server.
Also if you would add all these things to git versioning, you would be able to work with any computer with your project under ±15 minutes (depends on internet speed to download 1 time virtual machine OS).
Maybe I should make a video tutorial on all this thing.. But you should be able to find one on Youtube.
Just to make your life easier, here's my working Vagrant config. I use ubuntu + PhalconPHP framework + MongoDb and Mysql. There are 2 files. One for vagrant main things: download OS, mount sync folder etc, and one - for installation after starting vagrant. If you want to rerun installation script, just type vagrant provision
Vagrantfile file (name of the file is just "Vagrantfile")
# -*- 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|
# Base Box
# --------------------
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
# Connect to IP
# --------------------
config.vm.network :private_network, ip: "192.168.5.0"
# Forward to Port
# --------------------
#config.vm.network :forwarded_port, guest: 80, host: 8080
# Optional (Remove if desired)
config.vm.provider :virtualbox do |v|
# How much RAM to give the VM (in MB)
# -----------------------------------
v.customize ["modifyvm", :id, "--memory", "700"]
# Uncomment the Bottom two lines to enable muli-core in the VM
#v.customize ["modifyvm", :id, "--cpus", "2"]
#v.customize ["modifyvm", :id, "--ioapic", "on"]
end
# Provisioning Script
# --------------------
config.vm.provision "shell", path: "init.sh"
# Synced Folder
# --------------------
config.vm.synced_folder "./", "/var/www/", :mount_options => [ "dmode=775", "fmode=644" ], :owner => 'www-data', :group => 'www-data'
end
and the installation file (name of the file is "init.sh"):
#!/bin/bash
# Using Precise32 Ubuntu
# to use closest ubuntu mirror by geographic location
echo 'deb mirror://mirrors.ubuntu.com/mirrors.txt precise main restricted universe multiverse' | cat - /etc/apt/sources.list > temp && mv temp /etc/apt/sources.list
echo 'deb mirror://mirrors.ubuntu.com/mirrors.txt precise-updates main restricted universe multiverse' | cat - /etc/apt/sources.list > temp && mv temp /etc/apt/sources.list
echo 'deb mirror://mirrors.ubuntu.com/mirrors.txt precise-backports main restricted universe multiverse' | cat - /etc/apt/sources.list > temp && mv temp /etc/apt/sources.list
echo 'deb mirror://mirrors.ubuntu.com/mirrors.txt precise-security main restricted universe multiverse' | cat - /etc/apt/sources.list > temp && mv temp /etc/apt/sources.list
sudo apt-get update
sudo apt-get update
#
# For PHP 5.5
#
sudo apt-get install -y python-software-properties
sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
#
# MySQL with root:<no password>
#
export DEBIAN_FRONTEND=noninteractive
apt-get -q -y install mysql-server
#
# PHP
#
sudo apt-get install -y php5 php5-dev apache2 libapache2-mod-php5 php5-mysql php5-curl php5-mcrypt php5-gd php5-imagick
#
# Redis
#
sudo apt-get install -y redis-server
#
# MongoDB
#
sudo apt-get install mongodb-clients mongodb-server
#
# Utilities
#
sudo apt-get install -y curl htop git-core gcc autoconf
sudo apt-get install -y libpcre3-dev
#
# Redis Configuration
# Allow us to Remote from Vagrant with Port
#
sudo cp /etc/redis/redis.conf /etc/redis/redis.bkup.conf
sudo sed -i 's/bind 127.0.0.1/bind 0.0.0.0/' /etc/redis/redis.conf
sudo /etc/init.d/redis-server restart
#
# MySQL Configuration
# Allow us to Remote from Vagrant with Port
#
sudo cp /etc/mysql/my.cnf /etc/mysql/my.bkup.cnf
# Note: Since the MySQL bind-address has a tab character I comment out the end line
sudo sed -i 's/bind-address/bind-address = 0.0.0.0#/' /etc/mysql/my.cnf
#
# Grant All Priveleges to ROOT for remote access
#
mysql -u root -Bse "GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY '' WITH GRANT OPTION;"
sudo service mysql restart
#
# Composer for PHP
#
sudo curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
#
# Apache VHost
#
cd ~
echo '<VirtualHost *:80>
DocumentRoot /var/www/public
SetEnv APPLICATION_ENV "development"
</VirtualHost>
<Directory "/var/www/public">
Options Indexes Followsymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/www/logs/error.log
' > vagrant.conf
sudo mv vagrant.conf /etc/apache2/sites-available
sudo a2enmod rewrite
#
# Install PhalconPHP
# Enable it
#
cd ~
git clone --depth=1 git://github.com/phalcon/cphalcon.git
cd cphalcon/build
sudo ./install
echo "extension=phalcon.so" > phalcon.ini
sudo mv phalcon.ini /etc/php5/mods-available
sudo php5enmod phalcon
sudo php5enmod curl
#
# Install PhalconPHP DevTools
#
cd ~
echo '{"require": {"phalcon/devtools": "dev-master"}}' > composer.json
composer install
rm composer.json
sudo mkdir /opt/phalcon-tools
sudo mv ~/vendor/phalcon/devtools/* /opt/phalcon-tools
sudo ln -s /opt/phalcon-tools/phalcon.php /usr/bin/phalcon
sudo rm -rf ~vendor
#
# PHP.ini params edits
#
sudo echo "; ######### PHP.ini modifications from vagrant init.sh #######" >> /etc/php5/apache2/php.ini
sudo echo "error_reporting = E_ALL | E_STRICT" >> /etc/php5/apache2/php.ini
sudo echo "display_errors = On" >> /etc/php5/apache2/php.ini
#
# Reload apache
#
sudo a2ensite vagrant
sudo a2dissite 000-default
sudo service apache2 reload
sudo service apache2 restart
sudo service mongodb restart
#echo -e "----------------------------------------"
#echo -e "To create a Phalcon Project:\n"
#echo -e "----------------------------------------"
#echo -e "$ cd /var/www"
#echo -e "$ phalcon project projectname\n"
#echo -e
#echo -e "Then follow the README.md to copy/paste the VirtualHost!\n"
#echo -e "----------------------------------------"
#echo -e "Default Site: http://192.168.5.0"
#echo -e "----------------------------------------"
####### writable Volt directory
sudo mkdir /vagrant/cache/volt/
sudo chmod 777 /vagrant/cache/volt/
Of course if you need Debian 7, installation script should be adapted to your needs and edit Vagrantfile lines about ubuntu to your OS. Here is the list of all supported OS's: http://www.vagrantbox.es
Change these two lines in Vagrant file:
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
And also change install script, i don't use Debian, can't tell what can go wrong.

Categories