How to move espocrm From HTTP to HTTPS (with .crt .key .ca-bundle) π
When I installed espocrm I installed it with docker compose, without ssl, what happened is that in the project I was doing I realized that I had bought the domain and I was missing the SSL/TLS certificate and I introduced it to the project
The first thing we have to do is have these 3 files
β
I bought the certificate from an external company but with lets encrypt these files can be generated, what you have to keep in mind that you have to renew them every 90 days.
Delete all ur containers (dont worry your data is safe on the volumes that u create)
Now bse sure that ur espocrm container is running on port 443:443
(docker-compose.yml)
Now execute
Now let's list the containers that are working
Will se something like this
Now we will joun on the espocrm container so we need to use the container name and use this comand
β
In order to upload the certificates I am going to create a folder, you can create a folder where you want I use this
Now we go to the folder that we just created and we are going to put the certificates using the command
We copy the content of the file from our system, press enter and CTRL + D.
We do the same with the other 2 files, (YOUR DOMAIN).ca-bundle and (YOUR DOMAIN).net.key
Now we go to the /etc/apache2/sites-enabled/ directory and we will edit the file called 000-default.conf
We use the command cat >> 000-default.conf and write this
Now let's use the command
And finally
β
and we would already have the certificatesβ πβ
When I installed espocrm I installed it with docker compose, without ssl, what happened is that in the project I was doing I realized that I had bought the domain and I was missing the SSL/TLS certificate and I introduced it to the project
The first thing we have to do is have these 3 files
β
I bought the certificate from an external company but with lets encrypt these files can be generated, what you have to keep in mind that you have to renew them every 90 days.
Delete all ur containers (dont worry your data is safe on the volumes that u create)
PHP Code:
docker rm -f $(docker ps -a -q)
(docker-compose.yml)
PHP Code:
espocrm:
image: espocrm/espocrm
container_name: espocrm
environment:
ESPOCRM_DATABASE_PLATFORM: Mysql
ESPOCRM_DATABASE_HOST: mysql
ESPOCRM_DATABASE_USER: xxxxxxxxxxxxxxxx
ESPOCRM_DATABASE_PASSWORD: xxxxxxxxxxxxxxxx
ESPOCRM_ADMIN_USERNAME: xxxxxxxxxxxxxxxx
ESPOCRM_ADMIN_PASSWORD: xxxxxxxxxxxxxxxx
ESPOCRM_SITE_URL: xxxxxxxxxxxxxxxx
volumes:
- espocrm:/var/www/html
restart: always
ports:
- 443:443β
Now execute
PHP Code:
docker compose up -d
Now let's list the containers that are working
PHP Code:
docker ps
Now we will joun on the espocrm container so we need to use the container name and use this comand
β
PHP Code:
docker exec -it espocrm bash
In order to upload the certificates I am going to create a folder, you can create a folder where you want I use this
PHP Code:
mkdir /etc/ssl/server
Now we go to the folder that we just created and we are going to put the certificates using the command
PHP Code:
cat >> (YOUR DOMAIN).crt
We do the same with the other 2 files, (YOUR DOMAIN).ca-bundle and (YOUR DOMAIN).net.key
Now we go to the /etc/apache2/sites-enabled/ directory and we will edit the file called 000-default.conf
We use the command cat >> 000-default.conf and write this
PHP Code:
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/server/j(YOUR DOMAIN).crt
SSLCertificateKeyFile /etc/ssl/server/(YOUR DOMAIN).key
SSLCertificateChainFile /etc/ssl/server/(YOUR DOMAIN).ca-bundle
<FilesMatch "\.(?:cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>β
PHP Code:
a2enmod ssl
And finally
PHP Code:
service apache2 restart
and we would already have the certificatesβ πβ