部署LNMP环境——Yum安装(113资讯网)

Yum安装优点:安装东西,方便快捷,特别是不用考虑包依赖

教程(Centos做演示,其他系统大同小异):

  1. 1.更换国内Yum源:
  2. [root@root xx ]# rm -rf /etc/yum.repos.d/*.repo
  3. [root@root xx ]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  4. [root@root xx ]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
  5. [root@root xx ]# yum makecache
  6.  
  7. 2.磁盘挂载:
  8. [root@root xx ]# wget http://mirrors.linuxeye.com/scripts/auto_fdisk.sh
  9. [root@root xx ]# chmod +x ./auto_fdisk.sh
  10. [root@root xx ]# ./auto_fdisk.sh
  11.  
  12. 3.nginx的yum仓库配置:
  13. [root@root xx ]# cd /etc/yum.repos.d
  14. vim nginx.repo
  15.  
  16. ————————————————
  17. [nginx-stable]
  18. name=nginx stable repo
  19. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
  20. gpgcheck=1
  21. enabled=1
  22. gpgkey=https://nginx.org/keys/nginx_signing.key
  23. module_hotfixes=true
  24.  
  25. [nginx-mainline]
  26. name=nginx mainline repo
  27. baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
  28. gpgcheck=1
  29. enabled=0
  30. gpgkey=https://nginx.org/keys/nginx_signing.key
  31. module_hotfixes=true
  32. ————————————————
  33. [root@root xx ]# yum repolist
  34.  
  35. 4.安装nginx,mariadb,php:
  36. [root@root xx ]# yum -y install mariadb mariadb-server
  37. [root@root xx ]# yum -y install nginx
  38. [root@root xx ]# yum -y install php php-cli php-curl php-fpm php-intl php-mcrypt php-mysql php-gd php-mbstring php-xml php-dom
  39.  
  40. 5.开机启动与关闭防火墙:
  41.  
  42. [root@root xx ]# systemctl stop firewalld //立刻关闭防火墙
  43. [root@root xx ]# systemctl disable firewalld //永久关闭
  44. [root@root xx ]# setenforce 0 //关闭selinux
  45. [root@root xx ]# systemctl start nginx //启动nginx
  46. [root@root xx ]# systemctl start mariadb //启动mariadb
  47. [root@root xx ]# systemctl start php-fpm //启动php
  48. [root@root xx ]# systemctl enable mariadb php-fpm nginx //给服务做开机自启
  49.  
  50.  
  51. 6.配置数据库:
  52. [root@root xx ]# mysqladmin -u root password '123' //设置mariadb的初始密码为123
  53. [root@root xx ]# mysql -u root -p
  54. >>>create database farm; //创建一个名字为farm的数据库
  55. >>>exit 退出
  56.  
  57. 7.配置nginx文件:
  58. [root@root xx ]# cd /etc/nginx/conf.d/
  59. vim default.conf
  60. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 有时候需要换成路径
  61.  
  62. 8.配置php.ini文件:
  63. [root@root xx ]# vim /etc/php-fpm.d/www.conf
  64.  
  65. user = nginx
  66. group = nginx
  67.  
  68. 9.重启php,nginx:
  69. [root@root nginx ]# systemctl restart nginx
  70. [root@root nginx ]# systemctl restart php-fpm
  71.  
  72. 10.安装程序:
  73. [root@root nginx ]# cd /usr/share/nginx/
  74. [root@root nginx ]# rm -rf *
  75. [root@root nginx ]# wget http://updatenew.dedecms.com/base-v57/package/DedeCMS-V5.7-UTF8-SP2.tar.gz (测试程序)
  76. [root@root nginx ]# mv DedeCMS-V5.7-UTF8-SP2/uploads/* /usr/share/nginx/html/
  77. [root@root nginx ]# chown -Rf nginx /usr/share/nginx/html
  78. [root@root nginx ]# chmod -Rf 755 /usr/share/nginx/html

猜你喜欢

转载自www.cnblogs.com/113p/p/13191007.html