Last active
April 13, 2020 17:21
-
-
Save aamnah/30c596c3cdc96c1f1470 to your computer and use it in GitHub Desktop.
Opencart settings for an Ubuntu server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ### | |
| # Author: AAmnah | |
| # Link: http://aamnah.com | |
| # Description: Install script for Opencart 2.x on a Linux (Ubuntu/Debian) server | |
| ### | |
| # Color Reset | |
| Color_Off='\033[0m' # Text Reset | |
| # Regular Colors | |
| Red='\033[0;31m' # Red | |
| Green='\033[0;32m' # Green | |
| Cyan='\033[0;36m' # Cyan | |
| get() { | |
| # Get latest source files from git repo | |
| git clone https://github.com/opencart/opencart.git | |
| # clean up | |
| mv opencart/upload/* . | |
| } | |
| config() { | |
| # add config files | |
| cp config-dist.php config.php | |
| cp admin/config-dist.php admin/config.php | |
| } | |
| htaccess() { | |
| htaccess='.htaccess.txt' | |
| # if .htaccess.txt exists then rename it | |
| if [ -s ${htaccess} ]; then | |
| cp .htaccess.txt .htaccess | |
| #otherwise, create a new file | |
| else | |
| touch .htaccess | |
| echo "# 1.To use URL Alias you need to be running apache with mod_rewrite enabled. | |
| # 2. In your opencart directory rename htaccess.txt to .htaccess. | |
| # For any support issues please visit: http://www.opencart.com | |
| Options +FollowSymlinks | |
| # Prevent Directoy listing | |
| Options -Indexes | |
| # Prevent Direct Access to files | |
| <FilesMatch \"(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))\"> | |
| Order deny,allow | |
| Deny from all | |
| </FilesMatch> | |
| # SEO URL Settings | |
| RewriteEngine On | |
| # If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/ | |
| RewriteBase / | |
| RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L] | |
| RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L] | |
| RewriteRule ^system/download/(.*) /index.php?route=error/not_found [L] | |
| RewriteCond %{REQUEST_FILENAME} !-f | |
| RewriteCond %{REQUEST_FILENAME} !-d | |
| RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css) | |
| RewriteRule ^([^?]*) index.php?_route_=\$1 [L,QSA] | |
| ### Additional Settings that may need to be enabled for some servers | |
| ### Uncomment the commands by removing the # sign in front of it. | |
| ### If you get an \"Internal Server Error 500\" after enabling any of the following settings, restore the # as this means your host doesn't allow that. | |
| # 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it: | |
| # php_flag register_globals off | |
| # 2. If your cart has magic quotes enabled, This may work to disable it: | |
| # php_flag magic_quotes_gpc Off | |
| # 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try | |
| # php_value upload_max_filesize 999M | |
| # 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields | |
| # php_value post_max_size 999M | |
| # 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields | |
| # php_value max_execution_time 200 | |
| # 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields | |
| # php_value max_input_time 200 | |
| # 7. disable open_basedir limitations | |
| # php_admin_value open_basedir none" > .htaccess | |
| fi | |
| } | |
| installPerms() { | |
| # set permissions for install | |
| chmod 777 system/cache/ | |
| chmod 777 system/logs/ | |
| chmod 777 system/download/ | |
| chmod 777 system/upload/ | |
| chmod 777 image/ | |
| chmod 777 image/cache/ | |
| chmod 777 image/catalog/ | |
| chmod 777 config.php | |
| chmod 777 admin/config.php | |
| } | |
| installMessage() { | |
| echo -e " ${Cyan} Please visit http://yourdomain.com/install to finish the installation ${Color_Off}" | |
| } | |
| secure() { | |
| echo -e "Should i SECURE the install now? ( y / n ) \n (remove the install folder and change file permissions)" | |
| read doit | |
| if [ doit == 'y' ]; then | |
| # delete install folder | |
| rm -rf install/ | |
| # To change all the directories to 755 (-rwxr-xr-x) | |
| find . -type d -exec chmod 755 {} \; | |
| # To change all the files to 644 (-rw-r--r--): | |
| find . -type f -exec chmod 644 {} \; | |
| # set 444 for admin files | |
| chmod 444 config.php | |
| chmod 444 admin/config.php | |
| # set 777 for cache | |
| chmod 777 image/cache/ | |
| chmod 777 system/cache/ | |
| else | |
| echo -e "Your install is insecure! Please remove the install folder and change permissions" | |
| secure | |
| fi | |
| } | |
| # RUN | |
| echo -e "\n ${Cyan} Cloning latest files from Github repo.. ${Color_Off}" | |
| get | |
| echo -e " ${Cyan} Creating config files.. ${Color_Off}" | |
| config | |
| echo -e " ${Cyan} Creating .htaccess ${Color_Off}" | |
| htaccess | |
| echo -e " ${Cyan} Settings install permissions.. ${Color_Off}" | |
| installPerms | |
| installMessage | |
| secure | |
| echo -e " ${Cyan} Securing.. ${Color_Off}" | |
| echo -e " ${Green} OpenCart has been successfully installed! ${Color_Off}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment