美文网首页
manjaro 安装LNMP开发环境

manjaro 安装LNMP开发环境

作者: AGEGG | 来源:发表于2020-06-13 17:05 被阅读0次

    1.升级Arch Linux

    sudo pacman -Syu

    2.安装nginx

    2.1:安装nginx-mainline
    sudo pacman -S nginx-mainline
    2.2:启动nginx
    sudo systemctl start nginx
    2.3:测试nginx:浏览器打开127.0.0.1
    nginx -v

    3.安装mariaDB

    3.1:安装mariadb
    sudo pacman -S mariadb
    3.2:在启动MariaDB服务之前,需要用下面的mysql_install_db命令初始化MariaDB的数据目录
    sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
    3.3:启动mariadb
    sudo systemctl start mysqld
    3.4:运行安全脚本
    sudo mysql_secure_installation

    #执行这个脚本
    [root]$ /usr/bin/mysql_secure_installation
    #输入root(mysql)的密码。默认没有,直接回车
    Enter current password for root (enter for none): 
    #是否切换到unix套接字身份验证[Y/n]
    Switch to unix_socket authentication [Y/n] n
    #是否设置root密码
    Change the root password? [Y/n]
    #如果选Y,就输入2次密码
    New password:
    Re-enter new password:
    #是否删除匿名用户?(就是空用户),建议删除
    Remove anonymous users? [Y/n]
    #是否不允许远程root登录
    Disallow root login remotely? [Y/n]
    #是否删除test数据库
    Remove test database and access to it? [Y/n]
    #是否加载权限使之生效
    Reload privilege tables now? [Y/n]
    

    4.安装php

    4.1:安装php
    sudo pacman -S php-fpm
    4.2:编辑nginx使用php-fpm
    sudo vim /etc/nginx/nginx.conf

    找到location ~ .php$这部分的配置,将这部分配置修改成如下:

    location ~ \.php$ {
                root           /usr/share/nginx/html;
                fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }
    

    4.3:启动php
    sudo systemctl start php-fpm
    4.4:测试php
    sudo vim /usr/share/nginx/html/test.php
    在文件中添加如下PHP代码。
    <?php phpinfo(); ?>
    保存文件重新加载nginx
    sudo systemctl reload nginx
    查看127.0.0.1/test.php

    4.5:启用PHP拓展
    sudo vim /etc/php/php.ini
    找到如下两行文字,去掉前面的;符号以启用mysqli和pdo_mysql。

    ;extension=mysqli.so
    ;extension=pdo_mysql.so
    
    data.timezone = Asia/Shanghai
    

    5.安装redis

    安装redis
    sudo pacman -S redis
    启动redis
    sudo systemctl start redis

    6.添加自启

    sudo systemctl enable nginx
    sudo systemctl enable mysqld
    sudo systemctl enable php-fpm
    sudo systemctl enable redis
    

    systemctl restart network

    安装php gd拓展
    yay -S php-gd

    参考地址:https://www.linuxdashen.com/install-lemp-nginx-mariadb-php7-arch-linux-server

    https://www.linuxbabe.com/linux-server/install-lemp-nginx-mariadb-php7-arch-linux-server

    相关文章

      网友评论

          本文标题:manjaro 安装LNMP开发环境

          本文链接:https://www.haomeiwen.com/subject/pcpvtktx.html