Helo i have a problem with running behat test on circle ci. When i try to run them on my local everything works fine.
Here is a screen: https://www.dropbox.com/s/f27tfxdm1zxst8h/Screenshot%202016-11-17%2014.33.54.png?dl=0
and here is my circle.yml:
machine:
timezone:
Europe/Prague
php:
version: 7.0.7
dependencies:
pre:
- cp $HOME/$CIRCLE_PROJECT_REPONAME/app/config/parameters.yml.circle.dist $HOME/$CIRCLE_PROJECT_REPONAME/app/config/parameters.yml
database:
override:
- php app/console doctrine:migrations:migrate --no-interaction
test:
override:
- php bin/behat
Thanks for help
UPDATE
circle.yml
machine:
timezone:
Europe/Prague
php:
version: 7.0.7
dependencies:
pre:
- cp $HOME/$CIRCLE_PROJECT_REPONAME/app/config/parameters.yml.circle.dist $HOME/$CIRCLE_PROJECT_REPONAME/app/config/parameters.yml
post:
- sudo cp $HOME/$CIRCLE_PROJECT_REPONAME/app/config/mywebsite.conf /etc/apache2/sites-available
- sudo a2ensite mywebsite.conf
- sudo rm /etc/apache2/mods-enabled/php5.load
- sudo service apache2 restart
database:
override:
- php app/console doctrine:migrations:migrate --no-interaction -e=test
test:
override:
- php bin/behat
mywebsite.conf
Listen 8080
<VirtualHost *:8080>
LoadModule php7_module /opt/circleci/php/7.0.7/usr/lib/apache2/modules/libphp7.so
DocumentRoot /home/ubuntu/my_project/web
ServerName mywebsite.com
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
</VirtualHost>
And of course now i'm trying to connect to url mywebsite.com but response is still: cURL error 6: Could not resolve host: mywebsite.com (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) (GuzzleHttp\Exception\ConnectException)
I had the same problem as you and finally got it running. The mere Apache config sample in the Circle docs will never work. For me the following did work in the end:
<VirtualHost *:80>
DocumentRoot /home/circleci/drupal-circleci-behat/web
ServerName drupal-circleci-behat.localhost
<Directory /home/circleci/drupal-circleci-behat/web >
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Also I had added the domain to the host file via config.yml:
version: 2
jobs:
build:
docker:
- image: circleci/php:7.1-apache-node-browsers
working_directory: ~/drupal-circleci-behat
steps:
- checkout
- run:
name: Apache
command: |
sudo cp .circleci/drupal-circleci-behat.conf /etc/apache2/sites-available/drupal-circleci-behat.conf
sudo a2ensite drupal-circleci-behat
sudo service apache2 start
echo 127.0.0.1 drupal-circleci-behat.localhost | sudo tee -a /etc/hosts
cat /etc/hosts
curl drupal-circleci-behat.localhost
- run:
name: Other stuff ...
command: |
...
Working sample repo here: https://github.com/leymannx/drupal-circleci-behat
Related
I'm completely beginner with Docker and I'm trying to install wordpress (without database) from a base ubuntu 20.04 image with docker. I'm using apache server for this.
Here is my wordpress2_ms.dockerfile:
FROM ubuntu:20.04 as baseimage
SHELL ["/bin/bash", "-c"]
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y wget tar curl sudo systemctl
RUN apt install -y php libapache2-mod-php
RUN wget -c http://wordpress.org/latest.tar.gz
RUN tar xzvf latest.tar.gz -C /var/www/html
RUN sudo chown -R www-data.www-data /var/www/html/wordpress
FROM baseimage as wordpressapp
COPY wordpress.conf /etc/apache2/sites-available/
WORKDIR /etc/apache2/sites-available
RUN sudo a2ensite wordpress.conf
RUN sudo a2dissite 000-default.conf
RUN sudo systemctl reload apache2
EXPOSE 80
For this, we have to place a context folder beside this wordpress2_ms.dockerfile, and inside this context folder we need the following wordpress.conf file:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port t$
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/wordpress
ServerName localhost
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
The building command: sudo docker build -t wordpress:1.0 -f ./wordpress2_ms.dockerfile --target wordpressapp ./context/
The run command: sudo docker run -td --name wordpress_cont -p 8081:80 wordpress:1.0
After the run command I get the log that the wordpress has started at port 80 of the container, but nothing is happening at 8081 port of my host machine.
I would appreciate any help. Thanks in advance!
First I followed this tutorial:
https://www.tecmint.com/install-wordpress-alongside-lamp-on-debian-10/
Which worked fine until I got to the step where I needed to set the permissions. After that, when I try to cd wordpress I get Permission Denied, so I had to sudo su to continue following the directions.
Then in step 6 where you set the DocumentRoot, I followed that to the latter.
Now on step 7, where you actually test if you can access the WordPress initial installation screens, Apache2 is still displaying the Default apache2 static page.
I found this tutorial as well:
https://dade2.net/how-to-install-lamp-wordpress-ubuntu-and-debian/
While that second one is more recent, the only difference is that it uses slightly different Permissions and uses MariaDB. So I tried their Permissions and can now cd into wordpress without sudo su.
But the apache2 static page is still there.
Has something changed with Apache2 or WordPress that's preventing it from pointing to WP?
Looks like your are trying to install apache2 with WordPress. I would suggest you to follow these steps and let me know, if it helps.
$ sudo apt-get update
Install apache
$ sudo apt install apache2
Verify your Apache installation by typing "http://your-ip-address" in your favourite browser.
hostname -I | awk '{print $1}' # can help you to get your IP address.
If you have firewall installed run this command to enable port 80. If you don't have firewall, skip this step.
$ sudo ufw allow 'Apache'
Install wordpress
1. sudo apt update
2. sudo apt install wordpress php libapache2-mod-php mysql-server php-mysql
3. cd /etc/apache2/sites-available/
4. sudo vi wordpress.conf
#Add these lines in wordpress.conf
Alias /blog /usr/share/wordpress
<Directory /usr/share/wordpress>
Options FollowSymLinks
AllowOverride Limit Options FileInfo
DirectoryIndex index.php
Order allow,deny
Allow from all
</Directory>
<Directory /usr/share/wordpress/wp-content>
Options FollowSymLinks
Order allow,deny
Allow from all
</Directory>
5. sudo a2ensite wordpress
6. sudo a2enmod rewrite
7. sudo service apache2 reload
Now Configure mysql
$ sudo mysql -u root
Once you get mysql prompt, Run create, grant, Flush and quit command as follows -
$ mysql> CREATE DATABASE wordpress;
set username and password
$ mysql> create user 'wordpress'#'localhost' IDENTIFIED BY 'test1234';
Run these commands
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON wordpress.* TO 'wordpress'#'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit
Now, configure "/etc/wordpress/config-localhost.php file to link MySQL DB "WordPress" created above. create the config-localhost.php, if doesn't exist.
add these lines
<?php
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'test1234');
define('DB_HOST', 'localhost');
define('DB_COLLATE', 'utf8_general_ci');
define('WP_CONTENT_DIR', '/usr/share/wordpress/wp-content');
?>
Restart mysql service
$ sudo service mysql start
Login to your WordPress by opening "localhost/blog/wp-login.php".
I found this link, may be helpful for you. It shows each step screenshot also.
I to linked 3 separate containers together:
nginx:1.10-alpine
php:7.0.6-fpm-alpine
mariadb:5.5
my goal is to run wp-cli installation before the source code being copy into the nginx container.
issues:
trying to run installation script of wp-cli from Dockerfile (my-nginx image) works fine, but when i try running any wp-cli commands it returns error: env: can't execute 'php': No such file or directory
wp-cli installation script (with the right dependencis) works also on dockerfile.php-fpm (my-php image), it returns an error as well : Error: YIKES! It looks like you're running this as root. You probably meant to run this as the user that your WordPress install exists under. and offers me to run this command with the flag --allow-root, wich is bad in this case becuase i want to use wp user permissions. or to run this command as another user.
core configuretions
docker-compose.yml:
version: '2'
services:
my-nginx:
build: .
volumes:
- .:/var/www/html
ports:
- "8080:80"
links:
- my-php
- my-mysql
my-php:
build:
context: .
dockerfile: Dockerfile.php-fpm
volumes:
- .:/var/www/html
ports:
- "9000:9000"
my-mysql:
image: mariadb:5.5
volumes:
- /var/lib/mysql
nginx.conf:
server {
server_name _;
listen 80 default_server;
root /var/www/html;
index index.php index.html;
access_log /dev/stdout;
error_log /dev/stdout info;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .php$ {
include fastcgi_params;
fastcgi_pass my-php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
wp-cli integration is cloned from : https://github.com/conetix/docker-wordpress-wp-cli
option 1
Dokerfile:
FROM nginx:1.10-alpine
# add root dir
RUN mkdir -p /var/www/html
WORKDIR /var/www/html
ENV WP_ROOT /var/www/html
# Install requirements for wp-cli support
RUN apk update \
&& apk add less mysql-client sudo curl
# copy nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Add WP-CLI
RUN curl -o /bin/wp-cli.phar https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
COPY wp-su.sh /bin/wp
RUN chmod +x /bin/wp-cli.phar \
&& sudo mv /bin/wp-cli.phar /usr/local/bin/wp
RUN wp core download --allow-root
# copy all files for current dir (should be theme or plugin folder)
COPY . ./
Dockergile.php-fpm
FROM php:7.0.6-fpm-alpine
VOLUME /var/www/html
RUN docker-php-ext-install -j $(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) iconv gd mbstring fileinfo curl xmlreader xmlwriter mysqli
option 2
Dokerfile:
FROM nginx:1.10-alpine
# add root dir
RUN mkdir -p /var/www/html
WORKDIR /var/www/html
RUN apk update \
&& apk add less mysql-client sudo
# copy nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
# copy all files for current dir (should be theme or plugin folder)
COPY . ./
Dockergile.php-fpm
FROM php:7.0.6-fpm-alpine
VOLUME /var/www/html
RUN docker-php-ext-install -j $(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) iconv gd mbstring fileinfo curl xmlreader xmlwriter mysqli
# Install requirements for wp-cli support
RUN apk update \
&& apk add curl sudo less
ENV WP_ROOT /var/www/html
# Add WP-CLI
RUN curl -o /bin/wp-cli.phar https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
COPY wp-su.sh /bin/wp
RUN chmod +x /bin/wp-cli.phar \
&& sudo mv /bin/wp-cli.phar /usr/local/bin/wp
RUN wp core download
general questions:
what is the best practice for users premissions inside dockers?
wp-cli integration from https://github.com/conetix/docker-wordpress-wp-cli/blob/master/wp-su.sh uses www-data user - should i add this user to my docker, and if so - to wich one? ngnix or php-fpm and why.
running wp donlowd core from php-fpm container appaers as if it download the files but when i try to exec when its running, none of this files shown at /var/www/html . is there a certain way to order images file mounting?
why does 'php' isn't available command from my-nginx if i volume
my-php image? i must install php also on this image?
PHP isn't installed in your nginx container. I'd argue that it should not be installed there either. Use your php fpm container to run WP CLI. Here's how I get WP CLI running using a similar setup:
docker-compose.yml:
version: '2'
services:
mysql:
image: mysql:latest
volumes:
- "../.data/db:/var/lib/mysql"
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: my_database
MYSQL_USER: my_user
MYSQL_PASSWORD: password
phpfpm:
depends_on:
- mysql
image: my/phpfpm:latest
build: ./docker/php-fpm
volumes:
- ".:/var/www/html"
- "./docker/php-fpm/php.ini:/usr/local/etc/php/php.ini"
- "./docker/php-fpm/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini"
links:
- mysql
restart: always
extra_hosts:
- "mysite.dev:172.18.0.1" # Use the gateway address for your docker network for the ip address. This is so that PHP FPM can find nginx for the postback to do things like cron jobs with WordPress
nginx:
depends_on:
- phpfpm
ports:
- "80:80"
image: nginx:latest
volumes:
- ".:/var/www/html"
- "./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf"
links:
- phpfpm
restart: always
docker/php-fpm/Dockerfile:
FROM php:5.5-fpm
ARG INSTALL_XDEBUG=true
ENV INSTALL_XDEBUG ${INSTALL_XDEBUG}
RUN if [ ${INSTALL_XDEBUG} = true ]; then \
pecl install xdebug && \
docker-php-ext-enable xdebug \
;fi
RUN apt-get update && apt-get install -y libz-dev libmemcached-dev libjpeg-dev libpng-dev \
&& pecl install memcached \
&& docker-php-ext-enable memcached \
&& docker-php-ext-install -j$(nproc) pdo pdo_mysql mysqli gd \
&& docker-php-ext-enable pdo pdo_mysql mysqli gd
RUN docker-php-ext-install zip \
&& docker-php-ext-enable zip
RUN curl https://getcomposer.org/download/1.2.0/composer.phar > /tmp/composer.phar \
&& chmod +x /tmp/composer.phar \
&& mv /tmp/composer.phar /usr/local/bin/composer \
&& apt-get update && apt-get install -y less \
&& curl https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar > /tmp/wp-cli.phar \
&& chmod +x /tmp/wp-cli.phar \
&& mv /tmp/wp-cli.phar /usr/local/bin/wp
CMD ["php-fpm"]
EXPOSE 9000
I also use a memcached container, so that's why the dockerfile is also installing the memcached extension. The important parts are where it installs WP CLI and moves it into place. You can also modify the version of PHP that's installed by changing it in that dockerfile. Once you have your cluster up and running with WP CLI installed on PHP, you can run the following command to run wp cli commands inside the container:
docker exec -u www-data <container_name> wp ... # whatever command after that
I have aliases for different projects that already have the container names:
alias mywp="docker exec -u www-data mysite_phpfpm_1 wp"
and that lets me run wp commands like this:
mywp core update-db --network
mywp post meta list 2119
Hello fellows I have made a custom wordpress image located there: https://github.com/ellakcy/wordpressWithPlugins
And on entrypoint script I am using wp-cli in order to generate a custom user in order to preinstall plugins. But I cannot login to the control panel with the generated user from wp-cli.
Do you have any Idea how to fix it?
The entrypoint of the script is the following: https://github.com/ellakcy/wordpressWithPlugins/blob/master/docker-entrypoint.sh
I run the containers with these commands: (for development purpose)
docker run --name wpdb -e MYSQL_ROOT_PASSWORD=1234 -d mariadb
docker run --name mywordpress --link wpdb:mysql -p 8080:80 -ti wp
And I am using apache as reverse proxy in order to access the wordpress running in the mywordpress container:
<VirtualHost *:80>
ProxyPass / http://172.17.0.3/
ProxyPassReverse http://172.17.0.3/ /
</Virtualhost>
(In place of 172.17.0.3 can be the ip of the container running the wordpress)
Edit 1
I managed to login by setting up a network:
docker network create --subnet="172.19.0.0/16" wordpress_default
And setting the custom ips to the coontainers. (Also I set some Enviromental variables too.)
RUN MYSQL/MARIADB
docker run --name wpdb --net wordpress_default --ip 172.19.0.2 -e MYSQL_ROOT_PASSWORD=1234 -d mariadb
run wordpress docker with some extra enviiromental variables
docker run --name mywordpress --net wordpress_default --ip 172.19.0.3 --link wpdb:mysql -e WORDPRESS_ADMIN_PASSWORD=1234 -e WORDPRESS_ADMIN_EMAIL=pc_magas#openmailbox.org -e WORDPRESS_URL=172.19.0.3 -p 8080:80 -ti wp
And visiting the wordpress site via the ip given oon the second coommand. But I still have problems with the local apache running as reverse proxy.
In the end just manually setting the machine's ip as url works like a charm.
docker run --name wpdb --net wordpress_default --ip 172.19.0.2 -e MYSQL_ROOT_PASSWORD=1234 -d mariadb
run wordpress docker with some extra enviiromental variables
docker run --name mywordpress --net wordpress_default --ip 172.19.0.3 --link wpdb:mysql -e WORDPRESS_ADMIN_PASSWORD=1234 -e WORDPRESS_ADMIN_EMAIL=pc_magas#openmailbox.org -e WORDPRESS_URL=172.19.0.3 -p 8080:80 -ti wp
All I had to do wat to set the following vhost to my apache:
<VirtualHost *:80>
RequestHeader set X-Forwarded-Proto "http"
ProxyPass / http://172.19.0.3/
ProxyPassReverse http://172.19.0.3/ /
</Virtualhost>
(Perhaps for production may need some changes)
Maybe it's just because it's a Friday and it's after closing time but I've been stuck on this for an hour and can't quite get it working. I'm using Vagrant with an application we're building - the git repo contains the Vagrantfile and a Laravel application. We have /deploy, /tests, and /src directories; the actual Laravel framework lives in /src. On my local machine, I have set up a VirtualHost that let's me access the application by browsing to localhost:9000:
Listen 8081
<VirtualHost *:8081>
DocumentRoot "/Application/mamp/apache2/htdocs/myapp/src/public"
ServerName localhost
<Directory "/Application/mamp/apache2/htdocs/myapp/src/public">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Works like a charm. So I copied the relevant bits to my Vagrant setup:
Listen 8081
<VirtualHost *:8081>
DocumentRoot "/var/www/src/public"
ServerName localhost
<Directory "/var/www/src/public">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
My Vagrantfile looks like this:
# -*- 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|
config.vm.box = "hashicorp/precise64"
config.vm.provision :shell, :path => "vagrant/main.sh"
config.vm.network "private_network", ip: "192.168.100.101", virtualbox__intnet: true
end
And my vagrant/main.sh file looks like this:
#!/usr/bin/env bash
apt-get update
echo mysql-server-5.5 mysql-server/root_password password notthepassword | debconf-set-selections
echo mysql-server-5.5 mysql-server/root_password_again password notthepassword | debconf-set-selections
apt-get install -y mysql-common mysql-server mysql-client
apt-get install -y apache2
apt-get install -y php5 libapache2-mod-php5
apt-get install -y php5-mysql php5-curl php-pear php5-imagick php5-mcrypt php5-memcache
apt-get install -y vim
a2enmod rewrite
sed -i -e 's/AllowOverride None/AllowOverride All/g' /etc/apache2/sites-available/default
cp /vagrant/vagrant/bgs /etc/apache2/sites-available
a2ensite bgs
/etc/init.d/apache2 restart
rm -rf /var/www
ln -fs /vagrant /var/www
Once it's all up and running I can ping 192.168.100.101. But it's not serving any HTML - if I browse to that address in Chrome, I get a "no data received" error. If I go to 192.168.100.101:8081 Chrome says it can't find the address. How can I configure everything to play nice together and let me clone my repo, run vagrant up, and browse to 192.168.100.101:8081 and see my app?
(Also: I even added a port forwarding line in there to go from guest:8081 to host:8081. That generated an HTTP 500 error ("The server encountered an internal error or misconfiguration and was unable to complete your request."). Not sure if that's progress or not.
Turns out there was a number of things happening all at once:
I was using Ubuntu 12 LTS, which had a version of PHP a little to old to run the edge release of Laravel. Installing an upgraded version of PHP fixed that.
The virtualbox__intnet directive was...wrong. Somehow. Changed that whole Vagrantfile line to: config.vm.network "private_network", :ip => "192.168.100.101", :auto_network => true
The different ports, mucking about in the various symlinked directories vs. apache config directories...needlessly complicated.
Here's my final setup, in case anyone else has this exact, specific problem:
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|
config.vm.box = "puppetlabs/ubuntu-13.10-64-puppet"
config.vm.provision :shell, :path => "vagrant/main.sh"
config.vm.network "private_network", :ip => "192.168.100.101", :auto_network => true
end
main.sh:
#!/usr/bin/env bash
apt-get update
echo mysql-server-5.5 mysql-server/root_password password f6b6rWixbu99CtQ | debconf-set-selections
echo mysql-server-5.5 mysql-server/root_password_again password f6b6rWixbu99CtQ | debconf-set-selections
apt-get install -y mysql-common mysql-server mysql-client apache2 php5 libapache2-mod-php5 php5-mysql php5-curl php-pear php5-imagick php5-mcrypt php5-memcache php5-json
a2enmod rewrite
sed -i -e 's/AllowOverride None/AllowOverride All/g' /etc/apache2/sites-available/default
cp /vagrant/vagrant/app.conf /etc/apache2/sites-available
a2ensite app.conf
#fix for ubuntu 13.10: http://stackoverflow.com/questions/19446679/mcrypt-not-present-after-ubuntu-upgrade-to-13-10
ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/mcrypt.ini
php5enmod mcrypt
#/fix
#json licensing snafu: http://stackoverflow.com/questions/18239405/php-fatal-error-call-to-undefined-function-json-decode
php5enmod json
#/snafu
#may need to be done on the host OS, not the guest: http://stackoverflow.com/questions/17954625/services-json-failed-to-open-stream-permission-denied-in-laravel-4
chmod -R 0777 /vagrant/src/app/storage
rm -rf /var/www
ln -fs /vagrant/src/public /var/www
/etc/init.d/apache2 restart
Apache site configuration copied in:
<VirtualHost *:80>
DocumentRoot "/var/www"
ServerName localhost
<Directory "/var/www">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
(BTW, though this config looks very similar to the default apache configuration, I found it was easier and more extensible to create a config for whatever project I happen to be working on, and if I need to expand on the options for a future project, I can.)