mysql -u [username] -p
making a new user within the MySQL shell
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
Therefore, the first thing to do is to provide the user with access to the information they will need.
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
Once you have finalized the permissions that you want to set up for your new users, always be sure to reload all the privileges.
FLUSH PRIVILEGES;
How To Grant Different User Permissions
Here is a short list of other common possible permissions that users can enjoy.
ALL PRIVILEGES- as we saw previously, this would allow a MySQL user full access to a designated database (or if no database is selected, global access across the system)
CREATE- allows them to create new tables or databases
DROP- allows them to them to delete tables or databases
DELETE- allows them to delete rows from tables
INSERT- allows them to insert rows into tables
SELECT- allows them to use the SELECT command to read through databases
UPDATE- allow them to update table rows
GRANT OPTION- allows them to grant or remove other users’ privileges
To provide a specific user with a permission, you can use this framework:
To GRANT ALL
privileges to a user, allowing that user full control over a specific database, use the following syntax:
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';
GRANT type_of_permission ON database_name.table_name TO 'username'@'localhost';
revoke a permission, the structure is almost identical to granting it:
REVOKE type_of_permission ON database_name.table_name FROM 'username'@'localhost';
review a user’s current permissions by running the following:
SHOW GRANTS FOR 'username'@'localhost';
delete databases with DROP, you can use DROP to delete a user altogether:
DROP USER 'username'@'localhost';
log out by typing:
quit
sudo apt update
sudo apt install git
You can confirm that you have installed Git correctly by running the following command:
git --version
sudo apt update
install openssh-server
sudo apt install openssh-server
Once the installation is complete, the SSH service will start automatically. You can verify that SSH is running by typing:
sudo systemctl status ssh
output
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-06-01 12:34:00 CEST; 9h ago
...
Ubuntu ships with a firewall configuration tool called UFW. If the firewall is enabled on your system, make sure to open the SSH port:
sudo ufw allow ssh
Connecting to the SSH Server #
To connect to your Ubuntu machine over LAN invoke the ssh command followed by the username and the IP address in the following format:
ssh username@ip_address
sudo apt update
Next, run the following command to install the required packages:
sudo apt install php-cli unzip
Make sure you’re in your home directory, then retrieve the installer using curl:
cd ~
curl -sS https://getcomposer.org/installer -o composer-setup.php
Next, we’ll verify that the downloaded installer matches the SHA-384 hash for the latest installer found on the Composer Public Keys / Signatures page. To facilitate the verification step, you can use the following command to programmatically obtain the latest hash from the Composer page and store it in a shell variable:
HASH=`curl -sS https://composer.github.io/installer.sig`
If you want to verify the obtained value, you can run:
echo $HASH
Now execute the following PHP code, as provided in the Composer download page, to verify that the installation script is safe to run:
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
You’ll see the following output:Installer verified
If the output says Installer corrupt, you’ll need to download the installation script again and double check that you’re using the correct hash. Then, repeat the verification process. When you have a verified installer, you can continue.
To install composer globally, use the following command which will download and install Composer as a system-wide command named composer, under /usr/local/bin:
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
You’ll see output similar to this:All settings correct for using Composer
Downloading...
Composer (version 1.10.5) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
To test your installation, run:
composer
sudo chown -R www-data.www-data /var/www/your_domain/storage
sudo chown -R www-data.www-data /var/www/your_domain/bootstrap/cache
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
create a new virtual host configuration file at /etc/nginx/sites-available
:
sudo nano /etc/nginx/sites-available/your_domain
The following configuration file contains the recommended settings for Laravel applications on Nginx:
server {
listen 80;
server_name server_domain_or_IP;
root /var/www/your_domain/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.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
Copy this content to your /etc/nginx/sites-available/travellist file and, if necessary, adjust the highlighted values to align with your own configuration. Save and close the file when you’re done editing.
To activate the new virtual host configuration file, create a symbolic link to travellist in sites-enabled:
sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/
To confirm that the configuration doesn’t contain any syntax errors, you can use:
sudo nginx -t
You should see output like this:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
To apply the changes, reload Nginx with:
sudo systemctl reload nginx
Now go to your browser and access the application using the server’s domain name or IP address, as defined by the server_name directive in your configuration file:
http://server_domain_or_IP
scp <file> <username>@<IP address or hostname>:<Destination>
The -r (recursive) option means to copy the whole folder and any sub-folders. You can also copy files the other way:
scp -r <file> OR <Folder> @IP address :<Destination>
scp file.txt remote_username@10.10.0.2:/remote/directory
The scp command syntax take the following form:
scp [OPTION] [user@]SRC_HOST:]file1 [user@]DEST_HOST:]file2
OPTION - scp options such as cipher, ssh configuration, ssh port, limit, recursive copy …etc.
[user@]SRC_HOST:]file1
- Source file.
[user@]DEST_HOST:]file2
- Destination file
scp provides a number of options that control every aspect of its behavior. The most widely used options are:
-P
- Specifies the remote host ssh port.
-p
- Preserves files modification and access times.
-q
- Use this option if you want to suppress the progress meter and non-error messages.
-C
- This option forces scp to compresses the data as it is sent to the destination machine.
-r
- This option tells scp to copy directories recursively.mysqldump -u username -p database_name > backup_file_name.sql
JS
is to use !!
directives:<script>
change_asset_category('{!! $category_values !!}');
</script>
The result will be:<script>
change_asset_category('{"version":"vers","patch_level":"patc","bcp_dr":"bcp\/d"}');
</script>