阿里云centos7进行yum安装lnmp(linux+nginx+php7.1+mysql5.7)

 

  1. 1. yum update #yum的安装
  2. yum安装nginx,安装nginx最新源
  3. 1. yum localinstall
  4. 2. rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
  5. 3. yum repolist enabled | grep "nginx*"
  6. 安装nginx
  7. 1. yum -y install nginx
  8. 启动nginx
  9. 1. service nginx start或者systemctl start nginx.service 开启nginx服务
  10. 设置nginx服务器开机自启动
  11. 1. systemctl enable nginx.service
  12. 检查开机自动是否设置成功
  13. 1. systemctl list-dependencies | grep nginx
  14. 浏览器中输入公网ip,检测是否安装成功(输入ip地址)
  15. 1.http://00.00.00.00/(阿里云公网IP地址复制粘贴回车看到Welcome Nginx即为成功)
  16. 使用yum安装mysql5.7 安装mysql源
  17. 1. yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
  18. 2. yum repolist enabled | grep "mysql.*-community.*"
  19.  
  20. 安装mysql
  21. 1. yum -y install mysql-community-server install mysql-community-devel
  22.  
  23. 启动mysql
  24. 1. service mysqld start
  25.  
  26. 检查mysql启动是否正常
  27. 1. service mysqld status 或者 ps -ef | grep mysql
  28.  
  29. 设置mysqld服务开机自启动
  30. 1. systemctl enable mysqld.service
  31.  
  32. 检查mysqld开机自启动是否设置成功
  33. 1. systemctl list-dependencies | grep mysqld
  34.  
  35. mysql5.7以后的争强了安全机制, 所以使用yum安装,启动会系统会自动生成一个随机的密码
  36. 查看mysql的随机密码
  37. 1.grep 'temporary password' /var/log/mysqld.log
  38. 使用查询得到的随机密码(输入上一条命令会出现一串字符串 例如:&s#r2q2XkiXfi,这串字符串就是随机的密码)
  39. 重新进入mysql
  40. 1. mysql -u root -p
  41. 更改密码复制下面一条命令(mysql文档规定,密码必须包括大小写字母数字加特殊符号>8位 例如:Qwe@1234)
  42. 2.ALTER USER 'root'@'localhost' IDENTIFIED BY '你要修改的密码例如:Qwe@1234';
  43. 3. exit; #退出
  44. 退出mysql客户端,用刚才修改的密码登录确保密码修改成功
  45. (重新进入mysql输入新密码确认然后复制下面的命令开启远程权限)
  46. 1.mysql -u root -p
  47. 2.输入新密码
  48. 3.mysql>
  49. 4.mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '自己8位新密码' WITH GRANT OPTION; ##开启mysql远程数据库访问权限
  50. 5.mysql>flush privileges; ##刷新权限
  51. 6.mysql>exit; ##退出
  52.  
  53. 安装php7.1 安装php源
  54. 1. rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  55. 2. rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
  56.  
  57. 检查源是否安装成功
  58. 1.yum repolist enabled | grep "webtatic*"
  59.  
  60. 安装php扩展源
  61. 1. yum -y install php71w php71w-fpm
  62. 2. yum -y install php71w-mbstring php71w-common php71w-gd php71w-mcrypt
  63. 3. yum -y install php71w-mysql php71w-xml php71w-cli php71w-devel
  64. 4. yum -y install php71w-pecl-memcached php71w-pecl-redis php71w-opcache
  65.  
  66. 验证php7.1.x和扩展是否安装成功 验证php是否安装成功
  67. 1. php -v
  68.  
  69. 验证对应的扩展是否安装成功
  70. 1. php -m #可以查看里面已近安装好的软件
  71.  
  72. 设置php-fpm并检测php-fpm的运行状态 启动php-fpm
  73. 1. service php-fpm star
  74.  
  75. 检查启动是否成功
  76. 1. service php-fpm status
  77.  
  78. 设置开机自启动
  79. 1. systemctl enable php-fpm.service
  80.  
  81. 检查开机自启动是否设置成功
  82. 1. systemctl list-dependencies | grep php-fpm
  83. 2. ps -ef | grep php-fpm
  84. 上面安装最基本的扩展包如果还想使用其他扩展包自己手动安装扩展命令
  85. 1. yum search php71w #查看所有包命令
  86. 输入安装命令:yum install php71w 空格自己想要安装的包 php71w-pdo #就能安装自己想要的包
  87. 完整命令:
  88. 2. yum install php71w php71w-pdo
  89. nginx配置如下:vim /etc/nginx/conf.d/default.conf
  90.  
  91. server{
  92. listen 80;
  93. server_name youserver;
  94. index index.html index.php;
  95. root /home/public;
  96. location / {
  97. index index.html index.htm index.php;
  98. try_files $uri $uri/ /index.php?$query_string;
  99. }
  100. error_page 404 /404.html;
  101. error_page 500 502 503 504 /50x.html;
  102. location = /50x.html {
  103. root html;
  104. }
  105. location ~ .php$ {
  106. root /home/public;
  107. fastcgi_pass 127.0.0.1:9000;
  108. fastcgi_index index.php;
  109. fastcgi_param SCRIPT_FILENAME /home/public$fastcgi_script_name;
  110. include fastcgi_params;
  111. }
  112. location ~ /.ht {
  113. deny all;
  114. }
  115. }
  116.  
  117. 不懂Nginx配置的可以百度自己搭配!
  118. Nginx里面基本操作命令
  119. ① systemctl status firewalld.service ##查看防火墙状态
  120. ② systemctl stop firewalld.service ##停止防火墙
  121. ③ systemctl disable firewalld.service ##防火墙设置开机自启服务
  122. ④ systemctl start firewalld.service ##防火墙开启服务器
  123. ⑤ systemctl restart firewalld.service ##重启防火墙服务
  124. 以上例子换成其它命令操作可以启动不同服务如:
  125. nginx
  126. php-fpm
  127. mysqld
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

韩若轩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值