Facebook
From Eckmar , 4 Weeks ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 45
  1. Eckbar Marketplace Script 2.0
  2.  
  3. sudo apt-get update
  4.  
  5. sudo apt-get install nginx
  6.  
  7. sudo ufw allow 'Nginx HTTP'
  8.  
  9. After both steps are done, you should check whats your VPS IP address and enter that IP in a browser. Youshould see
  10. welcome to nginx !
  11.  page. If you do see it, nginx is installed correctly.
  12. MySQL
  13. Marketplace supports multiple databases like: MySQL,PostgreSQL, SQLite, SQL Server We will use MySQL.
  14.  
  15. sudo apt-get install mysql-server
  16.  
  17. mysql_secure_installation
  18.  
  19. that will guide you trough securing your MySQL connection.After secure installation is done, we need to create database for Marketplace by running series of commands:
  20.  
  21. mysql -u root -p
  22.  
  23. CREATE DATABASE marketplace DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
  24.  
  25. exit
  26.  
  27. (above code are 3 separate commands)
  28.  
  29. PHP
  30. We need to install PHP (PHP-FPM) to run our code.
  31.  
  32. sudo apt-get install php7.2-fpm php-mysql
  33.  
  34. php -v
  35.  
  36. sudo nano /etc/php/7.2/fpm/php.ini
  37.  
  38. Inside this file, there is commented line
  39. # cgi.fix_pathinfo=1
  40.  You need to uncomment the line and setvalue to
  41. cgi.fix_pathinfo=0
  42.  (without #)
  43.  
  44. In order for changes to take effect, php-fpm must be restarted.
  45.  
  46. sudo systemctl restart php7.2-fpm
  47.  
  48. Now we need to install some PHP extensions that are required by Marketplace as well as composer and unzip tools
  49.  
  50. sudo apt-get install php7.2-mbstring php7.2-xml php7.2-xmlrpc php7.2-gmp php7.2-curl php7.2-gd composer unzip -y
  51.  
  52. (Above code is single command)
  53.  
  54. Elasticsearch
  55.  
  56. Marketplace uses Elasticsearch software that provices great search speeds and flexibility.
  57.  
  58. Elasticsearch requires Java in order to run
  59.  
  60. Oracle JDK 
  61.  
  62. Add repository to apt
  63.  
  64. sudo add-apt-repository ppa:webupd8team/java
  65.  
  66. Update apt
  67.  
  68. sudo apt update
  69.  
  70.  Install Java:
  71.  
  72. sudo apt install oracle-java8-installer
  73.  
  74. To see if Java is installed correctly run:
  75.  
  76. sudo update-alternatives --config java
  77.  
  78. Exit out of the command. You should see the path similar to this:
  79. /usr/lib/jvm/java-8-oracle/jre/bin/java
  80. now we need to use that path and create environment variable
  81.  
  82. sudo nano /etc/environment
  83.  
  84. At the bottom of the file add
  85.  
  86. JAVA_HOME="/usr/lib/jvm/java-8-oracle/jre/bin/java"
  87.  
  88. (Based on path above, if yours is different change it here)
  89.  
  90. In order for changes to take effect we need to reload environment file
  91.  
  92. source /etc/environment
  93.  
  94. To check if everything is working enter:
  95.  
  96. echo $JAVA_HOME
  97.  
  98. Command should give same path as before as output.
  99.  
  100. Elasticsearch installation
  101. Now that java is installed, we can proceed with installation of Elasticsearch
  102.  
  103. wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.3.1/elasticsearch-2.3.1.deb
  104. (Above code is single command)Download
  105. .deb
  106.  package and install it with:
  107. sudo dpkg -i elasticsearch-2.3.1.deb
  108. We want Elasticsearch service to start when system boots up, so we enter:
  109.  
  110. sudo systemctl enable elasticsearch.service
  111.  
  112. Now we need to start it up.
  113.  
  114. sudo systemctl start elasticsearch
  115.  
  116. Give it 10-15 seconds from last command, and then run:
  117.  
  118. curl -X GET "localhost:9200"
  119.  
  120. If you see information about your Elasticsearch engine, then installation is completed successfully.
  121.  
  122. Elasticsearch installation error
  123.  
  124. Elasticsearch has some problems on servers with low memory. In order to make it work we need to limit maxmemory Java is using. To check if this is an issue run:
  125.  
  126. sudo service elasticsearch status
  127.  
  128. If you see
  129. "There is insufficient memory for the Java Runtime..."
  130.  inside the text, continue, if not then your installation is not done properly and you should remove all Elasticsearch packages and go back toinstalling it from the start.
  131.  
  132. Enter:
  133.  
  134. edit /etc/elasticsearch/jvm.options
  135.  
  136. Change to lower memory
  137.  
  138. -Xms512m
  139. -Xmx512m
  140.  
  141. Then restart Elasticsearch:
  142.  
  143. sudo systemctl restart elasticsearch
  144.  
  145. Give it 10-15 seconds and then run:
  146.  
  147. curl -X GET "localhost:9200"
  148.  
  149. If you see information about your Elasticsearch engine, then installation is completed successfully.
  150.  
  151. Redis
  152. This step is optional, but will greatly increase your app performance.
  153.  
  154. sudo apt install redis-server
  155.  
  156. After redis installation is done open redis config file:
  157.  
  158. sudo nano /etc/redis/redis.conf
  159.  
  160. In there find supervised and change it from supervised no to  supervised systemd and save the file.
  161.  
  162. Reload Redis with:
  163.  
  164. sudo systemctl restart redis.service
  165.  
  166. And check if its running with
  167.  
  168. sudo systemctl status redis.service
  169.  
  170. To check if Redis is installed correctly enter:
  171.  
  172. redis-cli
  173.  
  174. it should open Redis interface running on port 6379. By entering  ping you should get response PONG If¬†everything is fine, type exit and exit redis-cli.
  175.  
  176. Node and NPM
  177.  
  178. We need NodeJs and NPM in order to compile our client side css files.
  179.  
  180. Install NodeJs:
  181.  
  182. sudo apt-get install -y nodejs
  183.  
  184. Install NPM:
  185.  
  186. sudo apt-get install -y npm
  187.  
  188. To check if they are installed properly run:
  189.  
  190. node -v npm -v
  191.  
  192. (Above code are 2 commands)
  193.  
  194. Files
  195.  
  196. Now we need to copy Marketplace files to the server. Make new directory inside
  197. /var/www
  198.  and put all files there. You can call it whatever you want.
  199.  
  200. Permissions
  201.  
  202. After files are copied we need to give them permissions.Run theese commands based on your file path:
  203.  
  204. sudo chown -R www-data:www-data /var/www/DIRECTORY_NAME/public
  205.  
  206. sudo chmod 755 /var/www
  207.  
  208. sudo chmod -R 755 /var/www/DIRECTORY_NAME/bootstrap/cache
  209.  
  210. sudo chmod -R 755 /var/www/DIRECTORY_NAME/storage
  211.  
  212. Run:
  213.  
  214. php artisan storage:link
  215.  
  216. To link public directory with storage.Make this folder: (for product pictures)
  217.  
  218. sudo mkdir /var/www/DIRECTORY_NAME/storage/public/products
  219.  
  220. And give it permissions
  221.  
  222. sudo chmod -R 755 /var/www/DIRECTORY_NAME/storage/public/products
  223. sudo chgrp -R www-data storage/storage/public/products
  224. sudo chmod -R ug+rwx storage/storage/public/products
  225.  
  226. (Above code are 3 commands)
  227. Installation
  228.  
  229. After everything above is done, change current directory to the
  230.  
  231. DIRECTORY_NAME you previously chose(marketplace files) and run series of commands to install all required dependencies:
  232.  
  233. composer install
  234. npm install
  235. npm run prod
  236. cp .env.example .env
  237. php artisan key:generate
  238.  
  239. (Above code are 4 commands)
  240.  
  241. Then open your .env file and insert database connection details:
  242.  
  243. sudo nano .env
  244.  
  245. Example of database configuration:
  246.  
  247. DB_CONNECTION=mysql
  248. DB_HOST=127.0.0.1
  249. DB_PORT=3306
  250. DB_DATABASE=marketplace
  251. DB_USERNAME=root
  252. DB_PASSWORD=password
  253.  
  254. If you did install redis, change driver from
  255. sync to redis
  256.  
  257. CACHE_DRIVER=redis
  258.  
  259. Now you can try running:
  260.  
  261. php artisan migrate
  262.  
  263. Now, you can create some dummy data, with:
  264.  
  265. php artisan db:seed
  266.  
  267. f both commands ran fine, your connection to database is configured fine. If you want to get rid of dummydata, run:
  268.  
  269. php artisan migrate:fresh
  270.  
  271. Your basic marketplace is working now, congratulations !
  272.  
  273. Connecting coins
  274.  
  275. Marketplace has support for various coins. Each coin has its on prefix in .env file as well as connectionparameters. Connection paramters are:
  276.  
  277. HOST
  278. PORT
  279. USERNAME
  280. PASSWORD
  281.  
  282. And coin prefixes are:
  283. Bitcoin - BITCOIND
  284. Litecoin - LITECOIN
  285. Monero - MONERO
  286. Pivx - PIVX
  287. Dash - DASH
  288. Verge - VERGE
  289. Bitcoin Cash - BITCOIN_CASH
  290.  
  291. Knowing this, you can input connection parameters in
  292. .env accordingly. For example, for Bitcoin you wouldenter
  293. BITCOIND_HOST=server_ip, or for Dash
  294. DASH_PASSWORD=password
  295. .
  296. Marketplace configuration
  297. Marketplace configuration is split into multiple files located in
  298. config folder. Main one is marketplace.php You will find most of the config options described or self-explanatory. Other than  marketplace.php
  299.  You can configure levels and experience in experience.php
  300.  and marketplace addresses for receiving profits in
  301. coins.php
  302.  
  303. Contact
  304. If you find any error in code, please contact me at:Telegram:
  305. @eckmar
  306.  (Best way to reach me)XMPP:
  307. eckmar@creep.im
  308.  (Main account) or
  309. eckmar@xmpp.zone
  310.  
  311.