资讯专栏INFORMATION COLUMN

基于centos7进行yum安装lnmp linux+nginx+php7.1+mysql5.7

Richard_Gao / 1146人阅读

摘要:环境搭建基于进行安装作者原文的安装安装安装最新源安装启动设置服务器开机自启动检查开机自动是否设置成功浏览器中输入公网检测是否安装成功使用安装安装源安装启动检查启动是否正常或者设置服务开机自启动检查开机自启

centos7环境搭建 基于centos7进行yum安装lnmp linux+nginx+php7.1+mysql5.7
作者:studytime
原文:https://www.studytime.xin/
yum的安装
yum update
yum安装nginx

安装nginx最新源

yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum repolist enabled | grep "nginx*"     

安装nginx

yum -y install nginx  

启动nginx

service nginx start

设置nginx服务器开机自启动

systemctl enable nginx.service

检查开机自动是否设置成功

systemctl list-dependencies | grep nginx

浏览器中输入公网ip,检测是否安装成功

http://00.00.00.00/

使用yum安装mysql5.7

安装mysql源

yum -y localinstall  http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"

安装mysql

yum -y install mysql-community-server install mysql-community-devel 

启动mysql

service mysqld start

检查mysql启动是否正常

service mysqld status 或者 ps -ef | grep mysql

设置mysqld服务开机自启动

systemctl enable mysqld.service

检查mysqld开机自启动是否设置成功

systemctl list-dependencies | grep mysqld

mysql5.7以后的争强了安全机制, 所以使用yum安装,启动会系统会自动生成一个随机的密码,修改mysql密码
查看mysql的随机密码

grep "temporary password" /var/log/mysqld.log

使用查询得到的随机密码在终端登录

mysql -u root -p    更改密码(mysql文档规定,密码必须包括大小写字母数字加特殊符号>8位)
ALTER USER "root"@"localhost" IDENTIFIED BY "Yourpassword";

退出mysql客户端,用刚才修改的密码登录确保密码修改成功

exit;
mysql -u root -p  

安装php7.1

安装php源

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

检查源是否安装成功

 yum repolist enabled | grep "webtatic*"

安装php扩展源

yum -y install php71w php71w-fpm
yum -y install php71w-mbstring php71w-common php71w-gd php71w-mcrypt
yum -y install php71w-mysql php71w-xml php71w-cli php71w-devel
yum -y install php71w-pecl-memcached php71w-pecl-redis php71w-opcache

验证php7.1.x和扩展是否安装成功
验证php是否安装成功

php -v 

验证对应的扩展是否安装成功

php -m

设置php-fpm并检测php-fpm的运行状态
启动php-fpm

service php-fpm start

检查启动是否成功

 service php-fpm status   

设置开机自启动

systemctl enable php-fpm.service

检查开机自启动是否设置成功

systemctl list-dependencies | grep php-fpm
ps -ef | grep php-fpm

nginx配置如下:

server{
    listen       80;
    server_name  youserver;
    index index.html index.php;
    root /home/public;
    #charset koi8-r;
    #access_log  logs/host.access.log  main;
    location / {
        index  index.html index.htm index.php;
        try_files $uri $uri/ /index.php?$query_string;
     }
    error_page  404              /404.html;
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ .php$ {
    #    proxy_pass   http://127.0.0.1;
    #}
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ .php$ {
        root           /home/public;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /home/public$fastcgi_script_name;
        include        fastcgi_params;
}
    # deny access to .htaccess files, if Apache"s document root
    # concurs with nginx"s one
    #
    location ~ /.ht {
        deny  all;
    }
}

更多精彩内容,请关注作者博客,https://studytime.xin

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/28417.html

相关文章

  • 基于centos7进行yum安装lnmp linux+nginx+php7.1+mysql5.7

    摘要:环境搭建基于进行安装作者原文的安装安装安装最新源安装启动设置服务器开机自启动检查开机自动是否设置成功浏览器中输入公网检测是否安装成功使用安装安装源安装启动检查启动是否正常或者设置服务开机自启动检查开机自启 centos7环境搭建 基于centos7进行yum安装lnmp linux+nginx+php7.1+mysql5.7 作者:studytime原文:https://www.stu...

    zeyu 评论0 收藏0
  • 基于centos7进行yum安装lnmp linux+nginx+php7.1+mysql5.7

    摘要:环境搭建基于进行安装作者原文的安装安装安装最新源安装启动设置服务器开机自启动检查开机自动是否设置成功浏览器中输入公网检测是否安装成功使用安装安装源安装启动检查启动是否正常或者设置服务开机自启动检查开机自启 centos7环境搭建 基于centos7进行yum安装lnmp linux+nginx+php7.1+mysql5.7 作者:studytime原文:https://www.stu...

    yanest 评论0 收藏0
  • centos7安装LNMPnginx+PHP7.1.9+mysql5.7

    摘要:开发这个分支的原因之一是甲骨文公司收购了后,有将闭源的潜在风险。可以完全兼容,可以成为的替代品。提供了更好的进程管理方式,可以有效控制内存和进程可以平滑重载配置。新版已经集成了,可以直接使用。 编译安装LNMP 准备工作 安装gcc yum -y install gcc-c++ 1、安装nginx 安装pcre-devel yum -y install pcre-devel 安装gzi...

    EsgynChina 评论0 收藏0
  • centos7安装LNMPnginx+PHP7.1.9+mysql5.7

    摘要:开发这个分支的原因之一是甲骨文公司收购了后,有将闭源的潜在风险。可以完全兼容,可以成为的替代品。提供了更好的进程管理方式,可以有效控制内存和进程可以平滑重载配置。新版已经集成了,可以直接使用。 编译安装LNMP 准备工作 安装gcc yum -y install gcc-c++ 1、安装nginx 安装pcre-devel yum -y install pcre-devel 安装gzi...

    Big_fat_cat 评论0 收藏0
  • centos7安装LNMPnginx+PHP7.1.9+mysql5.7

    摘要:开发这个分支的原因之一是甲骨文公司收购了后,有将闭源的潜在风险。可以完全兼容,可以成为的替代品。提供了更好的进程管理方式,可以有效控制内存和进程可以平滑重载配置。新版已经集成了,可以直接使用。 编译安装LNMP 准备工作 安装gcc yum -y install gcc-c++ 1、安装nginx 安装pcre-devel yum -y install pcre-devel 安装gzi...

    sean 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<