How To Setup RHEL Web Server And Install Litecart

عنوان

لا توجد تغييرات

الرابط الدائم

لا توجد تغييرات

المحتوى

OldNew
5## Configure the Server 5## Configure the Server
6 6
7```bash 7```bash
8# Update all OS components 8# Become root (or you will need to pass `sudo` before every command)
9dnf update 9# (If a password is not previously set, first set a root password with the command: sudo passwd root)
10su
10 11
11# Install stuff we need 12# Make sure system and components are up to date
12dnf -y install nano unzip 13dnf upgrade --refresh -y && sudo dnf autoremove -y
13
14# Install locales (Example: glibc-langpack-{language_code})
15dnf -y install glibc-langpack-en
16 14
17# Install repository for extra packages like php-imagick 15# Install repository for extra packages like php-imagick
18dnf -y install epel-release 16dnf -y install epel-release
19 17
20# Install server daemons and extensions 18# Install some server software and components
21dnf -y install httpd mod_ssl mariadb-server php php-bcmath php-intl php-apcu php-gd php-json php-mysqlnd php-simplexml php-zip 19dnf -y install nano unzip httpd mod_ssl mariadb-server php php-bcmath php-intl php-apcu php-gd php-imagick php-json php-mysqlnd php-simplexml php-zip
22 20
23# Change PHP distribution to version 8.1 21# Install locales (Example: glibc-langpack-{language_code})
24dnf module switch-to php:8.1 22dnf -y install glibc-langpack-es
23dnf -y install glibc-langpack-fr
24
25# Change PHP distribution to version 8.3
26dnf module switch-to php:8.3
25 27
26# Start our new services 28# Start our new services
27systemctl enable php-fpm 29systemctl enable php-fpm httpd mariadb
28systemctl start php-fpm 30systemctl start php-fpm httpd mariadb
29
30systemctl enable httpd
31systemctl start httpd
32
33systemctl enable mariadb
34systemctl start mariadb
35 31
36# Run the guide for securing MariaDB/MySQL 32# Run the guide for securing MariaDB/MySQL
37mysql_secure_installation 33mysql_secure_installation
69Go to the document root for your site, remove default index page, download the LiteCart web installer and setting the correct permissions: 65Go to the document root for your site, remove default index page, download the LiteCart web installer and setting the correct permissions:
70 66
71```bash 67```bash
68# Create a directory for LiteCart
69mkdir /var/www/litecart
70
71# Create a MySQL database for LiteCart
72read -p "New database name: " newdb_name
73read -p "New database user: " newdb_user
74read -sp "Password for database user '$newdb_user': " newdb_password
75
76mysql -u root -p <<END
77CREATE DATABASE $newdb_name; \
78CREATE USER '$newdb_user'@'localhost' IDENTIFIED BY '$newdb_password'; \
79GRANT ALL PRIVILEGES ON $newdb_name.* TO '$newdb_user'@'localhost' WITH GRANT OPTION; \
80FLUSH PRIVILEGES;
81END
82
83# Create an Apache virtualhost configuration directive for mydomain.tld pointing to the folder of LiteCart
84cat <<EOL > /etc/httpd/conf.d/mydomain.tld.conf
85<VirtualHost *:80>
86 ServerName mydomain.tld
87 ServerAlias www.mydomain.tld
88 ServerAdmin webmaster@mydomain.tld
89 DocumentRoot /var/www/litecart
90
91 ErrorLog \${APACHE_LOG_DIR}/error.log
92 CustomLog \${APACHE_LOG_DIR}/access.log combined
93
94 <Directory /var/www/litecart>
95 Options FollowSymLinks
96 AllowOverride All
97 Require all granted
98 </Directory>
99</VirtualHost>
100EOL
101
72# Go to the document root for your site 102# Go to the document root for your site
73cd /var/www/html 103cd /var/www/litecart
74 104
75# Download the LiteCart web installer 105# Install LiteCart
76curl --output index.php https://raw.githubusercontent.com/litecart/installer/master/web/index.php 106bash -c "$(curl https://raw.githubusercontent.com/litecart/installer/master/cli/install.sh)"
77 107
78# Change owner of the files to apache 108# Change owner of the files to apache
79chown -R apache:apache ./ 109chown -R apache:apache ./
80 110
81##########################################################################
82# Open your browser and visit your website to begin installing LiteCart. #
83# http://myserver/ #
84##########################################################################
85
86# When the LiteCart web installation is completed, do some cleanup: 111# When the LiteCart web installation is completed, do some cleanup:
87rm -Rf install/ 112rm -Rf install/
88```113
114systemctl restart httpd
115```
116
117## Install Let's Encrypt free SSL certificate
118
119```
120# Install certbot
121dnf install certbot python3-certbot-apache -y
122
123# Install an SSL Certificate using Let's Encrypt
124certbot --apache -w /var/www/litecart -d mydomain.tld
125
126# Append to virtualhost configuration to listen for HTTPS connections
127cat <<EOL >> /etc/httpd/conf.d/mydomain.tld.conf
128
129<VirtualHost *:443>
130 ServerName mydomain.tld
131 ServerAlias www.mydomain.tld
132 ServerAdmin webmaster@mydomain.tld
133 DocumentRoot /var/www/litecart
134
135 ErrorLog \${APACHE_LOG_DIR}/error.log
136 CustomLog \${APACHE_LOG_DIR}/access.log combined
137
138 <Directory /var/www/litecart>
139 Options FollowSymLinks
140 AllowOverride All
141 Require all granted
142 </Directory>
143
144 # SSL Configuration
145 SSLEngine on
146 SSLCertificateFile /etc/letsencrypt/live/mydomain.tld/fullchain.pem
147 SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.tld/privkey.pem
148</VirtualHost>
149EOL
150
151# Restart Apache web server for SSL
152systemctl restart httpd

تم التعديل بواسطة tim في 20 فبراير 2025 at 02:38

عرض الكود على GitHub