How To Setup RHEL Web Server And Install Litecart
عنوان
لا توجد تغييراتالرابط الدائم
لا توجد تغييراتالمحتوى
| Old | New | ||
|---|---|---|---|
| 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) |
| 9 | dnf update | 9 | # (If a password is not previously set, first set a root password with the command: sudo passwd root) |
| 10 | su | ||
| 10 | 11 | ||
| 11 | # Install stuff we need | 12 | # Make sure system and components are up to date |
| 12 | dnf -y install nano unzip | 13 | dnf upgrade --refresh -y && sudo dnf autoremove -y |
| 13 | |||
| 14 | # Install locales (Example: glibc-langpack-{language_code}) | ||
| 15 | dnf -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 |
| 18 | dnf -y install epel-release | 16 | dnf -y install epel-release |
| 19 | 17 | ||
| 20 | # Install s | 18 | # Install some server software and components |
| 21 | dnf -y install | 19 | dnf -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}) |
| 24 | dnf module switch-to php:8.1 | 22 | dnf -y install glibc-langpack-es |
| 23 | dnf -y install glibc-langpack-fr | ||
| 24 | |||
| 25 | # Change PHP distribution to version 8.3 | ||
| 26 | dnf module switch-to php:8.3 | ||
| 25 | 27 | ||
| 26 | # Start our new services | 28 | # Start our new services |
| 27 | systemctl enable php-fpm | 29 | systemctl enable php-fpm httpd mariadb |
| 28 | systemctl start php-fpm | 30 | systemctl start php-fpm httpd mariadb |
| 29 | |||
| 30 | systemctl enable httpd | ||
| 31 | systemctl start httpd | ||
| 32 | |||
| 33 | systemctl enable mariadb | ||
| 34 | systemctl start mariadb | ||
| 35 | 31 | ||
| 36 | # Run the guide for securing MariaDB/MySQL | 32 | # Run the guide for securing MariaDB/MySQL |
| 37 | mysql_secure_installation | 33 | mysql_secure_installation |
| 69 | Go to the document root for your site, remove default index page, download the LiteCart web installer and setting the correct permissions: | 65 | Go 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 | ||
| 69 | mkdir /var/www/litecart | ||
| 70 | |||
| 71 | # Create a MySQL database for LiteCart | ||
| 72 | read -p "New database name: " newdb_name | ||
| 73 | read -p "New database user: " newdb_user | ||
| 74 | read -sp "Password for database user '$newdb_user': " newdb_password | ||
| 75 | |||
| 76 | mysql -u root -p <<END | ||
| 77 | CREATE DATABASE $newdb_name; \ | ||
| 78 | CREATE USER '$newdb_user'@'localhost' IDENTIFIED BY '$newdb_password'; \ | ||
| 79 | GRANT ALL PRIVILEGES ON $newdb_name.* TO '$newdb_user'@'localhost' WITH GRANT OPTION; \ | ||
| 80 | FLUSH PRIVILEGES; | ||
| 81 | END | ||
| 82 | |||
| 83 | # Create an Apache virtualhost configuration directive for mydomain.tld pointing to the folder of LiteCart | ||
| 84 | cat <<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> | ||
| 100 | EOL | ||
| 101 | |||
| 72 | # Go to the document root for your site | 102 | # Go to the document root for your site |
| 73 | cd /var/www/ | 103 | cd /var/www/litecart |
| 74 | 104 | ||
| 75 | # | 105 | # Install LiteCart |
| 76 | 106 | bash -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 |
| 79 | chown -R apache:apache ./ | 109 | chown -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: |
| 87 | rm -Rf install/ | 112 | rm -Rf install/ |
| 88 | ``` | 113 | |
| 114 | systemctl restart httpd | ||
| 115 | ``` | ||
| 116 | |||
| 117 | ## Install Let's Encrypt free SSL certificate | ||
| 118 | |||
| 119 | ``` | ||
| 120 | # Install certbot | ||
| 121 | dnf install certbot python3-certbot-apache -y | ||
| 122 | |||
| 123 | # Install an SSL Certificate using Let's Encrypt | ||
| 124 | certbot --apache -w /var/www/litecart -d mydomain.tld | ||
| 125 | |||
| 126 | # Append to virtualhost configuration to listen for HTTPS connections | ||
| 127 | cat <<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> | ||
| 149 | EOL | ||
| 150 | |||
| 151 | # Restart Apache web server for SSL | ||
| 152 | systemctl restart httpd | ||
تم التعديل بواسطة tim في 20 فبراير 2025 at 02:38