You can use a mod_wsgi application with a Python virtual environment (also known as a virtualenv) by modifying a configuration file.
To reconfigure a mod_wsgi application (versions 3.4 or later) to use a virtual environment:
1. Open an SSH session to your account.
2. Open ~/webapps/application/apache2/conf/httpd.conf in a text editor.
3. Set the path to your virtual environment. In the WSGIDaemonProcess directive, replace python-path=/home/username/webapps/app/lib/python3.5 with python-home=venv , where venv is the path to your virtual environment.
For example, if your mod_wsgi application is in /home/demo/webapps/mywsgiapp/ and your virtual environment is in /home/demo/webapps/mywsgiapp/venv/ , replace
python-path=/home/demo/webapps/mywsgiapp/lib/python3.5 with python-home=/home/demo/webapps/mywsgiapp/venv/.
4. Optionally, set additional Python path directories, such as the path to your Python project. In the WSGIDaemonProcess directive, add python-path=path . You can add more than one python-path, if needed.
5. Save and close the file.
6. Restart Apache. Enter $HOME/webapps/app/apache2/bin/restart and press Enter . The mod_wsgi now uses your virtual environment.
TWELVE
MONGODB
MongoDBis an open source document-oriented database.
Warning: WebFaction servers less than Web300 or less than Dweb89 only support the 32-bit version of MongoDB. The 32-bit version of MongoDB is limited to storing approximately 2.5GB of data. For more information on this limitation, please see the MongoDB blog article “32 bit limitations.”
12.1 Installing MongoDB
To install MongoDB:
1. Create a custom application to make a directory and receive a port assignment for your MongoDB installation.
(a) Log in to the control panel.
(b) Click Domains / websites → Applications. The list of applications appears.
(c) Click the Add new application button. The Create a new application form appears.
(d) In the Name field, enter a name for the application.
(e) In the App Category menu, click to select Custom.
(f) In the App Type menu, click to select Custom app (listening on port).
(g) If applicable, in the Machine menu, click to select a web server.
(h) Click the Save button. The application is created and added to the list of applications.
(i) Make a note of the application’s port number. It is required in a later installation step.
2. Open an SSH session to your account.
3. Install MongoDB.
(a) Switch to the MongoDB application directory. Enter cd $HOME/webapps/application , where applicationis the name of the MongoDB application as it appears on the control panel, and press
Enter.
(b) Download the MongoDB Linux archive. Enter wget url , where url is the download URL for MongoDB, and press Enter .
See the MongoDBdownloadspage for download URLs. If you’re using a server less than Web300 or less than Dweb89 , choose the Linux 32-bit legacy download URL. If you’re using any other server, choose the Linux 64-bit legacy download URL.
An archive, named mongodb-linux-architecture-version.tgz where architecture is x86_64 or i686 and version is the MongoDB version number, is created in the current directory.
(c) Extract the contents of the archive. Enter
tar -xzf mongodb-linux-architecture-version.tgz and press Enter . A new directory is created in the current directory that contains the MongoDB files.
4. Configure MongoDB.
(a) Create a database data directory. Enter mkdir data and press Enter . (b) Start the MongoDB database. Enter
$HOME/webapps/application/mongodb-linux-architecture-version/bin/mongod --auth --dbpath $HOME/webapps/application/data/ --port number, where number is the port number provided by the control panel, and press Enter .
Warning: Always start MongoDB with the --auth switch to prevent unauthorized users from tampering with your data.
(c) Open a second SSH session to your account. Leave the first session with MongoDB running.
(d) In the second session, connect to the database. Enter
$HOME/webapps/application/mongodb-linux-architecture-version/bin/mongo localhost:port/admin and press Enter . An interactive prompt ( > ) appears.
(e) Add an administrator user, which can be used to manage other users. Enter
db.createUser({user: "<username>", pwd: "<password>", roles: ["userAdminAnyDatabase"]}), where <username> is the new administrator username of your choice and <password> is the new
user’s password, and press Enter .
(f) Authenticate as the administrator user. Enter db.auth("username", "password") , where usernameis the administrator username you chose in the previous step and password is the user’s password, and press Enter . If authentication is successful, a 1 appears.
You can use this administrator user to manage other users and their permissions. See the MongoDB documentation’s onadding usersfor more detail.
See also:
For more information about user authentication, see the MongoDBSecuritydocumentation.
(g) Close the database connection. Enter exit and press Enter . You may also end the SSH session.
The database is configured and ready. You may start and stop the database as needed.
To start the database, run
$HOME/webapps/application/mongodb-linux-architecture-version/bin/mongod --auth --dbpath $HOME/webapps/application/data/ --port number. To stop MongoDB while it is running in the foreground, press Ctrl + C . For other ways to stop the database, see
the MongoDBStopping mongoddocumentation.
See also:
To learn more about using MongoDB, please see the MongoDBtutorialdocumentation. To learn more about using your preferred programming language with MongoDB, please see the MongoDBdriverslist.
THIRTEEN
MOVABLE TYPE
Movable Typeis a blog publishing application.
13.1 Configuring Movable Type to Send Mail
To configure Movable Type to be able to send email messages during the installation’s the Mail Configuration page:
1. In the Send email via menu, click to select Sendmail.
2. In the Mail address to which test email should be sent enter an email address where you wish to receive a test email.
3. In the From mail address field, enter an email address configured in the WebFaction control panel.
4. Click the Continue button.
5. Complete the installation.
6. Log in to the Movable Type User Dashboard.
7. Next to User Dashboard, click the navigation icon and then click System Overview. The System Overview page appears.
8. Click Settings → General. The General Settings page appears.
9. In the System Email field, enter the email address Movable Type should send mail as. This address must be configured in the WebFaction control panel.
10. Click the Save Changes button.
To configure Movable Type to be able to send email messages at any other time:
1. Open an SSH session to your account.
2. Switch the Movable Type directory. Enter cd ~/webapps/mt where mt is the name of the Movable Type application as it appears on the control panel, and press Enter .
3. Open mt-config.cgi in a text editor (the file may be in a subdirectory depending on where you install the Movable Type application files).
4. Modify or add these configuration directives:
MailTransfer sendmail
SendMailPath /usr/sbin/sendmail EmailAddressMain <address>
where <address> is Movable Type’s outgoing email address. This address must be registered on the WebFaction control panel.
5. Save and close the file.