LNMP:linux,nginx,mysql,php
安装mariadb:(可以理解为mysql的其他版本)
yum -y install mariadb mariadb-server mariadb-devel
# mariadb是客户端
# mariadb-server是服务器安装
# mariadb-devel是依赖包
安装php:
yum -y install php php-mysql php-fpm
# php是解释器
# php-mysql是mysql的拓展包
# php-fpm是服务
# 每一个php-fpm进程大概占用25M内存。
systemctl start php-fpm # 启动php服务
PHP配置:
# php配置文件 /etc/php-fpm.d/www.conf,主要配置信息如下:
[www]
listen = 127.0.0.1:9000 #端口
pm.max_children = 32 #最大进程数
pm.start_serrvers = 15 #最小进程数
pm.min_spare_servers = 5 #最小空闲进程数
pm.max_spare_servers = 32 #最大空闲进程数
Nginx配置:
nginx配置在 /usr/local/nginx/conf/nginx.conf
修改server下的location
location相当于if判断,用于匹配用户在浏览器地址栏中的地址。
例如:location /abc { xxxxx; } ---> http://192.168.4.10/abc 然后执行{ xxxxx; }
静态网页匹配:(默认是根目录/,http://192.168.4.10/)
location / {
root html; #documentRoot,文件目录
index index.html; #默认文件为index.html
}
匹配php:
location ~ \.php$ { # 这里的~代表是正则匹配,$表示结尾,表示以.php为结尾
root html/php_test; # 文件根目录
fastcgi_pass 127.0.0.1:9000; # 将请求转发给这个进程去处理
fastcgi_index index.php; # 默认首页,index.php
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # $document_root表示到根目录下 html/php_test 去找对应的php文件
include fastcgi_params;
}
重启nginx服务:nginx -s reload
写总结的第十五天!!!