commit fba3e3627b6c6a38ad67f395eacb49a6408a82bf Author: Bachir Soussi Chiadmi Date: Wed Mar 21 17:36:52 2018 +0100 first commit diff --git a/.env b/.env new file mode 100644 index 0000000..964a7f3 --- /dev/null +++ b/.env @@ -0,0 +1,10 @@ +COMPOSE_PROJECT_NAME=popsu + +PROJECT_ROOT=./public_html +LOG_ROOT=./log + +DB_IMPORTE_FILE=./ressources/db.sql +DB_ROOT_PASSWORD=popsu +DB_NAME=popsu +DB_USERNAME=popsu +DB_PASSWORD=popsu diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6cac38d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +public_html/* +log/* +*.sql diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0a9a858 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "public_html"] + path = public_html + url = https://figureslibres.io/gogs/bachir/popsu-d7.git diff --git a/Docker/mysql/mysql.cnf b/Docker/mysql/mysql.cnf new file mode 100644 index 0000000..8d6fb74 --- /dev/null +++ b/Docker/mysql/mysql.cnf @@ -0,0 +1,2 @@ +[mysqld] +max_allowed_packet=500M diff --git a/Docker/nginx/Dockerfile b/Docker/nginx/Dockerfile new file mode 100644 index 0000000..f1acc2d --- /dev/null +++ b/Docker/nginx/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx:latest + +COPY ./default.conf /etc/nginx/conf.d/default.conf diff --git a/Docker/nginx/default.conf b/Docker/nginx/default.conf new file mode 100644 index 0000000..83f32f4 --- /dev/null +++ b/Docker/nginx/default.conf @@ -0,0 +1,36 @@ +server { + listen 80 default_server; + root /var/www/html; + index index.html index.php; + + charset utf-8; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location = /favicon.ico { access_log off; log_not_found off; } + location = /robots.txt { access_log off; log_not_found off; } + + access_log on; + error_log /var/log/nginx/error.log error; + + sendfile off; + + client_max_body_size 100m; + + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php:9000; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_intercept_errors off; + fastcgi_buffer_size 16k; + fastcgi_buffers 4 16k; + } + + location ~ /\.ht { + deny all; + } +} diff --git a/Docker/php/Dockerfile b/Docker/php/Dockerfile new file mode 100644 index 0000000..82cc8cb --- /dev/null +++ b/Docker/php/Dockerfile @@ -0,0 +1,25 @@ +FROM php:5.6-fpm + +COPY ./php-custom.ini /usr/local/etc/php/conf.d/php-custom.ini + +RUN apt-get update && apt-get install -y \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libmcrypt-dev \ + libpng-dev \ + mysql-client \ + zip && \ + docker-php-ext-install -j$(nproc) iconv mcrypt && \ + docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \ + docker-php-ext-install -j$(nproc) gd && \ + docker-php-ext-install pdo_mysql zip && \ + docker-php-ext-install opcache && \ + apt-get install -y git vim && \ + pecl install redis-3.1.0 && \ + pecl install xdebug-2.5.0 && \ + docker-php-ext-enable redis xdebug && \ + export COMPOSER_HOME=/usr/local/composer && \ + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \ + composer global require drush/drush:6.5.0 && \ + composer global install && \ + ln -s /usr/local/composer/vendor/drush/drush/drush /usr/local/bin/drush diff --git a/Docker/php/php-custom.ini b/Docker/php/php-custom.ini new file mode 100644 index 0000000..7d45b6c --- /dev/null +++ b/Docker/php/php-custom.ini @@ -0,0 +1 @@ +memory_limit = 526M diff --git a/README.md b/README.md new file mode 100644 index 0000000..9471180 --- /dev/null +++ b/README.md @@ -0,0 +1,103 @@ + +# Popsu 7.x +Popsu powered by druapl 7 in docker environement (nginx, php:5.6-fpm+drush, solr:5, phpmyadmin) + +## Install docker +``` +sudo pacman -S docker docker-compose docker-machine +``` + +## Clone this repos + +this will clone this repos (main docker environement) and the materio-base drupal 7 source code (without sites/default folder) + +``` +git clone --recursive -o figli https://figureslibres.io/gogs/bachir/docker-popsu-d7.git +``` + +### setup /sites/default/settings.php + +```cp -r ressources/default public_html/sites/``` + +### get the sites/default/files folder +get the files from where you have it and rsync it to public_html/sites/default/files/ + +## Mysql +Copy your-sql-dump.sql into ./ressources/db.sql +It will be automaticly imported into the mysql container db (only) on the first docker-compose up + +## Hosts and reverse proxy + +add to your /etc/hosts : +``` +127.0.0.1 dev.popsu.archi.fr +127.0.0.1 dev.phpmyadmin.popsu.archi.fr +``` +configure your apache vhosts to add a reverse proxy that will redirect the dev.materio.com to our container +``` + + ServerName dev.popsu.archi.fr + ProxyPass / http://127.0.0.1:8880/ + ProxyPassReverse / http://127.0.0.1:8880/ + ProxyRequests Off + +``` +``` + + ServerName dev.phpmyadmin.popsu.archi.fr + ProxyPass / http://127.0.0.1:8881/ + ProxyPassReverse / http://127.0.0.1:8881/ + ProxyRequests Off + +``` +## Docker + +### build +only before the first run (may take some time) +``` +sudo docker-compose build +``` +### run +then each time you want to launch the app +``` +sudo docker-compose up -d +``` +Be aware that a first up, since the db is empty, it will be populated with your file db.sql. It may take some time depending of your db size. + +### loging in +``` +sudo docker exec -it popsu_php_1 bash +``` + +## Visualize +You can now visit http://dev.popsu.archi.fr on your browser +After the first run + +## Coding +### drush +you can access to drush by loging into the php container +``` +sudo docker exec -it popsu_php_1 bash +``` +once inside the php container in /var/www/html you can use drush as usual + +## updateding manualy mysql db +copy your db backup into the mysql container +``` +sudo docker cp your-db-file.sql popsu_mysql_1:/root/ +``` +log into mysql container +``` +sudo docker exec -it popsu_php_1 bash +``` +once inside the mysql container you can use mysql command to drop then create and load the db with your file + + +# sources +https://www.ostraining.com/blog/drupal/docker/ + +http://tech.osteel.me/posts/2017/01/15/how-to-use-docker-for-local-web-development-an-update.html + +https://mmenozzi.github.io/2016/01/22/php-web-development-with-docker/ + +https://dzone.com/articles/continuous-drupal-maintaining-a-drupal-website-wit diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5a61d7c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,72 @@ +version: "3.5" + +services: + mysql: + image: mariadb:latest + volumes: + - db-data:/var/lib/mysql + - ./Docker/mysql/mysql.cnf:/etc/mysql/conf.d/custom.cnf:ro + - "${DB_IMPORTE_FILE}:/docker-entrypoint-initdb.d/db.sql" + networks: + - database + environment: + MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}" + MYSQL_DATABASE: "${DB_NAME}" + MYSQL_USER: "${DB_USERNAME}" + MYSQL_PASSWORD: "${DB_PASSWORD}" + + redis: + image: redis:3 + volumes: + - redis-data:/data + networks: + - redis + ports: + - "6379" + + php: + build: ./Docker/php/ + expose: + - 9000 + volumes: + - php-root-data:/root + - "${PROJECT_ROOT}:/var/www/html" + networks: + - database + - server + - redis + depends_on: + - mysql + + phpmyadmin: + image: phpmyadmin/phpmyadmin + ports: + - 8881:80 + networks: + - database + depends_on: + - mysql + environment: + PMA_HOST: mysql + + nginx: + build: ./Docker/nginx/ + ports: + - 8880:80 + volumes: + - "${PROJECT_ROOT}:/var/www/html" + - "${LOG_ROOT}:/var/log:rw" + networks: + - server + depends_on: + - php + +volumes: + db-data: + redis-data: + php-root-data: + +networks: + database: + redis: + server: diff --git a/public_html b/public_html new file mode 160000 index 0000000..68e9e90 --- /dev/null +++ b/public_html @@ -0,0 +1 @@ +Subproject commit 68e9e90294412e471666b9d2b39544b882945eb3 diff --git a/ressources/default/settings.php b/ressources/default/settings.php new file mode 100644 index 0000000..9adf1f5 --- /dev/null +++ b/ressources/default/settings.php @@ -0,0 +1,483 @@ + 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'port' => 3306, + * 'prefix' => 'myprefix_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * The "driver" property indicates what Drupal database driver the + * connection should use. This is usually the same as the name of the + * database type, such as mysql or sqlite, but not always. The other + * properties will vary depending on the driver. For SQLite, you must + * specify a database file name in a directory that is writable by the + * webserver. For most other drivers, you must specify a + * username, password, host, and database name. + * + * Some database engines support transactions. In order to enable + * transaction support for a given database, set the 'transactions' key + * to TRUE. To disable it, set it to FALSE. Note that the default value + * varies by driver. For MySQL, the default is FALSE since MyISAM tables + * do not support transactions. + * + * For each database, you may optionally specify multiple "target" databases. + * A target database allows Drupal to try to send certain queries to a + * different database if it can but fall back to the default connection if not. + * That is useful for master/slave replication, as Drupal may try to connect + * to a slave server when appropriate and if one is not available will simply + * fall back to the single master server. + * + * The general format for the $databases array is as follows: + * @code + * $databases['default']['default'] = $info_array; + * $databases['default']['slave'][] = $info_array; + * $databases['default']['slave'][] = $info_array; + * $databases['extra']['default'] = $info_array; + * @endcode + * + * In the above example, $info_array is an array of settings described above. + * The first line sets a "default" database that has one master database + * (the second level default). The second and third lines create an array + * of potential slave databases. Drupal will select one at random for a given + * request as needed. The fourth line creates a new database with a name of + * "extra". + * + * For a single database configuration, the following is sufficient: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => 'main_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * You can optionally set prefixes for some or all database table names + * by using the 'prefix' setting. If a prefix is specified, the table + * name will be prepended with its value. Be sure to use valid database + * characters only, usually alphanumeric and underscore. If no prefixes + * are desired, leave it as an empty string ''. + * + * To have all database names prefixed, set 'prefix' as a string: + * @code + * 'prefix' => 'main_', + * @endcode + * To provide prefixes for specific tables, set 'prefix' as an array. + * The array's keys are the table names and the values are the prefixes. + * The 'default' element is mandatory and holds the prefix for any tables + * not specified elsewhere in the array. Example: + * @code + * 'prefix' => array( + * 'default' => 'main_', + * 'users' => 'shared_', + * 'sessions' => 'shared_', + * 'role' => 'shared_', + * 'authmap' => 'shared_', + * ), + * @endcode + * You can also use a reference to a schema/database as a prefix. This maybe + * useful if your Drupal installation exists in a schema that is not the default + * or you want to access several databases from the same code base at the same + * time. + * Example: + * @code + * 'prefix' => array( + * 'default' => 'main.', + * 'users' => 'shared.', + * 'sessions' => 'shared.', + * 'role' => 'shared.', + * 'authmap' => 'shared.', + * ); + * @endcode + * NOTE: MySQL and SQLite's definition of a schema is a database. + * + * Database configuration format: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'pgsql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'sqlite', + * 'database' => '/path/to/databasefilename', + * ); + * @endcode + */ +$databases['default']['default'] = array( + 'driver' => 'mysql', + 'database' => 'materio_base_d7', + 'username' => 'root', + 'password' => 'materio', + 'host' => 'mysql', + 'prefix' => '', + 'collation' => 'utf8_general_ci', + ); + +/** + * Access control for update.php script. + * + * If you are updating your Drupal installation using the update.php script but + * are not logged in using either an account with the "Administer software + * updates" permission or the site maintenance account (the account that was + * created during installation), you will need to modify the access check + * statement below. Change the FALSE to a TRUE to disable the access check. + * After finishing the upgrade, be sure to open this file again and change the + * TRUE back to a FALSE! + */ +$update_free_access = FALSE; + +/** + * Salt for one-time login links and cancel links, form tokens, etc. + * + * This variable will be set to a random value by the installer. All one-time + * login links will be invalidated if the value is changed. Note that this + * variable must have the same value on every web server. If this variable is + * empty, a hash of the serialized database credentials will be used as a + * fallback salt. + * + * For enhanced security, you may set this variable to a value using the + * contents of a file outside your docroot that is never saved together + * with any backups of your Drupal files and database. + * + * Example: + * $drupal_hash_salt = file_get_contents('/home/example/salt.txt'); + * + */ +$drupal_hash_salt = ''; + +/** + * Base URL (optional). + * + * If Drupal is generating incorrect URLs on your site, which could + * be in HTML headers (links to CSS and JS files) or visible links on pages + * (such as in menus), uncomment the Base URL statement below (remove the + * leading hash sign) and fill in the absolute URL to your Drupal installation. + * + * You might also want to force users to use a given domain. + * See the .htaccess file for more information. + * + * Examples: + * $base_url = 'http://www.example.com'; + * $base_url = 'http://www.example.com:8888'; + * $base_url = 'http://www.example.com/drupal'; + * $base_url = 'https://www.example.com:8888/drupal'; + * + * It is not allowed to have a trailing slash; Drupal will add it + * for you. + */ +// $base_url = 'http://dev.materio.com'; // NO trailing slash! + +/** + * PHP settings: + * + * To see what PHP settings are possible, including whether they can be set at + * runtime (by using ini_set()), read the PHP documentation: + * http://www.php.net/manual/en/ini.list.php + * See drupal_initialize_variables() in includes/bootstrap.inc for required + * runtime settings and the .htaccess file for non-runtime settings. Settings + * defined there should not be duplicated here so as to avoid conflict issues. + */ + +/** + * Some distributions of Linux (most notably Debian) ship their PHP + * installations with garbage collection (gc) disabled. Since Drupal depends on + * PHP's garbage collection for clearing sessions, ensure that garbage + * collection occurs by using the most common settings. + */ +ini_set('session.gc_probability', 1); +ini_set('session.gc_divisor', 100); + +/** + * Set session lifetime (in seconds), i.e. the time from the user's last visit + * to the active session may be deleted by the session garbage collector. When + * a session is deleted, authenticated users are logged out, and the contents + * of the user's $_SESSION variable is discarded. + */ +ini_set('session.gc_maxlifetime', 200000); + +/** + * Set session cookie lifetime (in seconds), i.e. the time from the session is + * created to the cookie expires, i.e. when the browser is expected to discard + * the cookie. The value 0 means "until the browser is closed". + */ +ini_set('session.cookie_lifetime', 2000000); + +/** + * If you encounter a situation where users post a large amount of text, and + * the result is stripped out upon viewing but can still be edited, Drupal's + * output filter may not have sufficient memory to process it. If you + * experience this issue, you may wish to uncomment the following two lines + * and increase the limits of these variables. For more information, see + * http://php.net/manual/en/pcre.configuration.php. + */ +# ini_set('pcre.backtrack_limit', 200000); +# ini_set('pcre.recursion_limit', 200000); + +/** + * Drupal automatically generates a unique session cookie name for each site + * based on on its full domain name. If you have multiple domains pointing at + * the same Drupal site, you can either redirect them all to a single domain + * (see comment in .htaccess), or uncomment the line below and specify their + * shared base domain. Doing so assures that users remain logged in as they + * cross between your various domains. + */ +$cookie_domain = 'dev.materio.com'; + +/** + * Variable overrides: + * + * To override specific entries in the 'variable' table for this site, + * set them here. You usually don't need to use this feature. This is + * useful in a configuration file for a vhost or directory, rather than + * the default settings.php. Any configuration setting from the 'variable' + * table can be given a new value. Note that any values you provide in + * these variable overrides will not be modifiable from the Drupal + * administration interface. + * + * The following overrides are examples: + * - site_name: Defines the site's name. + * - theme_default: Defines the default theme for this site. + * - anonymous: Defines the human-readable name of anonymous users. + * Remove the leading hash signs to enable. + */ + $conf['site_name'] = "materiO'"; +# $conf['theme_default'] = 'garland'; +# $conf['anonymous'] = 'Visitor'; + +/** + * A custom theme can be set for the offline page. This applies when the site + * is explicitly set to maintenance mode through the administration page or when + * the database is inactive due to an error. It can be set through the + * 'maintenance_theme' key. The template file should also be copied into the + * theme. It is located inside 'modules/system/maintenance-page.tpl.php'. + * Note: This setting does not apply to installation and update pages. + */ +# $conf['maintenance_theme'] = 'bartik'; + +/** + * Enable this setting to determine the correct IP address of the remote + * client by examining information stored in the X-Forwarded-For headers. + * X-Forwarded-For headers are a standard mechanism for identifying client + * systems connecting through a reverse proxy server, such as Squid or + * Pound. Reverse proxy servers are often used to enhance the performance + * of heavily visited sites and may also provide other site caching, + * security or encryption benefits. If this Drupal installation operates + * behind a reverse proxy, this setting should be enabled so that correct + * IP address information is captured in Drupal's session management, + * logging, statistics and access management systems; if you are unsure + * about this setting, do not have a reverse proxy, or Drupal operates in + * a shared hosting environment, this setting should remain commented out. + */ +# $conf['reverse_proxy'] = TRUE; + +/** + * Set this value if your proxy server sends the client IP in a header other + * than X-Forwarded-For. + * + * The "X-Forwarded-For" header is a comma+space separated list of IP addresses, + * only the last one (the left-most) will be used. + */ +# $conf['reverse_proxy_header'] = 'HTTP_X_CLUSTER_CLIENT_IP'; + +/** + * reverse_proxy accepts an array of IP addresses. + * + * Each element of this array is the IP address of any of your reverse + * proxies. Filling this array Drupal will trust the information stored + * in the X-Forwarded-For headers only if Remote IP address is one of + * these, that is the request reaches the web server from one of your + * reverse proxies. Otherwise, the client could directly connect to + * your web server spoofing the X-Forwarded-For headers. + */ +# $conf['reverse_proxy_addresses'] = array('a.b.c.d', ...); + +/** + * Page caching: + * + * By default, Drupal sends a "Vary: Cookie" HTTP header for anonymous page + * views. This tells a HTTP proxy that it may return a page from its local + * cache without contacting the web server, if the user sends the same Cookie + * header as the user who originally requested the cached page. Without "Vary: + * Cookie", authenticated users would also be served the anonymous page from + * the cache. If the site has mostly anonymous users except a few known + * editors/administrators, the Vary header can be omitted. This allows for + * better caching in HTTP proxies (including reverse proxies), i.e. even if + * clients send different cookies, they still get content served from the cache + * if aggressive caching is enabled and the minimum cache time is non-zero. + * However, authenticated users should access the site directly (i.e. not use an + * HTTP proxy, and bypass the reverse proxy if one is used) in order to avoid + * getting cached pages from the proxy. + */ +# $conf['omit_vary_cookie'] = TRUE; + +/** + * CSS/JS aggregated file gzip compression: + * + * By default, when CSS or JS aggregation and clean URLs are enabled Drupal will + * store a gzip compressed (.gz) copy of the aggregated files. If this file is + * available then rewrite rules in the default .htaccess file will serve these + * files to browsers that accept gzip encoded content. This allows pages to load + * faster for these users and has minimal impact on server load. If you are + * using a webserver other than Apache httpd, or a caching reverse proxy that is + * configured to cache and compress these files itself you may want to uncomment + * one or both of the below lines, which will prevent gzip files being stored. + */ +# $conf['css_gzip_compression'] = FALSE; +# $conf['js_gzip_compression'] = FALSE; + +/** + * String overrides: + * + * To override specific strings on your site with or without enabling locale + * module, add an entry to this list. This functionality allows you to change + * a small number of your site's default English language interface strings. + * + * Remove the leading hash signs to enable. + */ +# $conf['locale_custom_strings_en'][''] = array( +# 'forum' => 'Discussion board', +# '@count min' => '@count minutes', +# ); + +/** + * + * IP blocking: + * + * To bypass database queries for denied IP addresses, use this setting. + * Drupal queries the {blocked_ips} table by default on every page request + * for both authenticated and anonymous users. This allows the system to + * block IP addresses from within the administrative interface and before any + * modules are loaded. However on high traffic websites you may want to avoid + * this query, allowing you to bypass database access altogether for anonymous + * users under certain caching configurations. + * + * If using this setting, you will need to add back any IP addresses which + * you may have blocked via the administrative interface. Each element of this + * array represents a blocked IP address. Uncommenting the array and leaving it + * empty will have the effect of disabling IP blocking on your site. + * + * Remove the leading hash signs to enable. + */ +# $conf['blocked_ips'] = array( +# 'a.b.c.d', +# ); + +/** + * Authorized file system operations: + * + * The Update manager module included with Drupal provides a mechanism for + * site administrators to securely install missing updates for the site + * directly through the web user interface by providing either SSH or FTP + * credentials. This allows the site to update the new files as the user who + * owns all the Drupal files, instead of as the user the webserver is running + * as. However, some sites might wish to disable this functionality, and only + * update the code directly via SSH or FTP themselves. This setting completely + * disables all functionality related to these authorized file operations. + * + * Remove the leading hash signs to disable. + */ +# $conf['allow_authorize_operations'] = FALSE; + +// $conf['cache'] = 0; +$conf['preprocess_js'] = 0; +$conf['preprocess_css'] = 0; + +$conf['session_limit_max'] = 10; + +$conf['maillog_send'] = 0; +$conf['enforce_limit'] = 'no'; + + +$conf['search_api_solr_overrides'] = array( + 'materio_solr3_en' => array( + 'name' => t('Materio EN Solr Server (Overridden)'), + 'options' => array( + 'host' => 'solr', + 'port' => 8983, + 'path' => '/solr/materio_base_en', + ), + ), + 'materio_solr3_fr' => array( + 'name' => t('Materio FR Solr Server (Overridden)'), + 'options' => array( + 'host' => 'solr', + 'port' => 8983, + 'path' => '/solr/materio_base_fr', + ), + ), +);