[Docker] How use Laradock for any project web (Laravel, wordpress, php, anymore)?

administrator

Administrator
Nhân viên
9 Tháng tám 2021
87
0
6
Video:
1. Pull Laradock: https://laradock.io/
2. Setup file Host in windows/system32/host
Mã:
127.0.0.1      hello.localhost
Test ping CMD "ping hello.localhost"
3. Edit .env in Laradock/env-example
Mã:
### PHP MY ADMIN ##########################################

# Accepted values: mariadb - mysql

PMA_DB_ENGINE=mariadb

# Credentials/Port:

PMA_USER=default
PMA_PASSWORD=secret
PMA_ROOT_PASSWORD=secret
PMA_PORT=8069
PMA_MAX_EXECUTION_TIME=600
PMA_MEMORY_LIMIT=256M
PMA_UPLOAD_LIMIT=2G
4. Edit Laradock/nghinx: xinchao\laradock\nginx\sites\hello.config
Mã:
server {

    listen 80;
    listen [::]:80;

    # For https
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server ipv6only=on;
    # ssl_certificate /etc/nginx/ssl/default.crt;
    # ssl_certificate_key /etc/nginx/ssl/default.key;

    server_name hello.localhost;
    root /var/www/hello;
    index index.php index.html index.htm;

    location / {
         try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_pass php-upstream;
        fastcgi_index index.php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fixes timeouts
        fastcgi_read_timeout 600;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

    location /.well-known/acme-challenge/ {
        root /var/www/letsencrypt/;
        log_not_found off;
    }
}
5. Cài đặt image docker:
Mã:
docker-compose up -d nginx phpmyadmin mariadb workspace php-fpm
6. Edit file wp-config.php in folder hello(wordpress is download):
Mã:
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'hello' );

/** Database username */
define( 'DB_USER', 'root' );

/** Database password */
define( 'DB_PASSWORD', 'root' );

/** Database hostname */
define( 'DB_HOST', 'mysql' );

/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
8. Enter website url website: hello.localhost
 
Chỉnh sửa lần cuối: