Installing

Requirements

  • PHP ≥ 7.1.0

Installing

Poirot and set of packages are available on github. We will use Composer to create a new project from scratch it can be easily installed using Composer:

composer create-project poirot/project {path} dev-devel --prefer-dist

Up and Running

PHP Built-in Web Server Config

To run Poirot locally via Built-in Server, from the project's root directory by use the following command:

php -S 0.0.0.0:8000 -t html html/index.php

This will make the website available on port 8080 on all network interfaces. This means the site is accessible via http://localhost:8000 or http://<your-local-IP>:8000.

Using docker-compose

Docker enables you to rapidly deploy server environments in “containers.” Docker has become an extremely popular way to configure, save, and share server environments using containers. Because of this, installing an application or even a large stack can often be as simple as running docker pull or docker run.

docker-compose is a tool for automating configuration of containers and composing dependencies between them, such as volume storage, networking, etc.

Clone Dockerized PHP Webserver built to support Poirot by clone the repository beside to your Poirot project.

git clone git@github.com:phPoirot/shipWeb.git \
 && cd shipWeb

The .env file inside the folder will used for basic configuration of building application and settings such as port number, your project directory, installing dependencies and etc. copy dist file and make edit to this file based on project requirement. the first line will refer to your main project path.

cp .env.dist .env

Run docker compose to build and up the service:

docker-compose up -d

To see what happening inside container you can use these commands in order to see about health and output inside container.

docker-compose ps \
&& docker-compose logs -f

Server Configuration

Nginx Config

server {
	listen   80; ## listen for ipv4; this line is default and implied
	listen   [::]:80 default ipv6only=on; ## listen for ipv6

	root /var/www/html;
	index index.php index.html index.htm;

	# Make site accessible from http://localhost/
	server_name _;

    #
    client_max_body_size 800M;

	# Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
	sendfile off;

	# Add stdout logging
	error_log /dev/stdout info;
	access_log /dev/stdout;

    # Add option for x-forward-for (real ip when behind elb)
    #real_ip_header X-Forwarded-For;
    #set_real_ip_from 172.16.0.0/12;

	try_files $uri $uri/ @notfile;

    location @notfile {
        rewrite ^(.*) /index.php last;
    }

	# pass the PHP scripts to FastCGI server listening on socket
	#
	location ~ \.php(.*)$ {
        try_files $uri =404;

		fastcgi_pass unix:/var/run/php-fpm.sock;

		fastcgi_index index.php;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

		#fastcgi_split_path_info ^(.+\.php)(/.+)$;
		include fastcgi_params;
	}


    ## If no favicon exists return a 204 (no content error).
    location = /favicon.ico {
        try_files $uri =204;
        log_not_found off;
        access_log off;
    }

    ## Don't log robots.txt requests.
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

	# deny access to . files, for security
	#
	location ~ /\. {
        log_not_found off;
        deny all;
	}

	location ^~ /.well-known {
        allow all;
        auth_basic off;
    }
}

Apache Config

.htaccess
# Optional setting that you may want to disable.

### Compress ouput by mod_deflate
#<IfModule mod_deflate.c>
	#AddOutputFilterByType DEFLATE text/css application/x-javascript application/javascript text/html text/plain text/xml
#</IfModule>

### Use expires headers for images
#<IfModule mod_expires.c>
#	 ExpiresActive 	On
#	 ExpiresByType 	image/gif		  			A604800
#	 ExpiresByType  image/jpg		 			A604800
#	 ExpiresByType  image/jpeg		 			A604800
#	 ExpiresByType 	image/png		  			A604800
#	 ExpiresByType	application/x-javascript	A86400
#	 ExpiresByType	application/javascript		A86400
#	 ExpiresDefault				 				A604800
#</IfModule>

### Change Application enviorment cause load various Config
# php server default config is default
# SetEnv PT_ENVIRONMENT default
SetEnv PT_ENVIRONMENT development
SetEnv PT_DEBUG True

### Application requirement , dont change below !!

DirectoryIndex index.php

<IfModule mod_rewrite.c>
    SetEnv HTTP_MOD_REWRITE On
    RewriteEngine On
    ## FIX Missing Authorization Request Header
    RewriteCond %{HTTP:Authorization} ^(.*)
    RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
    # The following rule tells Apache that if the requested filename
    # exists, simply serve it.
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    # The following rewrites all other queries to index.php. The
    # condition ensures that if you are using Apache aliases to do
    # mass virtual hosting, the base path will be prepended to
    # allow proper resolution of the index.php file; it will work
    # in non-aliased environments as well, providing a safe, one-size
    # fits all solution.
    RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]
    RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
    RewriteCond %{REQUEST_URI} !=/server-status
</IfModule>

Last updated

Was this helpful?