9
archlinux搭建Nginx+PHP+MariaDB环境
source link: https://blog.zcmimi.top/posts/archlinux-nginx+php+mariadb/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
配置数据库
自2013年起,MariaDB就被Arch Linux当作官方默认的MySQL实现
所以请使用MariaDB
首先安装mariadb
,mariadb-libs
:
1
sudo pacman -S mariadb mariadb-libs
在启动mariadb.service
前必须运行该命令:
1
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
启动mariadb.service
:
1
2sudo systemctl enable mariadb.service sudo systemctl start mariadb.service
数据库配置完毕
配置php与nginx
安装php
,php-fpm
,nginx
:
1
sudo pacman -S php php-fpm nginx
启用开机自启服务,并启动服务:
1
2
3
4
5sudo systemctl enable php-fpm sudo systemctl enable nginx sudo systemctl start php-fpm sudo systemctl start nginx
接下来修改php-fpm
与nginx
运行用户以正常访问文件
修改php-fpm
运行用户:
编辑/etc/php/php-fpm.d/www.conf
,修改user=
为自己的用户,group=
可选
修改nginx
运行用户:
修改user
行为user root
或自己的用户
Nginx配置网站
建议在/etc/nginx/nginx.conf
中引入:
1
2
3# include /etc/nginx/conf.d/*.conf; # include /etc/nginx/sites-enabled/*; include /home/zcmimi/data/nginx/*; # 在引入用户(zcmimi)自定义目录下配置文件,请自行修改
静态网站配置示例:
1
2
3
4
5
6
7
8
9
10
11server { 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动态网站配置示例:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23server { 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; } }
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK