- 准备环境
- 1.nginx编译安装
- 2.mysql编译安装略
- 3.php7.4.24编译安装略
- 4.综合配置
- 5.web访问页面
Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器。 Mysql是一个小型关系型数据库管理系统。 PHP是一种在服务器端执行的嵌入HTML文档的脚本语言 lnmp是linux+nginx+mysql+php是针对于访问量很大的web构架,成为一个免费、高效、扩展性强的网站服务系统准备环境
nginx包下载
#安装环境工具包 [root@nginx ~]# yum -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++ [root@nginx ~]# yum -y groups mark install 'Development Tools' #创建系统用户 [root@nginx ~]# useradd -r -M -s /sbin/nologin nginx #下载nginx [root@nginx ~]# cd /usr/src/ [root@nginx src]# wget https://nginx.org/download/nginx-1.20.1.tar.gz #编译安装nginx [root@nginx src]# tar -xf nginx-1.20.1.tar.gz [root@nginx src]# cd nginx-1.20.1/ [root@nginx nginx-1.20.1]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log [root@nginx nginx-1.20.1]# make -j $(grep 'processor' /proc/cpuinfo |wc -l) && make install #环境变量配置 [root@nginx ~]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh [root@nginx ~]# source /etc/profile.d/nginx.sh [root@nginx ~]# which nginx /usr/local/nginx/sbin/nginx #开机自启 [root@nginx ~]# cat /usr/lib/systemd/system/nginxd.service [Unit] Description=Nginx server daemon After=network.target [Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginx ExecStop=/usr/local/nginx/sbin/nginx -s stop ExecReload=/bin/kill -HUP $MAINPID KillMode=process [Install] WantedBy=multi-user.target [root@nginx ~]# systemctl daemon-reload
nginx命令语法
#查看版本 [root@nginx ~]# nginx -v nginx version: nginx/1.20.1 #查看配置文件语法错误 [root@nginx ~]# nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful -c:指定配置文件路径 -s:发送控制服务信号,可选值:{stop|quit|reopen|reload}
启动|关闭|重新加载nginx
[root@nginx ~]# nginx //启动 [root@nginx ~]# nginx -s stop //关闭 [root@nginx ~]# nginx -s reload //重启 [root@nginx ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 0 128 0.0.0.0:802.mysql编译安装略
mysql编译安装
3.php7.4.24编译安装略php编译安装
4.综合配置
nginx配置
[root@nginx ~]# cat /usr/local/nginx/html/index.php [root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf location / { root html; index index.php index.html index.htm; #添加在开头index.php格式 } location ~ .php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param script_FILENAME /usr/local/nginx/html$fastcgi_script_name; #scripts修改成web访问路径 include fastcgi_params; }
php配置
[root@nginx ~]# vim /usr/local/php7/etc/php-fpm.d/www.conf ; will be used. user = nginx group = nginx
重启所有服务
[root@nginx ~]# systemctl restart nginxd [root@nginx ~]# service php-fpm reload [root@nginx ~]# systemctl restart mysqld.service5.web访问页面
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)