Sign Up

welcome

Already have an account? Sign In

Sign In

welcome

Sign Up
Login with Google

Don't have account, Sign Up Here
Sign In Sign Up

letsrectify

letsrectify
  • Home
  • About Us
  • Contact Us
  • Jobs
Ask a Question
  • Questions & Answers

Questions & Answers

aman
Asked: 31-07-24
Answer

To downgrade PHP from version 7.4 to 7.3 on an EC2 Ubuntu instance, you need to follow these steps:

  • 0

Step-by-Step Guide

Connect to Your EC2 Instance via SSH

 

Connect to your EC2 instance using SSH. Replace /path/to/your-key.pem with the path to your SSH key, and your-ec2-instance-public-dns with the public DNS of your EC2 instance.

 

ssh -i /path/to/your-key.pem ubuntu@your-ec2-instance-public-dns

Remove the Current PHP Version

 

Uninstall the current PHP version (7.4 in this case).

 

sudo apt-get purge php7.4*

sudo apt-get autoremove

sudo apt-get autoclean

Add the PHP 7.3 Repository

 

Add the repository for PHP 7.3 to your package manager.

 

sudo add-apt-repository ppa:ondrej/php

sudo apt-get update

Install PHP 7.3

 

Install PHP 7.3 and the necessary PHP extensions.

 

sudo apt-get install php7.3

sudo apt-get install php7.3-cli php7.3-fpm php7.3-json php7.3-common php7.3-mysql php7.3-zip php7.3-gd php7.3-mbstring php7.3-curl php7.3-xml php7.3-bcmath php7.3-json

Update the PHP Command Alternatives

 

If you have multiple PHP versions installed, update the alternatives to set PHP 7.3 as the default version.

 

sudo update-alternatives --set php /usr/bin/php7.3

sudo update-alternatives --set phar /usr/bin/phar7.3

sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.3

sudo update-alternatives --set phpize /usr/bin/phpize7.3

sudo update-alternatives --set php-config /usr/bin/php-config7.3

Restart the Web Server

 

Restart your web server (Apache or Nginx) to apply the changes.

 

For Apache:

 

sudo systemctl restart apache2

For Nginx:

If you are using PHP-FPM with Nginx, restart PHP-FPM and Nginx:

 

sudo systemctl restart php7.3-fpm

sudo systemctl restart nginx

Share
  • Facebook

Questions & Answers

aman
Asked: 31-07-24
Answer

If the asset function in Laravel is not working after uploading your project to an EC2 Ubuntu server, it might be due to several reasons including incorrect configuration, incorrect file permissions, or issues with your web server setup. Here’s a comprehensive guide to troubleshoot and resolve this issue:

  • 0

Step-by-Step Troubleshooting Guide

Check Laravel Environment Configuration

 

Ensure that your environment configuration is set correctly. The APP_URL in your .env file should match the URL of your server.

 

plaintext

 

APP_URL=http://your-ec2-instance-public-dns-or-domain

Clear Laravel Cache

 

After making changes to your .env file or configuration, you need to clear the cache.

 

 

cd /var/www/html/your-laravel-project

php artisan config:cache

php artisan route:cache

php artisan view:clear

php artisan cache:clear

Set Correct Permissions

 

Ensure that the public directory and its contents have the correct permissions.

 

 

sudo chown -R www-data:www-data /var/www/html/your-laravel-project/public

sudo chmod -R 755 /var/www/html/your-laravel-project/public

Ensure Web Server Configuration

 

Ensure that your web server is configured to serve the public directory as the document root.

 

For Apache:

Edit the default Apache configuration file or create a new virtual host file:

 

 

sudo nano /etc/apache2/sites-available/000-default.conf

Update the <VirtualHost> block to look like this:

 

apache

 

<VirtualHost *:80>

   ServerAdmin webmaster@localhost

   DocumentRoot /var/www/html/your-laravel-project/public

 

   <Directory /var/www/html/your-laravel-project/public>

       Options Indexes FollowSymLinks

       AllowOverride All

       Require all granted

   </Directory>

 

   ErrorLog ${APACHE_LOG_DIR}/error.log

   CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Enable the mod_rewrite module and restart Apache:

 

 

sudo a2enmod rewrite

sudo systemctl restart apache2

For Nginx:

Edit the Nginx configuration file:

 

 

sudo nano /etc/nginx/sites-available/default

Update the server block to look like this:

 

nginx

 

server {

   listen 80;

   server_name your-domain.com;

 

   root /var/www/html/your-laravel-project/public;

 

   index index.php index.html index.htm;

 

   location / {

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

   }

 

   location ~ \.php$ {

       include snippets/fastcgi-php.conf;

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

       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

       include fastcgi_params;

   }

 

   location ~ /\.ht {

       deny all;

   }

}

Restart Nginx:

 

 

sudo systemctl restart nginx

Check File Paths in Blade Templates

 

Ensure that you are using the asset function correctly in your Blade templates.

 

html

 

<link href="{{ asset('css/app.css') }}" rel="stylesheet">

<script src="{{ asset('js/app.js') }}" defer></script>

Verify Assets are in the Correct Location

 

Ensure that the assets (CSS, JS, images) are located in the public directory of your Laravel project.

 

 

ls -l /var/www/html/your-laravel-project/public/css

ls -l /var/www/html/your-laravel-project/public/js

Share
  • Facebook

Questions & Answers

aman
Asked: 31-07-24
Answer

The "Permission denied" error when trying to save an edited file in WinSCP indicates that your current user does not have the required permissions to modify the files or directories. Here are steps to resolve this issue:

  • 0

Step-by-Step Guide

Connect to Your EC2 Instance via SSH

 

Connect to your EC2 instance using SSH to change the permissions.

 

ssh -i /path/to/your-key.pem ubuntu@your-ec2-instance-public-dns

Elevate Permissions for Your User Temporarily

 

If you're logged in as ubuntu or another user, you might need to temporarily elevate the permissions to edit files.

 

sudo -i

Change Ownership and Permissions

 

Change the ownership of the files to your current user (assuming ubuntu) and grant necessary permissions. Be careful with chmod 777 as it gives full permissions to everyone.

 

sudo chown -R ubuntu:ubuntu /var/www/html/your-laravel-project

sudo chmod -R 755 /var/www/html/your-laravel-project

Alternatively, if you are using the web server user (www-data), ensure that your SSH user has appropriate permissions to edit files:

 

sudo chown -R www-data:www-data /var/www/html/your-laravel-project

sudo chmod -R 775 /var/www/html/your-laravel-project

Add Your User to the Web Server Group

 

Adding your user to the www-data group can help if you want to keep the ownership to www-data.

 

sudo usermod -a -G www-data ubuntu

sudo chmod -R 775 /var/www/html/your-laravel-project

sudo chown -R www-data:www-data /var/www/html/your-laravel-project

After this, you need to log out and log back in for the group changes to take effect.

 

Using WinSCP with Elevated Permissions

If you still face issues, you can use the "SCP/Shell" option in WinSCP to execute commands as sudo. Here’s how:

 

Open WinSCP and go to the "Advanced Site Settings".

Under "Environment" -> "SCP/Shell", set the shell to sudo su -.

This will allow you to execute commands with sudo permissions.

 

Example Commands to Execute

 

# Connect to your EC2 instance

ssh -i /path/to/your-key.pem ubuntu@your-ec2-instance-public-dns

 

# Elevate permissions

sudo -i

 

# Change ownership to ubuntu user

sudo chown -R ubuntu:ubuntu /var/www/html/your-laravel-project

 

# Set permissions to 755

sudo chmod -R 755 /var/www/html/your-laravel-project

 

# Alternatively, if using www-data

sudo chown -R www-data:www-data /var/www/html/your-laravel-project

sudo chmod -R 775 /var/www/html/your-laravel-project

 

# Add your user to the www-data group

sudo usermod -a -G www-data ubuntu

sudo chmod -R 775 /var/www/html/your-laravel-project

sudo chown -R www-data:www-data /var/www/html/your-laravel-project

https://www.letsrectify.com/answer/ODMx/letsrectify" data-action="share/whatsapp/share"> Share
  • Facebook
  • ‹
  • 1
  • 2
  • ...
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • ...
  • 292
  • 293
  • ›
Ask A Question
  • To downgrade PHP from version 7.4 to 7.3 on an EC2 Ubuntu instance, you need to follow these steps:

    • 7 Answers
  • If the asset function in Laravel is not working after uploading your project to an EC2 Ubuntu server, it might be due to several reasons including incorrect configuration, incorrect file permissions, or issues with your web server setup. Here’s a comprehensive guide to troubleshoot and resolve this issue:

    • 7 Answers
  • The "Permission denied" error when trying to save an edited file in WinSCP indicates that your current user does not have the required permissions to modify the files or directories. Here are steps to resolve this issue:

    • 7 Answers
letsrectify

Categories

  • Technology
  • Food
  • Health
  • Sports
  • Science
  • Politics
  • Marketing

Policies

  • Terms & Conditions
  • Privacy Policy

About Us

  • About Us
  • Contact Us
  • Feedback

© 2025 All Rights Reserved by
Letsrectify.com