# Introduction
When you’re ready to deploy your Barcloud application, there are some important things you can do to make sure your application is running and deployed properly.
# Requirements
The Barcloud App has a few system requirements. So, you will need to make sure your server meets the following requirements:
- PHP >= 7.1.3
- BCMath PHP Extension
- Ctype PHP Extension
- JSON PHP Extension
- Mbstring PHP Extension
- OpenSSL PHP Extension
- PDO PHP Extension
- Tokenizer PHP Extension
- XML PHP Extension
# Application Configuration
## Public Directory
After installing, you should configure your web server’s document / web root to be thepublic
directory. The index.php
in this directory serves as the front controller for all HTTP requests entering your application.
## Directory Permissions
After installing, you may need to configure some permissions. Directories within thestorage
and the bootstrap/cache
directories should be writable by your web server or Laravel will not run.
sudo chmod -R 775 /var/www/html/your-project/storage
sudo chmod -R 775 /var/www/html/your-project/bootstrap/cache
## Application Key
The next thing you should do after installing Laravel is set your application key to a random string. By thephp artisan key:generate
command.
Typically, this string should be 32 characters long. The key can be set in the .env
environment file. If you have not copied the .env.example
file to a new file named .env
, you should do that now. If the application key is not set, your user sessions and other encrypted data will not be secure!
# Database Configuration
## MySQL
Step1: Create a new database via phpmyadmin
Navigate to PHPMyAdmin, Click on the Databases tab and create a new database with your wanted name.
Clicking on create will create a new database in your MySQL.
Step2: Changes in .env configuration file
Once the database is created, you need to tell your project the details about the database.
All configuration that you should stay private and should not share goes into the .env file of your project.
DB_CONNECTION=mysql
DB_HOST=190.0.0.1
DB_PORT=3066
DB_DATABASE=testProject
DB_USERNAME=youruser
DB_PASSWORD=yourpassword
Modify the following property in your .env file according to your database settings.
## Add search engine configuration
Create a google developer account for a custom search engine https://developers.google.com/custom-search/v1/overview
for yandex here https://xml.yandex.com/
GOOGLE_USERNAME=""
GOOGLE_API_KEY=""
GOOGLE_LANG=""
YANDEX_CX=""
YANDEX_API_KEY=""
YANDEX_LANG=""
## Migrate the database and fill with the default data
Run the database migrations
php artisan migrate
Run the database seeders
php artisan db:seed
# Web Server Configuration
## Local Development Server
If you have PHP installed locally and you would like to use PHP’s built-in development server to serve your application, you may use the serve Artisan command. This command will start a development server at http://localhost:8000:
php artisan serve
## Apache
The project includes a public/.htaccess file that is used to provide URLs without the index.php front controller in the path. Before serving Barcloud application with Apache, be sure to enable the mod_rewrite module so the .htaccess file will be honored by the server. Follow the following steps.
Step1: Enable the mod rewrite
sudo a2enmod rewrite
Step2: Create the apache configuration file for the barcloudapp
cd /etc/apache2/sites-available
sudo nano barcloud.conf
Step3: Add to the barcloud.conf
<VirtualHost *:80>
ServerName yourdomain.tld
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/your-project/public
<Directory /var/www/html/your-project>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Step4: Enable the application
sudo a2ensite barcloud.conf
sudo service apache2 restart
# Nginx
If you are deploying your application to a server that is running Nginx, you may use the following configuration file as a starting point for configuring your web server.
server {
listen 80;
server_name bacloud.com;
root /path/to/barcloud/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm 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; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
# Apache Proxy for docker container
If you are deploying your application with docker than here is model of virtual host for apache to expose your docker container
ServerName bacloud.com
Allow from localhost
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://localhost:8086/
ProxyPassReverse / https://localhost:8086/
# Nginx Proxy for docker container
server {
server_name barcloud.net;
listen 80;
listen [::]:80;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
proxy_pass http://localhost:8086/;
}
}
# Installation using Docker(you must to follow the steps from the Application Configuration)
Go to the project directory
cd barcloud-app
Then start the project using docker composer
docker-compose up -d
Run the database migrations inside of docker container
docker-compose exec application php artisan migrate --seed
Well, your application now is running in a docker container and is available at the url http://localhost:8086/