How to Setup Virtual Host with XAMPP and LARAVEL at window OS

Step 1 – Add one virtual host at “httpd-vhosts.conf” at C:/xampp/apache/conf/extra/httpd-vhosts.conf

<VirtualHost *:8085>

DocumentRoot “D:/my_work_project_path/Project_Name/public”

ServerAdmin Project_Name@localhost

ServerName Project_Name

ServerAlias Project_Name

 

<Directory ” D:/my_work_project_path/Project_Name/public “>

AllowOverride All

Order Allow,Deny

Allow from all

Require all granted

</Directory>

</VirtualHost>

 

 

 

Step 2 – Add one host to C:/Windows/System32/drivers/etc/hosts

127.0.0.1             Project_Name

Step 3 – Add one Listen Port to “httpd.conf” at C:\xampp\apache\conf\httpd.conf

Listen 8085

 

Step 4 – Restart Apache server and browse from browser with “http://localhost:8085/”
 

Advertisements

Create a New User and Grant Permissions in MySQL

How To Create a New User and Grant Permissions in MySQL

================================

Before we create and grant the permissions to the new user, we need to open the ( MySql port 3306 from firewall ).
To check firewall is active or inactive at unbuntu by the following command

ufw status

if reply ufw inactive, we need to open the ufw (firewall) by the following command

ufw enable

And then you can check which port are allow in our web server by the following command

ufw status
and it will reply all status.
If mysql is not allow, we need to allow it by the following command

ufw allow 3306/tcp

if port 3306 is not okay to access from the remote / other local pc, we need to change the mysql default por to ‘3360’ or as you wish.

to change the MySql port to ‘3360’,
go to the /etc/mysql
and edit the my.cnf

go to ‘[mysqld]’ part
chnage the default “bind_address” to “server_ip_address
change the default “port” to “3360

And then, restart the mysql service by the follwoing command
sudo service mysql restart

After it all, we need to check one thing
which ports are opening at our Web Server by the following

nmap localhost/ipaddress

========================================

login to mysql with root password
mysql -uroot -p
and then,

1) Let’s start by making a new user within the MySQL shell:

CREATE USER ‘newuser’@’localhost’ IDENTIFIED BY ‘password’;

2) provide the user with access to the information they will need

GRANT ALL PRIVILEGES ON * . * TO ‘newuser’@’localhost’;

3) Let’s start by making a new user within the MySQL shell:

CREATE USER ‘newuser’@’ip_address’ IDENTIFIED BY ‘password’;

4) provide the user with access to the information they will need

GRANT ALL PRIVILEGES ON * . * TO ‘newuser’@’ip_address’;

5) Reload all privileges

FLUSH PRIVILEGES;

====================================

Cheers

How to Use SSL Certificate in LEMP Digital Droplet

(1) We need to create two Certificate to give to SSL Certificate Vendor ( Z.com / GMO-ACE )
———————————-
examplesite.csr
examplesite.key
———————————-

=================================
How do I generate a CSR Code
=================================

———————————————————

OS – Ubuntu 14.04
Digital Ocean Droplet with LEMP
———————————————————

cd /etc/ssl
mkdir /etc/ssl/websitessl
openssl req -new -newkey rsa:2048 -nodes -keyout domainname.key -out domainname.csr

rsa:2048
“`means you create a 2048bits csr. I recommend for more security to use “`rsa:4069“`
You also need to change “`domainname.key“`and “`domainname.csr“` into your own domain name
so you can verify the CSR file. After you filled in all the legit information ,
you can open the new file using a client for example WinSCP, copy it, and use it for your SSL.


 

(2) And then, we have to buy/generate our SSL certificate at SSL Vendor Site and we will get / SSL vendor will generate the certificate files .
———————————–
samplesite.PEM
samplesite.ICA
samplesite.PKCS7
———————————–

We have to copy generated .PEM files from SSL Certifiate Provider to our host ( Digital Ocean LEMP )
http://www.examplesite.com.PEM.
And then, we have to edit the virtual host setting file at
/etc/nginx/site-available/samplesite

===================================================
Using SSL Certificate at Nginx Virtual Host Setting
===================================================
you have to create tow server blocks for both HTTP and HTTPS request.
And then, redirect to every request to HTTPS.

server {
listen 80;
server_name example.com.mm http://www.example.com.mm;
return 301 https://www.example.com.mm$request_uri;
}

server {
listen 443 ssl;
ssl on;

root /var/www/registrations/public;
index index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name example.com.mm http://www.example.com.mm;
# server_name localhost;

access_log /var/log/nginx/nginx.vhost.access.log;
error_log /var/log/nginx/nginx.vhost.error.log;

ssl_certificate /etc/ssl/websitessl/www.example.com.mm.PEM;
ssl_certificate_key /etc/ssl/websitessl/examplesite.key;
ssl_trusted_certificate /etc/ssl/websitessl/www.example.com.mm.ICA;

ssl_ciphers “HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:3DES”;
ssl_prefer_server_ciphers on;

# to disable SSL3 service – to prevent the POODLE Vulnerablitiy attack
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?$query_string;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}

# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}

#error_page 404 /404.html;

# 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 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have “cgi.fix_pathinfo = 0;” in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
location ~ /\.ht {
deny all;
}

client_max_body_size 10M;
}

—————————————————————————————

Increase the Max Upload File Size at Nginx in Ubuntu 14.04

================================
Adding client_max_body_size” at Virtual Host of Nginx
================================
under /etc/nginx/site-available/sample_site_setting
———————————————————————-
server {
listen 8082;
listen [::]:8082;

root /var/www/registrations/public;
index index.php index.html index.htm;

server_name 128.199.226.122;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

client_max_body_size 10M;
}

================================
Increase the Max Upload File Size at PHP configuration
================================
/etc/php5/cli/php.ini
———————————————————————
from
post_max_size = 8M
upload_max_filesize = 2M
to
post_max_size = 10M
upload_max_filesize = 10M
———————————————————————–

Setting up Laravel with Nginx and phpmyadmin on Ubuntu 14.04

1) Install the Backend Components
1.1) sudo apt-get update
1.2) sudo apt-get upgrade
1.3) sudo apt-get install nginx php5-fpm php5-cli php5-mcrypt git
--------------------------------------------------------------------------------------------------------------------------
2) Modify the PHP Configuration
2.1) sudo nano /etc/php5/fpm/php.ini
2.2) cgi.fix_pathinfo=0 
2.3) sudo php5enmod mcrypt
2.4) sudo service php5-fpm restart
--------------------------------------------------------------------------------------------------------------------------
3) Configure Nginx and the Web Root
3.1) sudo mkdir -p /var/www/laravel
3.2) sudo nano /etc/nginx/sites-available/default


=======================================================
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    #root /var/www/laravel/public;
    index index.php index.html index.htm;

    server_name server_domain_or_IP;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

=======================================================
3.3) sudo service nginx restart
3.4) if you want to setup virtual block
3.4.1) sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/example.com
3.4.2) sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/

sample for "/etc/nginx/site-availables/example.com
=======================================================
server {
    listen 8080 default_server;
    listen [::]:8080 default_server;

    #root /var/www/laravel_example_com/public;
    index index.php index.html index.htm;

    server_name server_domain_or_IP;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}



======================================================== 

3.4.3) sudo nano /etc/nginx/nginx.conf 
3.4.4) server_names_hash_bucket_size 64; 
3.4.5) sudo service nginx restart 
-------------------------------------------------------------------------------------------------------------------------- 
4) Create Swap File (Optional) 
4.1) sudo fallocate -l 1G /swapfile 2) sudo mkswap /swapfile 3) sudo swapon /swapfile 

--------------------------------------------------------------------------------------------------------------------------
5) Install Composer and Laravel 5.1) cd ~ 
5.2) curl -sS https://getcomposer.org/installer | php 
5.3) sudo mv composer.phar /usr/local/bin/composer 
5.4) sudo composer create-project laravel/laravel /var/www/laravel 
5.5) sudo composer create-project laravel/laravel /var/www/laravel 4.2 
5.6) sudo chown -R :www-data /var/www/laravel 
5.7) sudo chmod -R 775 /var/www/laravel/app/storage 
5.8) http://server_domain_or_IP

--------------------------------------------------------------------------------------------------------------------------
4) Install phpmyadmin
4.1) sudo apt-get install phpmyadmin
4.2) che5.ck where is the site
cd /usr/share/nginx/html

4.3) sudo ln  -s /usr/share/phpmyadmin/ /usr/share/nginx/html
it will create a new link name “phpmyadmin” under /user/share/nginx/html
if you want to create custom phpmyadmin link, you can create by the following command
sudo ln  -s /usr/share/phpmyadmin_mycustom_name/ /usr/share/nginx/html
it will create a new link name “phpmyadmin_mycustom_name” under /user/share/nginx/html
And we can call it from browser by “http://ip_address/phpmyadmin; or “http://ip_address/phpmyadmin_mycustom_name;

4.3 ) sudo systemctl restart nginx

—————————————————————————————————————————————-

5) if there is “root /var/www/html” at /etc/nginx/sites-available/default, comment out it
eg ” # root /var/www/html ” and change server_name to
server_name localhost / ip_address;

—————————————————————————————————————————————

6) if “cgi.fix_pathinfo = 0” at /etc/php/7.0/fpm/php.ini, pls change back to original “cgi.fix_pathinfo = 1”
sudo systemctl restart nginx   OR sudo service nginx restart

 

7) If you used the new port for the virtual host, you have to allow that ports to access from globally ( outside )sudo ufw allow 8000/tcp

 

8) To Create a New User and Grant Permissions in MySQL

================================

Before we create and grant the permissions to the new user, we need to open the ( MySql port 3306 from firewall ).
To check firewall is active or inactive at unbuntu by the following command

ufw status

if reply ufw inactive, we need to open the ufw (firewall) by the following command

ufw enable

And then you can check which port are allow in our web server by the following command

ufw status
and it will reply all status.
If mysql is not allow, we need to allow it by the following command

ufw allow 3306/tcp

if port 3306 is not okay to access from the remote / other local pc, we need to change the mysql default por to ‘3360’ or as you wish.

to change the MySql port to ‘3360’,
go to the /etc/mysql
and edit the my.cnf

go to ‘[mysqld]’ part
chnage the default “bind_address” to “server_ip_address”
change the default “port” to “3360”

And then, restart the mysql service by the follwoing command
sudo service mysql restart

After it all, we need to check one thing
which ports are opening at our Web Server by the following

nmap localhost/ipaddress

========================================

login to mysql with root password
mysql -uroot -p
and then,

8.1) Let’s start by making a new user within the MySQL shell:

CREATE USER ‘newuser’@’localhost’ IDENTIFIED BY ‘password’;

8.2) provide the user with access to the information they will need

GRANT ALL PRIVILEGES ON * . * TO ‘newuser’@’localhost’;

8.3) Let’s start by making a new user within the MySQL shell:

CREATE USER ‘newuser’@’ip_address’ IDENTIFIED BY ‘password’;

8.4) provide the user with access to the information they will need

GRANT ALL PRIVILEGES ON * . * TO ‘newuser’@’ip_address’;

8.5) Reload all privileges

FLUSH PRIVILEGES;

 

Cheers

 

Setting up LEMP on Digital Ocean One Click Droplet to run the Laravel 5.2 web application

Setting up LEMP on Digital Ocean One Click Droplet to run the Laravel 5.2 web application

1) login with SSH
2) sudo apt-get update
3) sudo apt-get upgrade
3) copy the MySql admin password from /root/.digitalocean_password
4) run “mysql_secure_installation”
5) try to install composer
5.1) sudo apt-get install curl php5-cli git
5.2) curl -sS https://getcomposer.org/installer | php
5.3) sudo mv composer.phar /usr/local/bin/composer

6) go to /var/www
7) git download project folder
7.1) sudo chown -R :www-data /var/www/project_folder
7.2) sudo chmod -R 775 /var/www/project_folder/app/storage
7.3) sudo chmod -R 775 /var/www/project_folder/app/bootstrap
8) composer update –no-scripts
if you got error “allocate memeory case”
run the following commands to fix that issue
8.1) sudo fallocate -l 1G /swapfile
8.2) sudo mkswap /swapfile
8.3) sudo swapon /swapfile

9) Setting up / linking dns of the domain at z.com
10) login to z.com
11) go to related domain and added three dns for digital ocean
11.1) ns1.digitalocean.com
11.2) ns2.digitalocean.com
1.3) ns3.digitalocean.com

12) check at hosting (digital ocean droplet) with ssh
12.1) who is internalmedicinesocietymyanmar.com
and it will return digital ocean dns
13) create new domain setting at digital ocean
13.1) go to Networking at Digital Ocan
13.2) create new domain
13.3) Create One Domain at Digital Ocean by creating Records
===================================
A Record
Name = @
IP Address = 128.199.141.135
A Record
Name = acepluscoderepo.com
IP Address = 128.199.141.135
===================================
CNAME Record
Name = www
IP Address = example.com.
MX Record
Name = 1
IP Address = aspmx.l.google.com.
===================================
MX Record
Name = 5
IP Address = alt1.aspmx.l.google.com.
===================================
MX Record
Name = 5
IP Address = alt2.aspmx.l.google.com.
===================================
MX Record
Name = 10
IP Address = alt2.aspmx.l.google.com.
===================================
MX Record
Name = 10
IP Address = alt3.aspmx.l.google.com.
===================================
MX Record
Name = 10
IP Address = alt4.aspmx.l.google.com.
===================================
TXT Record
Name = example.com
IP Address = v=spf1 ip4:128.199.141.135 ~all
===================================
NS Record
Name = ns1.digitalocean.com.
===================================
NS Record
Name = ns2.digitalocean.com.
===================================
NS Record
Name = ns3.digitalocean.com.
===================================

14) After installed the nginx server at linux server, tried to send / testing email can send or not ?
Open terminal and type the following command to check it.

echo “HelloWorld” | mail -s “HelloWorld” test@gmail.com
test@gmail.com is “to” email address

Conclusion
Cheers

How to Install Laravel with an Nginx Web Server on Ubuntu 14.04

How to Install Laravel with an Nginx Web Server on Ubuntu 14.04

1) Install the Backend Components
1.1) sudo apt-get update
1.2) sudo apt-get upgrade
1.3) sudo apt-get install nginx php5-fpm php5-cli php5-mcrypt git
--------------------------------------------------------------------------------------------------------------------------
2) Modify the PHP Configuration
2.1) sudo nano /etc/php5/fpm/php.ini
2.2) cgi.fix_pathinfo=0 
2.3) sudo php5enmod mcrypt
2.4) sudo service php5-fpm restart
--------------------------------------------------------------------------------------------------------------------------
3) Configure Nginx and the Web Root
3.1) sudo mkdir -p /var/www/laravel
3.2) sudo nano /etc/nginx/sites-available/default
=======================================================
server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /var/www/laravel/public;
    index index.php index.html index.htm;

    server_name server_domain_or_IP;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}
=======================================================
3.3) sudo service nginx restart
3.4) if you want to setup 2 virtual block
3.4.1) sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/example.com
3.4.2) sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
2.4.3) sudo nano /etc/nginx/nginx.conf
2.4.4) server_names_hash_bucket_size 64;
2.4.5) sudo service nginx restart
--------------------------------------------------------------------------------------------------------------------------
4) Create Swap File (Optional)
4.1) sudo fallocate -l 1G /swapfile
2) sudo mkswap /swapfile
3) sudo swapon /swapfile
--------------------------------------------------------------------------------------------------------------------------
5) Install Composer and Laravel
5.1) cd ~
5.2) curl -sS https://getcomposer.org/installer | php
5.3) sudo mv composer.phar /usr/local/bin/composer
5.4) sudo composer create-project laravel/laravel /var/www/laravel
5.5) sudo composer create-project laravel/laravel /var/www/laravel 4.2
5.6) sudo chown -R :www-data /var/www/laravel
5.7) sudo chmod -R 775 /var/www/laravel/app/storage
5.8) http://server_domain_or_IP
-------------------------------------------------------------------------------------------------------------------------- 

6 )  After installed the nginx server at linux server, tried to send / testing email can send or not ?
Open terminal and type the following command to check it.

echo “HelloWorld” | mail -s “HelloWorld” test@gmail.com
test@gmail.com is “to” email address

 

------------------------------------------------------------------------------------------------------------------------------
Conclusion
------------------------------------------------------------------------------------------------------------------------------