zcmimi's blog

配置数据库

自2013年起,MariaDB就被Arch Linux当作官方默认的MySQL实现

所以请使用MariaDB

参考archlinux wiki官方说明

首先安装mariadb,mariadb-libs:

sudo pacman -S mariadb mariadb-libs

在启动mariadb.service前必须运行该命令:

sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

启动mariadb.service:

sudo systemctl enable mariadb.service
sudo systemctl start mariadb.service

数据库配置完毕

配置php与nginx

安装php,php-fpm,nginx:

sudo pacman -S php php-fpm nginx

启用开机自启服务,并启动服务:

sudo systemctl enable php-fpm
sudo systemctl enable nginx

sudo systemctl start php-fpm
sudo systemctl start nginx

接下来修改php-fpmnginx运行用户以正常访问文件

修改php-fpm运行用户:

编辑/etc/php/php-fpm.d/www.conf,修改user=为自己的用户,group=可选

修改nginx运行用户:

修改user行为user root或自己的用户

Nginx配置网站

建议在/etc/nginx/nginx.conf中引入:

# include /etc/nginx/conf.d/*.conf;
# include /etc/nginx/sites-enabled/*;
include /home/zcmimi/data/nginx/*; # 在引入用户(zcmimi)自定义目录下配置文件,请自行修改

静态网站配置示例:

server {
    listen 80;
    server_name  localhost;
    charset utf-8;
    #access_log  logs/host.access.log  main;
    location / {
        root /home/zcmimi/data/CX/blog/web/;
        index  index.html index.htm;
    }
    error_page  404 /404.html;
}

PHP动态网站配置示例:

server {
    listen 80;
    server_name  localhost;
    #charset utf-8;
    #access_log  logs/host.access.log  main;
    root /data/web/phpinfo/;
    index index.php index.html index.htm;
    location ~ \.php$ {
        # 404
        try_files $fastcgi_script_name =404;

        # default fastcgi_params
        include fastcgi_params;

        # fastcgi settings
        fastcgi_pass            unix:/run/php-fpm/php-fpm.sock;
        fastcgi_index           index.php;

        # fastcgi params
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        fastcgi_param SCRIPT_FILENAME   $realpath_root$fastcgi_script_name;
    }    
}

参考:

作者:zcmimi

链接:https://blog.zcmimi.top/posts/archlinux-nginx+php+mariadb/

声明: 本博客所有文章除特别声明外,均采用CC BY-NC-SA 3.0许可协议. 转载请注明来自zcmimi's blog

archlinux搭建Nginx+PHP+MariaDB环境
comment评论
Search
search