Monday 25 March 2024

Word Press Multisite on AWS instance cannot login with default password

 

Word Press Multisite on AWS instance cannot login with default password after setting a static IP ?

Try this

Login to the shell from AWS instance


cd  /opt/bitnami/wp-cli/bin 

sudo wp user list

you will see you admin user , example :

sudo wp user list

+----+------------+--------------+------------------+---------------------+---------------+

| ID | user_login | display_name | user_email       | user_registered     | roles         |

+----+------------+--------------+------------------+---------------------+---------------+

| 1  | user       | user         | user@example.com | 2024-03-22 10:38:41 | administrator |

+----+------------+--------------+------------------+---------------------+---------------+


update the password for the user ID using 

sudo wp user update 1 --user_pass=<newpasswordhere>

You should see : Success: Updated user 1.

Thats it, try logging in using the new password




Wednesday 13 March 2024

python error ModuleNotFoundError: No module named 'requests'

 

Python error 

line 1, in <module>

    import requests

ModuleNotFoundError: No module named 'requests'


Solution:

Install requests via pip


C:\Users\User>pip install requests

Collecting requests

  Downloading requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)



Still get the error after installation?

If you are using soemthing like pyCharm you would have to close and restart

It scans and reads install packages on restart

Do the same if you see the error on other modules like scrapy and pandas



Wednesday 6 March 2024

Create a simple Django web application 


Application includes a single textbox. When the user enters text, the application will calculate the number of characters and display the result on the same webpage.


Create a Django Project and App: 

First, create a new Django project and a new app within the project. 


Let’s call the app character_counter.

Create a View and Template:

In your views.py, create a view that handles the form submission and calculates the character count.

Create an HTML template (index.html) to display the form and the result.

Define Your View and Template:


Python

# character_counter/views.py

from django.shortcuts import render


def character_count(request):

    if request.method == 'POST':

        user_text = request.POST.get('user_text', '')

        char_count = len(user_text)

        return render(request, 'character_counter/index.html', {'char_count': char_count})

    return render(request, 'character_counter/index.html')





HTML

<!-- character_counter/templates/character_counter/index.html -->

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>Character Counter</title>

</head>

<body>

    <h1>Character Counter</h1>

    <form method="post">

        {% csrf_token %}

        <input type="text" name="user_text" placeholder="Enter text">

        <input type="submit" value="Count Characters">

    </form>

    {% if char_count %}

        <p>Character count: {{ char_count }}</p>

    {% endif %}

</body>

</html>




URL Configuration: Set up the URL pattern in your app’s urls.py:


Python

# character_counter/urls.py

from django.urls import path

from . import views


urlpatterns = [

    path('', views.character_count, name='character_count'),

]


Run the Development Server: Run python manage.py runserver to start the development server. 


Visit http://localhost:8000/ to see the character counter in action.

Create a Django Project On Mac or Linux

1. install python3 - download from python website 
2. install vertual env : 
sudo pip install virtualenv 
3. create a project directory : 
mkdir djproject 
4. create a virtual environment cd djproject virtualenv myvirtenv -p python3 
5. activate the virtual environment : source myvirtenv/bin/activate
 
6. install Django inside the virtual environment
 pip install Django (installs the latest version) 
7. start the project, creates the project files 
django-admin startproject djproject
8. start the webserver 
python manage.py runserver
 
9. Launch the webpage on thedefault port 
http://127.0.0.1:8000 
you should see django up an running!

Wednesday 25 August 2010

cannot restore segment prot after reloc: Permission denied

Error on CentOS 5 while starting a proccess

cannot restore segment prot after reloc: Permission denied

Noticed while running networker 7.6 on Centos 5

Resolution:

Centos has SELinux enabled by default and set to 'enforcing'

temporarily disable by running: /usr/sbin/setenforce 0

you can change SELinux config at /etc/selinux/config

Tuesday 15 June 2010

DIsable firewall on SuSE 11

The firewall is enabled by default , to stop it

/etc/init.d/SuSEfirewall2_setup stop

Unable to SSH to SuSE 11

Check if sshd is running , if not start it up

/etc.init.d/sshd status
/etc.init.d/sshd start

The firewall is enabled by default , you may have to stop/reconfigure it

/etc/init.d/SuSEfirewall2_setup stop

Word Press Multisite on AWS instance cannot login with default password

  Word Press Multisite on AWS instance cannot login with default password after setting a static IP ? Try this Login to the shell from AWS i...