Results: 30
move file to another server using scp
Moves
sql.zip
file to the location
/var/www/
of
use.ge
server using
root
user
scp sql.zip root@use.ge:/var/www/
We can use full path for the file that we want to move
scp /var/www/sql.zip root@use.ge:/var/www/
We can also use an IP address (instead of domain name) to specify the server that we want the file to move to
scp /var/www/sql.zip root@167.172.187.21:/var/www/
After the command execution the user is required to enter password of
root
user
create database backup using mysqldump
Creates
backup.sql
backup file of
some_db
database using
some_user
MySQL user. The database is located at
34.mysql.servage.net
server.
mysqldump -h 34.mysql.servage.net -u some_user -p some_db > backup.sql
Creates
backup.sql
backup file of
some_db
database with the same MySQL user but without
-h
flag. If the database is located on the same server (localhost)
-h
flag is not necessary to specify
mysqldump -u some_user -p some_db > backup.sql
If we want to include all the routines (procedures, functions), then we need to use flag
-R
mysqldump -u some_user -p some_db -R > backup.sql
If we want to export only one or several tables, then we should list tables after database name
mysqldump -u root -p sdtokens sdt_prices another_table > sdt_prices.sql
After running the command, we will be required to enter password of the
some_user
mysql user. After that, MySQL will create
backup.sql
file on the same location
MySQL command line
Activates MySQL console
mysql -u some_user -p
After running the command, we will be required to enter
password
of the mysql user
some_user
After that, MySQL
console
will be activated where we can run MySQL queries
move file to another directory
Moves
file.zip
file into
some_folder
folder
sudo mv file.zip some_folder/
In this example
file.zip
file and
some_folder
folder are at the same folder level (they have the same parent folder)
zip / unzip file or folder
Zips .sql file
db_backup.sql
and locates it to
public_html/
directory
zip -r db_backup.sql public_html/
Unzips the file
zipped.zip
and puts it to the current directory
unzip zipped.zip
delete folder
Removes unwanted folder
some_folder
sudo rm -r some_folder/
-r
means that it removes the directory with its all child directories
Copy all files and folders to another directory
Copies all files and folders from
source_dir
to
destination_dir
cp -r /home/user/source_dir/. /var/www/html/destination_dir/
-r
- copies recursively (with subfolders and files)
.
- copies all files and folders inside the folder
increase buffer size
The following issue:
...upstream sent too big header while reading response header from upstream...
Is fixed by adding these lines:
fastcgi_buffers 8 16k; # increase the buffer size for PHP-FTP
fastcgi_buffer_size 32k; # increase the buffer size for PHP-FTP
fastcgi_connect_timeout 60;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
To the site's configuration file:
server {
    listen 80;
    server_name pm.use.ge;
    root /var/www/pm.use.ge/public_html;

    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.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;

        include fastcgi_params;                                                                                                                                >        deny all;
    }
}
So that the final configuration file looks like this:
server {
    listen 80;
    server_name pm.use.ge;
    root /var/www/pm.use.ge/public_html;

    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.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;

        fastcgi_buffers 8 16k; # increase the buffer size for PHP-FTP
        fastcgi_buffer_size 32k; # increase the buffer size for PHP-FTP
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;

        include fastcgi_params;                                                                                                                                >        deny all;
    }
}
cURL Request example
Makes
cURL
request To
http://10.0.0.1/api/sms?PersonalID=19011111114
With headers: Channel-Name:
SMS
Authorization:
9s2EkGCDhv3eVwQY5BPSc
curl -H "Channel-Name: SMS" -H "Authorization: 9s2EkGCDhv3eVwQY5BPSc" "http://10.0.0.1/api/Sms?PersonalID=19011111114"
Export all table except ...
Exports all table from
dbname
except the two table:
table1
and
table2
mysqldump -u root -p --ignore-table=dbname.table1 --ignore-table=dbname.table2 dbname > dbname.sql
Results: 30