Skip to content

Instantly share code, notes, and snippets.

View Faizanq's full-sized avatar

Faizan Qureshi Faizanq

View GitHub Profile
Check if mod rewrite is enabled - sudo a2enmod rewrite
Give permissions to your storage and vendor folders - chmod 755 -R laravel and then chmod -R o+w storage
Check if you app.config has the environment variables set correctly including the 'url' . Set it to point to the right URL.
If you are using database ensure that you have your database.config set to the correct database for e.g. mysql. Set the database, user id and password
Go to /etc/apache2/sites-available/ and change your Document root to point to your Laravel public folder. (the one where you have your project installed)
Go to /etc/apache2 and use either of mcedit/vi/nano apache.conf and make the following modifications to /var/www/, you may also want to add this as an additional entry Assuming this is your DocumentRoot "/var/www/html/laravel/public/" <Directory "/var/www/html/laravel/public"> Allowoverride All Require all granted
Restart your apache-> apachectl restart or use a command that you find to handy.
//Open Ports on AWS
1->First Allow All TCP rules from anywhere
2->and Open port 80
//Now port forwading
1->sudo vim /etc/systctl.conf ==>enter
2->uncomment net.ipv4.ip_forward = 1 //line 28
3->save
1->sudo sysctl -p /etc/sysctl.conf // for activate the changes
##Install Apache, MySQL, PHP on Linux generally called LAMP which needs to install together to host websites and dynamic web applications on server. Where Linux is operating system, Apache is web server, MySQL is database and content is processed with PHP scripting language.
sudo apt-get update
sudo apt-get install apache2
##Enable Required apache2 modes
sudo a2enmod headers proxy_http xml2enc proxy ssl proxy_wstunnel rewrite
//logic
exports.getProducts = (req, res, next) => {
const page = +req.query.page || 1;
let totalItems;
Product.find()
.countDocuments()
.then(numProducts => {
totalItems = numProducts;
return Product.find()
<script src="http://maps.googleapis.com/maps/api/js?libraries=places" type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
var input = document.getElementById('searchTextField');
var autocomplete = new google.maps.places.Autocomplete(input);
google.maps.event.addListener(autocomplete, 'place_changed', function () {
var place = autocomplete.getPlace();
document.getElementById('city2').value = place.name;
document.getElementById('cityLat').value = place.geometry.location.lat();
In PHP
function calculate_distance($lat1, $lon1, $lat2, $lon2, $unit='N')
{
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$unit = strtoupper($unit);
In PHP
function calculate_distance($lat1, $lon1, $lat2, $lon2, $unit='N')
{
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$unit = strtoupper($unit);
models.inventory_transaction.findAll(
{ attributes: [[models.sequelize.fn('sum', models.sequelize.col('quantity')), 'total']],
include : [
{
model : models.product_entry,
attributes: [],
include : [
{
model : models.product,
attributes: [['name', 'name']]
https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform
<?php
class Db
{
private $_connection;
private static $_instance; //The single instance
private $_host = DB_HOST;
private $_username = DB_USER;
private $_password = DB_PASSWORD;
private $_database = DB_DB;