CS Forward

Month: December 2020 Page 1 of 3

Steps to Send Email from WordPress with SMTP

Steps

1. You will not be able to send emails when you install WordPress on Google Cloud Platform. To fix it, go to your WordPress’s wp-config.php file and add the following SMTP email settings:

define(‘FORCE_SSL_ADMIN’,false);
define(‘SMTP_USER’, ‘youremail@gmail.com’);
define(‘SMTP_PASS’, ‘yourpassword’);
define(‘SMTP_HOST’, ‘smtp.gmail.com’);
define(‘SMTP_FROM’, ‘youremail@gmail.com’);
define(‘SMTP_NAME’, ‘yourname’);
define(‘SMTP_PORT’, ‘587’);
define(‘SMTP_SECURE’, ‘tls’);
define(‘SMTP_AUTH’, true);

 

2. Go to WordPress admin panel and browse Appearance/Theme Editor and edit functions.php file of your theme and add the following:

add_action(‘phpmailer_init’,’my_phpmailer_example’);
function my_phpmailer_example($phpmailer){
$phpmailer->isSMTP();
$phpmailer->Host = SMTP_HOST;
$phpmailer->SMTPAuth = SMTP_AUTH;
$phpmailer->Port = SMTP_PORT;
$phpmailer->Username = SMTP_USER;
$phpmailer->Password = SMTP_PASS;
$phpmailer->SMTPSecure = SMTP_SECURE;
$phpmailer->From = SMTP_FROM;
$phpmailer->FromName = SMTP_NAME;
}

 

Credits

https://www.youtube.com/watch?v=eTqrw3bgfUE&ab_channel=TonyTeachesTech

Steps to Install a Free SSL Certificate on Google Cloud Platform

Steps

1. Install certbot:

sudo apt-get install certbot python3-certbot-apache

 

2. Run it:

sudo certbot –apache

 

3. Answer the questions and done. Make sure you also update your url with https on the WordPress settings.

 

Credits

https://www.youtube.com/watch?v=uSm3xepvUNM&ab_channel=TonyTeachesTech

Steps to Host a Free WordPress Website on Google Cloud Platform

Create a Micro VM Instance on Google Cloud Platform

1. Go to https://console.cloud.google.com/ and create a micro VM instance.

2. Machine type: f1-micro (1 vCPU, 0.6 GB memory)

3. Zone: us-central1-a

4. Boot Disk: Ubuntu XX.XX LTS

5. Disk size: 30GB

6. Please see this info “Your first 744 hours of f1-micro instance usage are free this month.” on the right side of the screen.

7. Allow http and https traffic.

8. And create.

 

Create a Swap File

1. After creating the VM, SSH into it and firstly do this to improve the performance of your micro instance:

sudo fallocate -l 1G /swapfile

 

2. Do dd to wipe this file out:

sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576

 

3. Make it readable only by root:

sudo chmod 600 /swapfile

 

4. Now we can make the swap:

sudo mkswap /swapfile

 

5. Turn it on:

sudo swapon /swapfile

 

6. Make sure to open the following file and see the defaults are 0 0:

sudo nano /etc/fstab

 

7. Make sure you did not do any misspellings:

sudo mount -a

 

8. Do the following and see your new Swp is 1024MB:

cd

htop

 

LAMP Stack Installation

1. Use tasksel to install Apache, MYSQL, and PHP:

sudo apt install tasksel

 

2. Install the lamp server:

sudo tasksel install lamp-server

 

3. To meet the all requirements, install the rest of our dependencies:

sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc

 

Domain Name Configuration

1. Know your website’s IP:

curl ifconfig.me

 

2. Let’s assume that you purchased a domain name. Add your site’s IP and domain name to the following place at the bottom and save it:

XX.XXX.XXX.XX sitename.com

 

Apache Configuration

1. To setup our domain name in our Apache configuration file, do:

cd /etc/apache2/sites-available/

ll

 

2. We have the default site. We have to make a copy of it and give it a name like “sitename.com.conf”:

sudo cp 000-default.conf sitename.com.conf

 

3. You can do the following to get superuser abilities to run as root (optional):

sudo su

 

4. After creating “sitename.com.conf” file, do:

cd /etc/apache2/sites-available/

sudo nano sitename.com.conf

 

5. Add the following at the top:

<Directory C:\xampp\htdocs>

        Options Indexes FollowSymLinks MultiViews

        AllowOverride All

        Require all granted

</Directory>

 

6. If you are working on an nginx server it should look like this:

upstream example-php-handler {

server unix:/var/run/php/php7.4-fpm.sock;

}

server {

listen 80;

server_name sitename.com www.sitename.com;

root /var/www/wordpress;

index index.php;

location / {

try_files $uri $uri/ /index.php?$args;

}

location ~ \.php$ {

include snippets/fastcgi-php.conf;

fastcgi_pass example-php-handler;

}

}

 

7. And change/add the following:

        ServerName sitename.com

        ServerAlias www.sitename.com

 

8. In order to disable the default site do the following:

a2dissite 000-default.conf

 

9. In order to set your new website as the default site, do the following:

a2ensite sitename.com.conf

 

10. Just reload Apache2 by doing:

systemctl reload apache2

 

MySQL Configuration

1. Create a database and grant permissions to the user. Make sure you remember your database name, user name, and password:

mysql -u root

CREATE DATABASE databasename;

GRANT ALL ON databasename.* TO ‘username’ IDENTIFIED BY ‘password’;

quit

 

2. Secure the installation and answer all the questions until see ‘All done!’:

mysql_secure_installation

 

PHP Configuration

1. Go to the PHP directory and edit ‘php.ini’:

cd /etc/php/7.X/apache2

sudo nano php.ini

 

2. Do the following:

max_input_time = 30

upload_max_file_size = 20M

post_max_size = 21M

 

3. Save and exit.

 

Install WordPress

1. Go to the root:

cd

 

2. Move index.html file to a lower directory:

cd C:\xampp\htdocs

ll

mv intex.html

ll

 

3. Get the latest WordPress:

wget https://www.wordpress.org/latest.tar.gz

 

4. Extract the files:

tar -xvf latest.tar.gz

 

5. We want all files to be in the lower directory which is the html directory:

cd wordpress/

mv * ..

cd ..

ll

 

6. Remove wordpress folder:

rm wordpress/ -r

 

7. Remove latest.tar.gz file:

rm latest.tar.gz

 

8. Go to your website and install your WordPress.

 

Tuning

1. Open and modify the following:

nano /etc/apache2/mods-enabled/mpm-prefork.conf

 

2. Do the following and save:

StartServers 1

MinSpareServers 2

MaxSpareServers 5

MaxRequestWorkers 10

MaxConnectionsPerChild 1000

 

3. Install the following script:

cd

wget https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl

 

4. Make it writeable:

chmod +x apache2buddy.pl

 

5. Run the script and make the recommended changes if necessary:

./apache2buddy.pl

 

Credits

https://christitus.com/wordpress-google-cloud-platform/

https://www.youtube.com/watch?v=vIJdypOqlL4&ab_channel=ChrisTitusTech

https://www.youtube.com/watch?v=f56PG7QxjFI&ab_channel=TonyTeachesTech

How to Stop Auto-Embedding Links in WordPress

If you paste a link from certain sites, WordPress will embed them automatically into your post or page. This happens in both Gutenberg and Classic Editor. You can completely disable automatic embeds in WordPress, but there is a workaround to prevent this only for specific links.

 

Steps for Classic Editor

1. Highlight the link you pasted into the editor.

2. Click “Insert/edit link” button on the toolbar and check the “Open link in a new tab” checkbox.

3. Optionally, change the Link Text if you don’t want a plain link to be displayed.

 

Credits

https://themeskills.com/prevent-auto-embedding-specific-links-wordpress/

Connect A Bluetooth Speaker to Raspberry Pi

Steps

1. Install PulseAudio and bluetooth module:

sudo apt-get install pulseaudio
sudo apt-get install pavucontrol paprefs
sudo apt-get install pulseaudio-module-bluetooth

 

2. Connect bluetooth speaker and configure:

bluetoothctl
power on
agent on
default-agent
quit
sudo killall bluealsa
pulseaudio -k
pulseaudio –start
pactl unload-module module-bluetooth-discover
pactl load-module module-bluetooth-discover

 

3. Turn your bluetooth speaker on and disconnect from other devices:

bluetoothctl
scan on

 

4. Wait until Raspberry Pi finds the target bluetooth speaker, and note the MAC address such as “XX:XX:XX:XX:XX:XX”:

scan off

 

5. Replace “XX:XX:XX:XX:XX:XX” with your address:

pair XX:XX:XX:XX:XX:XX
trust XX:XX:XX:XX:XX:XX
connect XX:XX:XX:XX:XX:XX

 

6. Confirm it is recognized as a sound device:

pacmd list-cards

 

7. You should see your device address like “XX:XX:XX:XX:XX:XX” somewhere:

pacmd set-card-profile bluez_card.XX_XX_XX_XX_XX_XX a2dp_sink
pacmd set-default-sink bluez_sink.XX_XX_XX_XX_XX_XX.a2dp_sink

 

8. Edit “start-pulseaudio-x11” script to connect bluetooth speaker on startup:

sudo nano /usr/bin/start-pulseaudio-x11

 

9. Find the block of commands below:

if [ x”$SESSION_MANAGER” != x ] ; then
/usr/bin/pactl load-module module-x11-xsmp “display=$DISPLAY session_manager=$SESSION_MANAGER” > /dev/null
fi

 

10. Add the following lines of commands right after it (this will let you get sound from your speaker):

/usr/bin/pactl unload-module module-bluetooth-discover
/usr/bin/pactl load-module module-bluetooth-discover
sudo killall bluealsa
pulseaudio –start
bluetoothctl << EOF
connect XX:XX:XX:XX:XX:XX
EOF

 

11. Save the file by pressing Ctrl + X then Y and finally ENTER.

12. Modify “.bashrc” file.

sudo nano ~/.bashrc

 

13. Add the following lines of commands at the bottom:

/usr/bin/pactl unload-module module-bluetooth-discover
/usr/bin/pactl load-module module-bluetooth-discover
sudo killall bluealsa
pulseaudio –start
bluetoothctl << EOF
connect XX:XX:XX:XX:XX:XX
EOF

 

14. Save the file by pressing Ctrl + X then Y and finally ENTER. Then restart the Raspberry Pi:

sudo reboot

 

Credits

https://www.funincomplete.com/how-to-make-raspberry-pi-speak/

Page 1 of 3

Powered by WordPress & Theme by Anders Norén