RHEL: Difference between revisions
→Setting up from scratch on a VM at work: Install EPEL repo |
|||
Line 5: | Line 5: | ||
=== Install NGINX === | === Install NGINX === | ||
<source lang=" | <source lang="sh"> | ||
$ sudo yum install yum-utils | $ sudo yum install yum-utils | ||
</source> | </source> | ||
Line 11: | Line 11: | ||
Create <code>/etc/yum.repos.d/nginx.repo</code> | Create <code>/etc/yum.repos.d/nginx.repo</code> | ||
<source lang=" | <source lang="cfg"> | ||
[nginx-stable] | [nginx-stable] | ||
name=nginx stable repo | name=nginx stable repo | ||
Line 31: | Line 31: | ||
Install nginx | Install nginx | ||
<source lang=" | <source lang="sh"> | ||
$ sudo yum install nginx | $ sudo yum install nginx | ||
</source> | |||
Set up folders | |||
<source lang="console"> | |||
# cd /etc/nginx | |||
# mkdir sites-available | |||
# mkdir sites-enabled | |||
</source> | |||
Create a file named <code>sites-available/unm.edu.conf</code> | |||
<source lang="nginx"> | |||
server { | |||
listen 80; | |||
listen [::]:80; | |||
server_name unm.edu *.unm.edu; | |||
return 301 https://$host$request_uri; | |||
} | |||
server { | |||
listen 443 ssl http2; | |||
listen [::]:443 ssl http2; | |||
server_name ~^(?<subdomain>.+)\.unm\.dev$; | |||
if (!-d /srv/www/unm.edu/$subdomain) { | |||
set $subdomain "base"; | |||
} | |||
set $public ""; | |||
if (-d /srv/www/unm.edu/$subdomain/public) { | |||
set $public public; | |||
} | |||
root /srv/www/unm.edu/$subdomain/$public; | |||
index index.php index.html index.htm; | |||
access_log /var/log/nginx/access-wildcard.unm.edu.log; | |||
error_log /var/log/nginx/error-wildcard.unm.edu.log; | |||
include php_80_params.conf; | |||
location / { | |||
try_files $uri $uri/ /index.php?$query_string; | |||
} | |||
ssl_certificate /etc/pki/tls/certs/_wildcard.unm.edu.pem; | |||
ssl_certificate_key /etc/pki/tls/private/_wildcard.unm.edu-key.pem; | |||
include letsencrypt_params.conf; | |||
} | |||
</source> | </source> | ||
Revision as of 11:51, 3 November 2021
Setting up from scratch on a VM at work
Web services
Install NGINX
$ sudo yum install yum-utils
Create /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
Install nginx
$ sudo yum install nginx
Set up folders
# cd /etc/nginx
# mkdir sites-available
# mkdir sites-enabled
Create a file named sites-available/unm.edu.conf
server {
listen 80;
listen [::]:80;
server_name unm.edu *.unm.edu;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name ~^(?<subdomain>.+)\.unm\.dev$;
if (!-d /srv/www/unm.edu/$subdomain) {
set $subdomain "base";
}
set $public "";
if (-d /srv/www/unm.edu/$subdomain/public) {
set $public public;
}
root /srv/www/unm.edu/$subdomain/$public;
index index.php index.html index.htm;
access_log /var/log/nginx/access-wildcard.unm.edu.log;
error_log /var/log/nginx/error-wildcard.unm.edu.log;
include php_80_params.conf;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
ssl_certificate /etc/pki/tls/certs/_wildcard.unm.edu.pem;
ssl_certificate_key /etc/pki/tls/private/_wildcard.unm.edu-key.pem;
include letsencrypt_params.conf;
}
Install EPEL repo
$ sudo subscription-manager repos --enable rhel-7-server-optional-rpms --enable rhel-7-server-extras-rpms
$ cd /tmp
$ wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
$ sudo yum install epel-release-latest-7.noarch.rpm
Useful commands
Package management
Clean up cache for yum PM
$ sudo service rhsmcertd restart
$ sudo subscription-manager refresh
$ sudo yum clean all && yum rm -rf /var/cache/yum && yum makecache
List all subscriptions
$ sudo subscription-manager list --all --available | more
Install downloaded RPM package
$ sudo yum -y localinstall ~/Downloads/screen
Check if there are any disabled repositories
$ egrep -Hi '(^\[|^enabled)' /etc/yum.repos.d/*
/etc/yum.repos.d/epel.repo.rpmsave:[epel]
/etc/yum.repos.d/epel.repo.rpmsave:enabled=1
/etc/yum.repos.d/epel.repo.rpmsave:[epel-debuginfo]
/etc/yum.repos.d/epel.repo.rpmsave:enabled=0
/etc/yum.repos.d/epel.repo.rpmsave:[epel-source]
/etc/yum.repos.d/epel.repo.rpmsave:enabled=0
/etc/yum.repos.d/nginx.repo:[nginx-stable]
/etc/yum.repos.d/nginx.repo:enabled=1
/etc/yum.repos.d/nginx.repo:[nginx-mainline]
/etc/yum.repos.d/nginx.repo:enabled=1
...