In this tutorial, we will install Python pip on CentOS 8 using the yum package manager and cover the basics of how to install and manage Python packages with pip. In the CentOS 8 repository AppStream, there are both pip versions for Python 2 as well as Python 3 interpreter. pip command is now run with pip2 or pip3 command respectively.
GROMACS is managed under the module system on TACC resources. To run simulations, simply load the module with the following command: login1$ module load gromacs. As of this date, the recommended and default version is V2016.4. Users are welcome to install different versions of GROMACS in their own directories.
What is PIP?
pip is the standard package (module) manager for Python. It allows you to install and manage additional packages that are not part of the Python standard library. Modules are Python code libraries you can include and use in your projects. pip has been included with the Python installer since versions 3.4 for Python 3 and 2.7.9 for Python 2, and it’s used by many Python projects, which makes it an essential tool for every Python programmer.
Installing pip
In CentOS 8 you can install packages either with dnf or yum command. We can install pip2 or pip3 package depending on what python version we use, or we could also install both packages as well, without any problem.
Installing python2-pip
First, we update the system:
We will install both python2-pip and python3-pip packages.
First, we install python2-pip: Installing python3-pip
We install python3-pip package the same way:
Next, we should verify the package installation went well.
Confirming the installation by querying the version number
We will query version info on python2-pip and python3-pip with the following commands:
For python3-pip we type:
Searching for python packages
Let say we want to install some module with pip but we don't know the exact module name. We can search for the available packages using a keyword.
or
The list goes on, but we'll choose to install the docker-fabric module in the next example.
Installing modules (packages) using PIP
We can install the docker-fiber package using a simple pip command:
List installed packages
To list installed packages we use this command:
To list outdated packages, we type:
Removing modules (packages) using PIP
The only thing left to see in this tutorial is how to remove the pip package. It is fairly simple, we type:
You will be presented with the file list about to be removed. When we proceed by typing y, the package will be removed.
Conclusion
You have successfully installed pip on your CentOS 8 system and you learned how to easily install and uninstall Python modules with pip. For more information, you can check the pip user guide. If you have any questions or feedback, feel free to comment below.
Read Also:
IntroductionThe HTTP server is the most widely-used web server in the world. It provides many powerful features including dynamically loadable modules, robust media support, and extensive integration with other popular software.In this guide, you will install an Apache web server with virtual hosts on your CentOS 7 server. OutputRedirecting to /bin/systemctl status httpd.service● httpd.service - The Apache HTTP ServerLoaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)Active: active (running) since Wed 2019-02-20 01:29:08 UTC; 5s agoDocs: man:httpd(8)man:apachectl(8)Main PID: 1290 (httpd)Status: 'Processing requests.'
CGroup: /system.slice/httpd.service├─1290 /usr/sbin/httpd -DFOREGROUND├─1291 /usr/sbin/httpd -DFOREGROUND├─1292 /usr/sbin/httpd -DFOREGROUND├─1293 /usr/sbin/httpd -DFOREGROUND├─1294 /usr/sbin/httpd -DFOREGROUND└─1295 /usr/sbin/httpd -DFOREGROUND.As you can see from this output, the service appears to have started successfully. However, the best way to test this is to request a page from Apache.You can access the default Apache landing page to confirm that the software is running properly through your IP address. If you do not know your server’s IP address, you can get it a few different ways from the command line.Type this at your server’s command prompt:. hostname -IThis command will display all of the host’s network addresses, so you will get back a few IP addresses separated by spaces. You can try each in your web browser to see if they work.Alternatively, you can use curl to request your IP from icanhazip.com, which will give you your public IPv4 address as seen from another location on the internet:. curl -4 icanhazip.comWhen you have your server’s IP address, enter it into your browser’s address bar: yourserveripYou’ll see the default CentOS 7 Apache web page:This page indicates that Apache is working correctly.
It also includes some basic information about important Apache files and directory locations. Now that the service is installed and running, you can now use different systemctl commands to manage the service. Step 3 — Managing the Apache ProcessNow that you have your web server up and running, let’s go over some basic management commands.To stop your web server, type:.
sudo systemctl stop httpdTo start the web server when it is stopped, type:. sudo systemctl start httpdTo stop and then start the service again, type:.
sudo systemctl restart httpdIf you are simply making configuration changes, Apache can often reload without dropping connections. To do this, use this command:. sudo systemctl reload httpdBy default, Apache is configured to start automatically when the server boots. If this is not what you want, disable this behavior by typing:. sudo systemctl disable httpdTo re-enable the service to start up at boot, type:. sudo systemctl enable httpdApache will now start automatically when the server boots again.The default configuration for Apache will allow your server to host a single website.
If you plan on hosting multiple domains on your server, you will need to configure virtual hosts on your Apache web server. Step 4 — Setting Up Virtual Hosts (Recommended)When using the Apache web server, you can use virtual hosts (similar to server blocks in Nginx) to encapsulate configuration details and host more than one domain from a single server. In this step, you will set up a domain called example.com, but you should replace this with your own domain name. To learn more about setting up a domain name with DigitalOcean, see our.Apache on CentOS 7 has one server block enabled by default that is configured to serve documents from the /var/www/html directory. While this works well for a single site, it can become unwieldy if you are hosting multiple sites. /var/www/example.com/html/index.html Welcome to Example.com!Success! The example.com virtual host is working!Save and close the file by pressing ESC, typing:wq, and pressing ENTER.With your site directory and sample index file in place, you are almost ready to create the virtual host files.
Virtual host files specify the configuration of your separate sites and tell the Apache web server how to respond to various domain requests.Before you create your virtual hosts, you will need to create a sites-available directory to store them in. You will also create the sites-enabled directory that tells Apache that a virtual host is ready to serve to visitors. The sites-enabled directory will hold symbolic links to virtual hosts that we want to publish.
Create both directories with the following command:. sudo mkdir /etc/httpd/sites-available /etc/httpd/sites-enabledNext, you will tell Apache to look for virtual hosts in the sites-enabled directory. To accomplish this, edit Apache’s main configuration file and add a line declaring an optional directory for additional configuration files:. sudo vi /etc/httpd/conf/httpd.confAdd this line to the end of the file: IncludeOptional sites-enabled/.confSave and close the file when you are done adding that line.
Now that you have your virtual host directories in place, you will create your virtual host file.Start by creating a new file in the sites-available directory:. sudo vi /etc/httpd/sites-available/ example.com.confAdd in the following configuration block, and change the example.com domain to your domain name. /etc/httpd/sites-available/example.com.conf ServerName www. Example.comServerAlias example.comDocumentRoot /var/www/ example.com/htmlErrorLog /var/www/ example.com/log/error.logCustomLog /var/www/ example.com/log/requests.log combinedThis will tell Apache where to find the root directly that holds the publicly accessible web documents.
It also tells Apache where to store error and request logs for this particular site.Save and close the file when you are finished.Now that you have created the virtual host files, you will enable them so that Apache knows to serve them to visitors. To do this, create a symbolic link for each virtual host in the sites-enabled directory:. sudo ln -s /etc/httpd/sites-available/ example.com.conf /etc/httpd/sites-enabled/ example.com.confYour virtual host is now configured and ready to serve content.
Before restarting the Apache service, let’s make sure that SELinux has the correct policies in place for your virtual hosts. Step 5 — Adjusting SELinux Permissions for Virtual Hosts (Recommended)is configured to work with the default Apache configuration. Since you set up a custom log directory in the virtual hosts configuration file, you will receive an error if you attempt to start the Apache service. To resolve this, you need to update the SELinux policies to allow Apache to write to the necessary files. SELinux brings heightened security to your CentOS 7 environment, therefore it is not recommended to completely disable the kernel module.There are different ways to set policies based on your environment’s needs, as SELinux allows you to customize your security level.
This step will cover two methods of adjusting Apache policies: universally and on a specific directory. Adjusting policies on directories is more secure, and is therefore the recommended approach. Adjusting Apache Policies UniversallySetting the Apache policy universally will tell SELinux to treat all Apache processes identically by using the httpdunified boolean. While this approach is more convenient, it will not give you the same level of control as an approach that focuses on a file or directory policy.Run the following command to set a universal Apache policy:. sudo setsebool -P httpdunified 1The setsebool command changes SELinux boolean values.
The -P flag will update the boot-time value, making this change persist across reboots. Httpdunified is the boolean that will tell SELinux to treat all Apache processes as the same type, so you enabled it with a value of 1. Adjusting Apache Policies on a DirectoryIndividually setting SELinux permissions for the /var/www/ example.com/log directory will give you more control over your Apache policies, but may also require more maintenance. Since this option is not universally setting policies, you will need to manually set the context type for any new log directories specified in your virtual host configurations.First, check the context type that SELinux gave the /var/www/ example.com/log directory:. sudo ls -dZ /var/www/ example.com/log/This command lists and prints the SELinux context of the directory.
You will see output similar to the following. Root root unconfinedu:objectr: httpdsyscontentt:s0 /var/www/ example.com/log/The current context is httpdsyscontentt, which tells SELinux that the Apache process can only read files created in this directory. In this tutorial, you will change the context type of the /var/www/ example.com/log directory to httpdlogt. This type will allow Apache to generate and append to web application log files:.
sudo semanage fcontext -a -t httpdlogt '/var/www/ example.com/log(/.)?' Next, use the restorecon command to apply these changes and have them persist across reboots:. sudo restorecon -R -v /var/www/ example.com/logThe -R flag runs this command recursively, meaning it will update any existing files to use the new context. The -v flag will print the context changes the command made. You will see the following output confirming the changes.
Root root unconfinedu:objectr: httpdlogt:s0 /var/www/ example.com/logNow that the /var/www/ example.com/log directory is using the httpdlogt type, you are ready to test your virtual host configuration. Step 6 — Testing the Virtual Host (Recommended)Once the SELinux context has been updated with either method, Apache will be able to write to the /var/www/ example.com/log directory. You can now successfully restart the Apache service:.
sudo systemctl restart httpdList the contents of the /var/www/ example.com/log directory to see if Apache created the log files:. ls -lZ /var/www/ example.com/logYou’ll see that Apache was able to create the error.log and requests.log files specified in the virtual host configuration. 1 root root 0 Feb 26 22:54 error.log-rw-r-r-. 1 root root 0 Feb 26 22:54 requests.logNow that you have your virtual host set up and SELinux permissions updated, Apache will now serve your domain name. You can test this by navigating to example.com, where you should see something like this:This confirms that your virtual host is successfully configured and serving content. Repeat Steps 4 and 5 to create new virtual hosts with SELinux permissions for additional domains. ConclusionIn this tutorial, you installed and managed the Apache web server.
Now that you have your web server installed, you have many options for the type of content you can serve and the technologies you can use to create a richer experience.If you’d like to build out a more complete application stack, you can look at this article on how to configure a.
Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |