单台部署LNMP架构

单台部署LNMP架构

/ 安装Nginx /
[root@jx_001 ~]# vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch
gpgcheck=0
enabled=1
[root@jx_001 ~]# yum makecache
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile

  • base: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    base | 3.6 kB 00:00:00
    epel | 3.2 kB 00:00:00
    extras | 3.4 kB 00:00:00
    nginx | 2.9 kB 00:00:00
    updates | 3.4 kB 00:00:00
    (1/3): nginx/x86_64/primary_db | 42 kB 00:00:00
    (2/3): nginx/x86_64/other_db | 23 kB 00:00:01
    (3/3): nginx/x86_64/filelists_db | 58 kB 00:00:02
    元数据缓存已建⽴
    [root@jx_001 ~]# yum -y install nginx
    ......

    验证中 : 1:nginx-1.14.2-1.el7_4.ngx.x86_64
    1/1
    已安装:
    nginx.x86_64 1:1.14.2-1.el7_4.ngx
    完毕!
    [root@jx_001 ~]# systemctl start nginx ---开启nginx服务
    [root@jx_001 ~]# systemctl enable nginx ---设置nginx服务开机⾃启动
    / 安装MariaDB数据库 /
    / 安装PHP环境 /
    / 整合 /
    -nginx设置
    Created symlink from /etc/systemd/system/multiuser.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
    ##确定ip地址, 并在浏览器中访问, 得到欢迎⻚⾯即代表成功!
    [root@jx_001 ~]# yum -y install mariadb-server mariadb
    ......
    [root@jx_001 ~]# systemctl start mariadb
    [root@jx_001 ~]# systemctl enable mariadb
    Created symlink from /etc/systemd/system/multiuser.target.wants/mariadb.service to
    /usr/lib/systemd/system/mariadb.service.
    [root@jx_001 ~]#
    [root@jx_001 ~]# mysqladmin -uroot -p password "123456"
    Enter password:
    [root@jx_001 ~]# mysql -uroot -p"123456"
    Welcome to the MariaDB monitor. Commands end with ; or \g.
    Your MariaDB connection id is 3
    Server version: 5.5.60-MariaDB MariaDB Server
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    Type 'help;' or '\h' for help. Type '\c' to clear the current input
    statement.
    MariaDB [(none)]> exit
    Bye
    [root@jx_001 ~]#
    [root@jx_001 ~]# yum -y install php php-devel php-fpm php-xml php-mbstring
    php-mcrypt php-gd php-mysql
    [root@jx_001 ~]# systemctl start php-fpm
    [root@jx_001 ~]# systemctl enable php-fpm
    Created symlink from /etc/systemd/system/multi-user.target.wants/phpfpm.service to /usr/lib/systemd/system/php-fpm.service.
    -mariadb设置

    vi /etc/nginx/conf.d/default.conf

    server {
    listen 80;
    server_name localhost;
    location / {
    root /usr/share/nginx/html;
    index index.php index.html index.htm;
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /usr/share/nginx/html;
    }
    location ~ .php$ {
    root /usr/share/nginx/html;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }
    }

    systemctl restart nginx

    增加php⾸⻚并进⾏测试

    vi /usr/share/nginx/html/index.php

    <?php phpinfo(); ?>
    在浏览器中访问主机IP地址,查看是否能够访问到PHP的信息
    [root@jx_001 ~]# mysql -uroot -p'123456'
    Welcome to the MariaDB monitor. Commands end with ; or \g.
    Your MariaDB connection id is 4
    Server version: 5.5.60-MariaDB MariaDB Server
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    Type 'help;' or '\h' for help. Type '\c' to clear the current input
    statement.
    MariaDB [(none)]> create database wordpress;
    Query OK, 1 row affected (0.01 sec)
    测试代码:
    MariaDB [(none)]> exit
    Bye
    [root@jx_001 ~]# vi /usr/share/nginx/html/index.php
    写⼊下⽅测试代码
    <?php
    $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    if (!$link) {
    die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';
    mysql_close($link);
    ?>
    ##项⽬上线流程
    [root@jx_001 ~]# curl -o wordpress.tar.gz
    https://wordpress.org/latest.tar.gz
    % Total % Received % Xferd Average Speed Time Time Time
    Current
    Dload Upload Total Spent Left
    Speed
    100 10.0M 100 10.0M 0 0 487k 0 0:00:21 0:00:21 --:--:--
    748k
    [root@jx_001 ~]#
    [root@jx_001 ~]# ls
    anaconda-ks.cfg wordpress.tar.gz
    [root@jx_001 ~]# tar xf wordpress.tar.gz
    [root@jx_001 ~]# ls
    anaconda-ks.cfg wordpress wordpress.tar.gz
    [root@jx_001 ~]# cp -rf wordpress/* /usr/share/nginx/html/
    [root@jx_001 ~]# cd /usr/share/nginx/html/
    [root@jx_001 html]# ls
    index.php wp-activate.php wp-comments-post.php wp-cron.php
    wp-load.php wp-settings.php xmlrpc.php
    license.txt wp-admin wp-config-sample.php wp-includes
    wp-login.php wp-signup.php
    readme.html wp-blog-header.php wp-content wp-links-opml.php
    wp-mail.php wp-trackback.php
    [root@jx_001 html]# mv wp-config-sample.php wp-config.php
    [root@jx_001 html]# vi wp-config.php
    // MySQL settings - You can get this info from your web host //
    / The name of the database for WordPress */
    define('DB_NAME', 'wordpress'); --数据库名称
    /* MySQL database username /
    访问到下⽅⻚⾯即代表成功
    define('DB_USER', 'root'); --数据库⽤户名
    /
    MySQL database password */
    define('DB_PASSWORD', '123456'); --数据库⽤户的密码

转载于:https://blog.51cto.com/14173127/2353154

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值