Sign inSign up

linuxsolutions/server-web-nginx-php-fpm

By linuxsolutions

•Updated over 5 years ago

Image for secure and performance web server!

Image
0

305

linuxsolutions/server-web-nginx-php-fpm repository overview

⁠WebServer Nginx and PHP-FPM

N|Solid

Image ready to build your web server with Nginx and PHP-FPM.

Current versions composed in this image;

⁠Features!

Image based on Debian Buster Slim.

⁠With WordPress support

⁠What do you need to know!
  • Default Nginx Welcome Directory:
$ /var/www/html
  • Default Nginx configuration:
$ /etc/nginx/conf.d/default.conf
  • General site customization settings and possibilities to add other sites as well:
$ /etc/nginx/nginx.conf
  • Already set by default in nginx.conf:
$ include /etc/nginx/conf.d/*.conf;
$ include /etc/nginx/sites-enabled/*.conf;
$ include /etc/nginx/upstream/*.conf;

  • Example to run the server.
$ docker run --name my-server -d -p 8080:80 fuerzastudio/nginx-php-fpm
  • In the Browser:
127.0.0.1:8080 or your-ip-host:8080
  • Referencing your project:
$ docker run --name my-server -d -p 8080:80 -v /var/www/project:/var/www/html fuerzastudio/nginx-php-fpm
  • Docker Compose:
version: '3'

services:
  
  server-web:
    image: fuerzastudio/nginx-php-fpm
    container_name: webserver 
    restart: always
    volumes:
      - ./custom-site.conf:/etc/nginx/conf.d/default.conf #Example below
      - /path/your-project/:/var/www/html
    ports:
      - '80:80'
      - '443:443'
    expose:
      - '22'
    networks: 
      dev:
        ipv4_address: 171.28.5.10
networks: 
  dev:
    driver: bridge
    driver_opts:
      com.docker.network.enable_ipv6: "false"
    ipam:
      driver: default
      config:
      - subnet: 171.28.0.0/16
  • Example configuration for your site by editing the file custom-site.conf;
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 your-domain.com www.your-domain.com; #Here my dear, you put your domain!

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

    # Security - Hide nginx version number in error pages and Server header
    server_tokens off;

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

    # reduce the data that needs to be sent over network
    gzip on;
    gzip_min_length 10240;
    gzip_proxied expired no-cache no-store private auth;
    gzip_types text/plain text/css text/xml application/json text/javascript application/x-javascript application/xml;
    gzip_disable "MSIE [1-6]\.";

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to index.html
        try_files $uri $uri/ =404;
    }

    # 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/html;
    }

    # pass the PHP scripts to FastCGI server listening on socket
    #
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

        location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
                expires           5d;
        }

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

}
version: '3'

services:
  
  server-web:
    image: fuerzastudio/nginx-php-fpm
    container_name: nginx-php-fpm 
    restart: always
    volumes:
      - ./custom-site.conf:/etc/nginx/conf.d/default.conf #Example below
      - /path/your-project/:/var/www/html
    ports:
      - '80:80'
      - '443:443'
    expose:
      - '22'
    networks: 
      dev:
        ipv4_address: 171.28.5.10
    server-database:
    image: mariadb
    container_name: database-mariadb
    restart: always
    volumes:
      - ./data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=passroot
      - MYSQL_USER=example_usr              
      - MYSQL_PASSWORD=example_pass
      - MYSQL_DATABASE=example_db               
    ports:
      - '3306:3306'
    networks: 
      dev:
        ipv4_address: 171.28.5.11
networks: 
  dev:
    driver: bridge
    driver_opts:
      com.docker.network.enable_ipv6: "false"
    ipam:
      driver: default
      config:
      - subnet: 171.28.0.0/16


⁠License

GNU General Public License v3.0

Free Software, Hell Yeah!

Tag summary

Content type

Image

Digest

Size

208.4 MB

Last updated

over 5 years ago

docker pull linuxsolutions/server-web-nginx-php-fpm