How to install pelican on a server to create mywebsite? - python

I want to install pelican to create my online website. However, to install it on OVH server where my website is hosted, I need to run command lines but i can only host files and folders in /www/ on my server. How can I install pelican in this case ?

There's no need to install Pelican on the server; it's meant to be installed on your local computer. Once installed locally, you generate your site and then transmit the output to your server. Many folks (myself included) use rsync to upload the generated HTML/CSS/JS to the server from which the site is actually served (OVH, in your case).
Once Pelican has been installed locally, you can run pelican-quickstart to create a skeleton project, answering the relevant questions for SSH/rsync. If you install Fabric as well, you can then edit the provided fabfile.py and run fab publish to automatically generate your site and transmit it to /var/www/yoursite/.

Related

Travis CI only uploads empty files from the build script

I'm currently trying to set up a documentation project on Travis CI. The build script uses the mkdocs library to generate markdown files to HTML files. I've tried now many hours to automate the deploy process with Travis CI. It should generate the files directly on Travis CI and upload it then to an FTP server.
What I've tried
So I had committed this .travis.yml file to my Github repo.
language: python
python:
- "2.7"
env:
global:
#FTP_USERNAME
- secure: "N9knL6LsuiZ....."
#FTP_PASSWORD
- secure: "NrRpwCeay7Y0s....."
install:
- pip install mkdocs
- mkdocs --version
script:
- mkdocs build
after_success:
- find documentation -type f -exec curl -u "${FTP_USERNAME}:${FTP_PASSWORD}" --verbose --progress-bar --ftp-create-dirs --max-time 30 -T {} ftp://my.ftp-server.com/{} \;
The mkdocs build script does output the generated files in the root folder "documentation". Actually this code works unless the directory on the FTP server does not exist.
What does not work
I have tried the same code locally (just ran the after_success command) and there it uploads the files correctly with content. When Travis-CI now starts uploading the files to my FTP server, then it begins with the transfer but does not end it until the timeout exception will be thrown. When I check the files on the server, then it only has created empty files.
Can maybe someone help me why this problem occurs?
I have found now something interesting on the Travis CI Blog. They are describing, that the FTP protocol is no longer supported on a normal Travis CI environment. The fact that it uses different NATs on the deployment, makes the FTP server unsure about the requests and it will block the content requests.
Solution
Therefore you have to use SFTP or a VPN connection to your FTP server in order to deploy the files on Travis CI. But there are also a lot of other CI/CD solutions. I personally use now Github Actions, which works very well. There is even an FTP Upload module for that.
This might be the reason why it does not upload the files because it writes it somewhere where the FTP server already has blocked the request.

Azure deployment not installing Python packages listed in requirements.txt

This is my first experience deploying a Flask web app to Azure.
I followed this tutorial.
The default demo app they have works fine for me.
Afterwards, I pushed my Flask app via git. The log shows deployment was successful. However, when I browse the hosted app via link provided in "Application Properties", I get a 500 error as follows:
The page cannot be displayed because an internal server error has
occurred.
Most likely causes: IIS received the request; however, an internal
error occurred during the processing of the request. The root cause of
this error depends on which module handles the request and what was
happening in the worker process when this error occurred. IIS was not
able to access the web.config file for the Web site or application.
This can occur if the NTFS permissions are set incorrectly. IIS was
not able to process configuration for the Web site or application. The
authenticated user does not have permission to use this DLL. The
request is mapped to a managed handler but the .NET Extensibility
Feature is not installed.
The only off-base thing I can see by browsing the wwwroot via KUDU is that none of the packages I have installed in my local virtual environment are installed on Azure despite the existence of the "requirements.txt" file in wwwroot.
My understanding is that Azure would pip install any non existent package that it finds in the requirements.txt upon GIT successful push. But it doesn't seem to be happening for me.
Am I doing something wrong and the missing packages is just a symptom or could it be the cause the issue?
Notes:
My Flask app works fine locally (linux) and on a 3rd party VPS
I redeployed several times starting from scratch to no avail (I use local GIT method)
I cloned the Azure Flask demo app locally, changed just the app folder and pushed back to Azure, yet no success.
Azure is set to Python 2.7 same as my virtual env locally
As suggested in the tutorial linked above, I deleted the "env" folder and redeployed to trick Azure to reinstall the virtual env. It did but with its own default packages not the one in my requirements.txt.
My requirements.txt has the following:
bcrypt==3.1.0 cffi==1.7.0 click==6.6 Flask==0.11.1 Flask-Bcrypt==0.7.1
Flask-Login==0.3.2 Flask-SQLAlchemy==2.1 Flask-WTF==0.12
itsdangerous==0.24 Jinja2==2.8 MarkupSafe==0.23 pycparser==2.14
PyMySQL==0.7.7 python-http-client==1.2.3 six==1.10.0 smtpapi==0.3.1
SQLAlchemy==1.0.14 Werkzeug==0.11.10 WTForms==2.1
As Azure Web Apps will run a deploy.cmd script as the deployment task to control which commands or tasks will be run during the deployment.
You can use the command of Azure-CLI azure site deploymentscript --python to get the python applications' deployment task script.
And you can find the following script in this deploy.cmd sciprt:
IF NOT EXIST "%DEPLOYMENT_TARGET%\requirements.txt" goto postPython
IF EXIST "%DEPLOYMENT_TARGET%\.skipPythonDeployment" goto postPython
echo Detected requirements.txt. You can skip Python specific steps with a .skipPythonDeployment file.
So the .skipPythonDeployment will skip all the following steps in deployment task, including creating virtual environment.
You can try to remove .skipPythonDeployment from your application, and try again.
Additionally, please refer to https://github.com/projectkudu/kudu/wiki/Custom-Deployment-Script for more info.

Moving Django 1.6 to new server

I'm wondering what steps are evolved in moving a django project to a new server.
basicly i'm completely new to Django and have a few questions. The server it is on is now is not stable so I need to act fast. I did not build the app that is there but have pulled down the www folder from the root server. The server is running centOS.
Questions.
is Django backwards compatible or will I need to insure that the same version is installed?
Apart from moving the files what other steps are involved in running the app?
Will I need to use centOS or will any linux server do?
I have a database cluster of PostgreSQL ready to go also.
Start with the docs here - this will give you a good overview.
To your specific questions:
1/ Django is not backwards compatible. You should install 1.6.x. Likely, there's a requirements.txt file in the root directory of your app. On your new server, install pip and then pip install -r requirements.txt will install your dependencies. I would personally use virtualenvwrapper to manage your dependencies on the server
2/ Check the docs, but the main steps are:
Choose a web server. I personally use nginx. You'll need to setup your nginx.conf.
Choose a Python WSGI HTTP Server - I use gunicorn. You'll also need to configure this. This tutorial is a great place to start.
If you use the DigitalOcean tutorial above, any linux server will do. Last, you'll need to upload your Postgres database to the server but sounds like you're able to do that.
3/ You will need to edit your settings.py of the Django project and update certain variables.
If you're changing your database, as well as the app deployment, you'll need to edit the database connection, run ./manage.py syncdb and ./manage.py migrate (if you're using South) to set up the database schema.
It's also recommended to change the SECRET_KEY between deployments.
If you're deploying on a different hosts, you'll need to edit ALLOWED_HOSTS appropriately for your new deployment as well.
Good luck!

How to install Django on shared hosting server with Plesk?

My question is: how can I install DJANGO on a shared hosting account?
My hosting supports PYTHON 2.4. After copying the files to the ftp server, what is the next step? On Django site it says you need to to this:
tar xzvf Django-1.3.tar.gz
cd Django-1.3
sudo python setup.py install
But I dont see any command shell on my plesk account admin page. Now, there is an option on my hosting provider that gives what they call "SSH chrooted shell access with a limited command set" for €60 euros more.
Do I need to get that shell access upgrade for Django/PYTHON development?
Thanks very much!
They probably wouldn't give you root access with your SSH access anyway. You can "install" a python library without root access by just copying it into the same directory as your application. Extract the contents of Django-1.3.tar.gz on your computer (not the shared server), find the folder inside named "django" and upload this to the ftp server in the folder containing your Django project.
You could use a "django ready" hoster (eg google apps)!
here's an collection of links
https://code.djangoproject.com/wiki/DjangoFriendlyWebHosts
I have been wondering the same thing. Thinking it would be easier to simply install Django on local machine (if you’re the only developer). For quick and easy setup, use Bitnami Django. If there are others working with you or you needed remote access, can open port to your local machine to make it accessible via the Internet (e.g. noip.com). If project is getting big, then it would be worth investing your time setting up or finding a proper host.

Deploying Django: How do you do it?

I have tried following guides like this one but it just didnt work for me.
So my question is this: What is a good guide for deploying Django, and how do you deploy your Django.
I keep hearing that capastrano is pretty nifty to use, but i have no idea as to how to work it or what it does (apart from automation of deploying code), or even if i want/need to use it or not.
mod_wsgi in combination with a virtualenv for all the dependencies, a mercurial checkout into the virtualenv and a fabric recipe to check out the changes on the server.
I wrote an article about my usual workflow: Deploying Python Web Applications. Hope that helps.
I have had success with mod_wsgi
In my previous work we had real genius guy on deployment duties, he deployed application (Python, SQL, Perl and Java code) as set of deb files built for Ubuntu. Unfortunately now, I have no such support. We are deploying apps manually to virtualenv-ed environments with separate nginx configs for FastCGI. We use paver to deploy to remote servers. It's painful, but it works.
This looks like a good place to start: http://www.unessa.net/en/hoyci/2007/06/using-capistrano-deploy-django-apps/
I use mod_python, and have every site in a git repository with the following subdirs:
mysite
template
media
I have mysite/settings.py in .gitignore, and work like this:
do development on my local machine
create remote repository on webserver
push my changes to webserver repo
set up apache vhost config file, tweak live server settings.py
run git checkout && git reset --hard && sudo /etc/init.d/apache2 restart on webserver repo to get up-to-date version to its working copy and restart apache
repeat steps 1, 3 and 5 whenever change request comes
The easiest way would be to use one of the sites on http://djangofriendly.com/hosts/ that will provide the hosting and set up for you, but even if you're wanting to roll your own it will allow you to see what set up other sites are using.

Categories

Resources