Advertisement
akhfa

Install LEMP Centos 7

Sep 30th, 2015
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.91 KB | None | 0 0
  1. #!/bin/bash
  2. yum install nano
  3. # https://downloads.mariadb.org/mariadb/repositories/#mirror=Beritagar&distro=CentOS&distro_release=centos7-amd64--centos7&version=10.1
  4. nano /etc/yum.repos.d/MariaDB.repo
  5.  
  6. [mariadb]
  7. name = MariaDB
  8. baseurl = http://yum.mariadb.org/10.1/centos7-amd64
  9. gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
  10. gpgcheck=1
  11.  
  12. yum install MariaDB-server MariaDB-client
  13. systemctl start mariadb
  14. systemctl enable mariadb
  15. mysql_secure_installation
  16.  
  17. yum install epel-release
  18. yum install nginx
  19. systemctl start nginx
  20. systemctl enable nginx
  21. firewall-cmd --zone=public --add-port=80/tcp --permanent
  22. firewall-cmd --zone=public --add-port=443/tcp --permanent
  23. firewall-cmd --reload
  24.  
  25. yum install wget -y
  26. wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
  27. rpm -Uvh remi-release-7.rpm
  28. nano /etc/yum.repos.d/remi-php71.repo
  29. yum install php php-mysql php-fpm php-cli*
  30. systemctl start php-fpm
  31. systemctl enable php-fpm
  32.  
  33. nano /etc/nginx/nginx.conf
  34.     server {
  35.         listen       80 default_server;
  36.         listen       [::]:80 default_server;
  37.         server_name  _;
  38.         root         /usr/share/nginx/html;
  39.  
  40.         # Load configuration files for the default server block.
  41.         include /etc/nginx/default.d/*.conf;
  42.  
  43.         index  index.php index.html index.htm;
  44.  
  45.         location / {
  46.             try_files $uri $uri/ /index.php;
  47.         }
  48.  
  49.         error_page 404 /404.html;
  50.             location = /40x.html {
  51.         }
  52.  
  53.         error_page 500 502 503 504 /50x.html;
  54.             location = /50x.html {
  55.         }
  56.  
  57.         location ~ .php$ {
  58.             try_files $uri =404;
  59.             fastcgi_pass 127.0.0.1:9000;
  60.             fastcgi_index index.php;
  61.             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  62.             include fastcgi_params;
  63.             fastcgi_buffer_size 128k;
  64.             fastcgi_buffers 256 4k;
  65.             fastcgi_busy_buffers_size 256k;
  66.             fastcgi_temp_file_write_size 256k;
  67.         }
  68.         location ~ /\.(ht|svn|git) {
  69.             deny all;
  70.         }
  71.     }
  72.  
  73. systemctl restart nginx
  74. nano /usr/share/nginx/html/index.php
  75. # masukkan <?php echo phpinfo();?>
  76. chown apache:apache /usr/share/nginx/html/index.php
  77. # akses di browser http://plx.akhfa.me/index.php
  78.  
  79. nano /etc/nginx/conf.d/wordpress.conf
  80.  
  81. server {
  82.     listen 80;
  83.     server_name  notulensiku.com www.notulensiku.com;
  84.  
  85.     #charset koi8-r;
  86.     #access_log  /var/log/nginx/log/host.access.log  main;
  87.  
  88.     root   /usr/share/nginx/html/wordpress/;
  89.     index  index.php index.html index.htm;
  90.  
  91.     location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
  92.         expires 30d;
  93.         add_header Pragma public;
  94.         add_header Cache-Control "public";
  95.     }
  96.  
  97.     location / {
  98.         try_files $uri $uri/ /index.php?q=$uri&$args;
  99.         # access_log  /var/log/nginx/postdata.log postdata;
  100.     }
  101.  
  102.     rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
  103.     rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
  104.     rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
  105.     rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
  106.  
  107.     #error_page  404              /404.html;
  108.  
  109.     # redirect server error pages to the static page /50x.html
  110.     #
  111.     error_page   500 502 503 504  /50x.html;
  112.     location = /50x.html {
  113.         root   /usr/share/nginx/html;
  114.     }
  115.  
  116.     # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  117.     #
  118.     #location ~ \.php$ {
  119.     #    proxy_pass   http://127.0.0.1;
  120.     #}
  121.  
  122.     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  123.     #
  124.     location ~ \.php$ {
  125.         fastcgi_pass   127.0.0.1:9000;
  126.         fastcgi_index  index.php;
  127.         fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
  128.         include        fastcgi_params;
  129.     }
  130.     # deny access to .htaccess files, if Apache's document root
  131.     # concurs with nginx's one
  132.     #
  133.     location ~ /\.ht {
  134.         deny  all;
  135.     }
  136.     # location ~ ^/(wp-content\/uploads\/wfm3_data/\.wfm3_scan_data){
  137.     location ~ /\. {
  138.         return 404;
  139.     }
  140. }
  141.  
  142. systemctl restart nginx
  143.  
  144. cd /usr/share/nginx/html
  145. wget https://wordpress.org/latest.zip
  146. yum install unzip -y
  147. unzip latest.zip
  148. chown -R apache:apache /usr/share/nginx/html/wordpress
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156. ======================================= end of tutorial ======================================================
  157.  
  158.  
  159. server {
  160.     listen 80;
  161.     server_name  notulensiku.com www.notulensiku.com;
  162.     return 301 https://$host$request_uri;
  163. }
  164.  
  165. server {
  166.     client_max_body_size 30M;
  167.     listen 443 ssl http2;
  168.     server_name  notulensiku.com www.notulensiku.com;
  169.  
  170.     ssl_certificate /etc/nginx/ssl/notulensiku.com/notulensiku.crt;
  171.     ssl_certificate_key /etc/nginx/ssl/notulensiku.com/notulensiku.key;
  172.  
  173.     #ssl_certificate /etc/letsencrypt/live/notulensiku.com/fullchain.pem;
  174.     #ssl_certificate_key /etc/letsencrypt/live/notulensiku.com/privkey.pem;
  175.  
  176.     #charset koi8-r;
  177.     #access_log  /var/log/nginx/log/host.access.log  main;
  178.  
  179.     root   /var/www/blog.akhfa.me/public_html/;
  180.     index  index.php index.html index.htm;
  181.  
  182.     location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
  183.         expires 30d;
  184.         add_header Pragma public;
  185.         add_header Cache-Control "public";
  186.     }
  187.  
  188.     location / {
  189.         limit_req      zone=one burst=50 nodelay;
  190.         try_files $uri $uri/ /index.php?q=$uri&$args;
  191.         # access_log  /var/log/nginx/postdata.log postdata;
  192.     }
  193.  
  194.     rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
  195.     rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
  196.     rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
  197.     rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
  198.  
  199.     #error_page  404              /404.html;
  200.  
  201.     # redirect server error pages to the static page /50x.html
  202.     #
  203.     error_page   500 502 503 504  /50x.html;
  204.     location = /50x.html {
  205.         root   /usr/share/nginx/html;
  206.     }
  207.  
  208.     # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  209.     #
  210.     #location ~ \.php$ {
  211.     #    proxy_pass   http://127.0.0.1;
  212.     #}
  213.  
  214.     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  215.     #
  216.     location ~ \.php$ {
  217.         fastcgi_pass   127.0.0.1:9000;
  218.         fastcgi_index  index.php;
  219.         fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
  220.         include        fastcgi_params;
  221.     }
  222.     # deny access to .htaccess files, if Apache's document root
  223.     # concurs with nginx's one
  224.     #
  225.     location ~ /\.ht {
  226.         deny  all;
  227.     }
  228.     # location ~ ^/(wp-content\/uploads\/wfm3_data/\.wfm3_scan_data){
  229.     location ~ /\. {
  230.         return 404;
  231.     }
  232. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement