source: https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-a-centos-7-server
If you are currently signed in as the
root
user, type:gpasswd -a username wheel
su –Step 02: Download the repo using the command given below.
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpmStep 03: Now install the downloaded rpm using
rpm -ivh rpmforge-release-0.5.3-1.el7.rf.x86_64.rpmStep 04: Now you need to install the package
yum install p7zipStep 05: To unzip the file use the following command
7za x
mod_wsgi
Apache module that can communicate with Django over the WSGI interface specification.sudo
privileges configured. You can learn how to set this up by running thorugh our initial server setup guide.mod_wsgi
Apache module, which can translate HTTP requests into a predictable
application format defined by a specification called WSGI. You can find
out more about WSGI by reading the linked section on this guide.mod_wsgi
module used to interface with our Django app, and pip
, the Python package manager that can be used to download our Python-related tools.sudo apt-get update
sudo apt-get install python-pip apache2 libapache2-mod-wsgi
virtualenv
command to create these environments. We can get this using pip
:sudo pip install virtualenv
With virtualenv
installed, we can start forming our
project. Create a directory where you wish to keep your project and
move into the directory:mkdir ~/myproject
cd ~/myproject
Within the project directory, create a Python virtual environment by typing:virtualenv myprojectenv
This will create a directory called myprojectenv
within your myproject
directory. Inside, it will install a local version of Python and a local version of pip
. We can use this to install and configure an isolated Python environment for our project.source myprojectenv/bin/activate
Your prompt should change to indicate that you are now operating
within a Python virtual environment. It will look something like this: (myprojectenv)user@host:~/myproject$
.pip
by typing:pip install django
django-admin.py startproject myproject .
nano myproject/settings.py
We are going to be using the default SQLite database in this guide
for simplicity's sake, so we don't actually need to change too much. We
will focus on configuring the static files directory, where Django will
place static files so that the web server can serve these easily.STATIC_ROOT
setting to determine the directory where these files should go. We'll
use a bit of Python to tell it to use a directory called "static" in our
project's main directory:STATIC_ROOT = os.path.join(BASE_DIR, "static/")
Save and close the file when you are finished.cd ~/myproject
./manage.py makemigrations
./manage.py migrate
Create an administrative user for the project by typing:./manage.py createsuperuser
You will have to select a username, provide an email address, and choose and confirm a password../manage.py collectstatic
You will have to confirm the operation. The static files will be placed in a directory called static
within your project directory../manage.py runserver 0.0.0.0:8000
In your web browser, visit your server's domain name or IP address followed by :8000
:http://server_domain_or_IP:8000
You should see the default Django index page:/admin
to the end of the URL in the
address bar, you will be prompted for the administrative username and
password you created with the createsuperuser
command:deactivate
mod_wsgi
module. This should have been automatically enabled upon installation earlier.sudo nano /etc/apache2/sites-available/000-default.conf
We can keep the directives that are already present in the file. We just need to add some additional items./static
to the "static" directory within our project folder. We collected the
static assets there earlier. We will set up the alias and then grant
access to the directory in question with a directory block:
. . .
Alias /static /home/user/myproject/static
user
wsgi.py
file within the
second level project directory where the Django code is stored. To do
this, we'll use a directory section with a file section inside. We will
grant access to the file inside of this nested construct:
. . .
Alias /static /home/user/myproject/static
user
/myproject/static>
Require all granted
WSGIDaemonProcess
directive to set this up.myproject
to stay consistent. Afterwards, we set up the Python path where Apache
can find all of the components that may be required. Since we used a
virtual environment, we will have to set up two path components. The
first is our project's parent directory, where the project files can be
found. The second is the lib/pythonx.x/site-packages
path within our virtual environment folder (where the Xs are replaced
by the Python version number components). This way, Apache can find all
of the other Python code needed to run our project.WSGIDaemonProcess
directive (myproject
in our case). Finally, we need to set the script alias so that Apache will pass requests for the root domain to the wsgi.py
file:
. . .
Alias /static /home/user/myproject/static
user
/myproject/static>
Require all granted
db.sqlite3
by default and it should be located in your base project directory:chmod 664 ~/myproject/db.sqlite3
Afterwards, we need to give the group Apache runs under, the www-data
group, group ownership of the file:sudo chown :www-data ~/myproject/db.sqlite3
In order to write to the file, we also need to give the Apache group ownership over the database's parent directory:sudo chown :www-data ~/myproject
Once these steps are done, you are ready to restart the Apache
service to implement the changes you made. Restart Apache by typing:sudo service apache2 restart
You should now be able to access your Django site by going to your
server's domain name or IP address without specifying a port. The
regular site and the admin interface should function as expected.mod_wsgi
to handle client requests and interface with the Django app.