Permission issues with WordPress

sudo chown -R bitnami:daemon /opt/bitnami/apps/wordpress/htdocs/wp-content/cache
sudo find /opt/bitnami/apps/wordpress/htdocs/wp-content/cache -type f -exec chmod 664 {} \;
sudo find /opt/bitnami/apps/wordpress/htdocs/wp-content/cache -type d -exec chmod 775 {} \;
sudo chown bitnami:daemon /opt/bitnami/apps/wordpress/htdocs/wp-config.php
sudo chmod g+w /opt/bitnami/apps/wordpress/htdocs/wp-config.php
sudo chown bitnami:daemon /opt/bitnami/apps/wordpress/htdocs/.htaccess
sudo chmod g+w /opt/bitnami/apps/wordpress/htdocs/.htaccess

Sometimes you need to get your virtual host file, you can get them by :

a2query -s

or

apachectl -S

 

As you may have noticed, you have a block called Sidebar, to modify this SideBar, you just have to modify your theme.

My theme was done with Boostrap which implements the task,

Go in Appearance> Editor> Edit single.php

Before:

<section id="section-block" class="site-content">
    <div class="container">
        <div class="row">
            <!--Blog Posts-->
            <?php 
echo '<div class="col-md-'.( !is_active_sidebar( "sidebar-primary" ) ?"12" :"8" ).' col-xs-12">'; 
?>

After :

<section id="section-block" class="site-content">
    <div class="container">
        <div class="row">
            <!--Blog Posts-->
            <?php // echo '<div class="col-md-'.( !is_active_sidebar( "sidebar-primary" ) ?"12" :"8" ).' col-xs-12">'; ?>
                <?php echo '<div class="col-md-12 col-xs-12">'; ?>
<?php

/*
 * if ( is_active_sidebar( 'sidebar-primary' ) ): ?>
	<div class="col-md-4 col-sm-4 col-xs-12">
		<div class="sidebar" >
		<?php dynamic_sidebar( 'sidebar-primary' );	 ?>
		</div>
	</div>
<?php endif; 
*/
?> 

I put everything in the comment, so that the side is not displayed!

Log in as root and place yourself at the root of your site directory

# Add group www-data 
chown www-data:www-data -R wp-content/uploads/

# set permission 755
find . -type d -exec chmod 755 {} \;

# set permission 644
find . -type f -exec chmod 644 {} \;


Open the file : wp-config.php

Find and edit this line, or add it if it does not exist :

define('FS_METHOD','direct');

 

To connect to MySQL

mysql -u root -p

Create a MysSQL Datatase

CREATE DATABASE mydatabase;

or Create a MySQL database character with charset UTF-8

CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_general_ci;

Everything is fine :

mysql> CREATE DATABASE webmarketing_en CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.00 sec)

Exit

exit

 

Laravel >= 5.4

php artisan cache:clear 
chmod -R 777 storage/
composer dump-autoload

Laravel < 5.4

php artisan cache:clear 
chmod -R 777 app/storage 
composer dump-autoload

 

 

To fix this error you should use this command :

chmod 777 storage/framework/sessions/

For twig

base.html.twig :

<p{{ 'message'|trans }}</p>

Create or update your files translation :

# tempate from app/Resources
php bin/console translation:update --dump-messages --force fr
php bin/console translation:update --dump-messages --force en

# template from AppBundle/Resources
php bin/console translation:update --dump-messages --force fr AppBundle
php bin/console translation:update --dump-messages --force en AppBundle

 

How to add expire header on Ubuntu with Apache2 :

Edit your httpd.conf

  1. The module ‘mod_expires’ must be activated
  2. Add the new configuration

1) Activate mod_expires

sudo a2enmod expires
sudo /etc/init.d/apache2 restart

2) Add new lines on your httpd.conf

nano /etc/apache2/apache2.conf

Then add these lines at the end

ExpiresActive On
ExpiresByType image/gif “access 1 month”
ExpiresByType image/jpg “access 1 month”
ExpiresByType image/jpeg “access 1 month”
ExpiresByType image/png “access 1 month”
ExpiresByType text/css “access 1 month”
ExpiresByType text/js “access 1 week”
ExpiresByType application/javascript “access 1 week”

the restart

sudo /etc/init.d/apache2 restart

Example :