LNMP

1.编译安装LNMP---重点

了解
静态网站:.html   htm    jpg   mp4


动态网站: .php .jsp






L     Linux
N     nginx
M     数据库
P     php


1.yum方式







2.编译方式


环境:虚拟机

ip:10.0.1.0

网关:10.0.1.2

子网掩码:255.255.255.0

测试机器ip:10.0.1.102

tips:机器不可以有nginx,所以这里建议你重新开个新机器或者克隆一个模版机 




#步骤
tips:安装时如果没有依赖包,这时就要更新一下yum源了

没有更新yum源的,可以更新一下

1. 备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2. 下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/

2.1各版本
centos8

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo


centos6
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo


CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo



3.各版本epel源

3.1 备份(如有配置其他epel源)
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup

3.2 下载新repo 到/etc/yum.repos.d/

epel(RHEL 8)
1)安装 epel 配置包

yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm

2)将 repo 配置中的地址替换为阿里云镜像站地址
sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*



epel(RHEL 7)

wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo


epel(RHEL 6) (epel6官方源已下线,建议切换epel-archive源)

wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-archive-6.repo



4.更新缓存和软件
yum clean all
yum makecache
yum update


tips:建议在这里设置一下虚拟机快照,不然每次都要这样,会很耽误时间








编译安装--lnmp
#0. 安装开发包
yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel

1.1#安装一下gcc编译工具和依赖
yum -y install pcre-devel  openssl-devel zlib-devel gcc
1.2#创建用户组和设置此用户组不可以登录(如果你有了,就不用创建了)
groupadd nginx
useradd -g nginx -s /sbin/nologin nginx
1.3#解压一下(一般你自己选个解压目录,便于管理和配置)
切换到解压后的nginx目录中执行:
cd /usr/local/src
wget http://nginx.org/download/nginx-1.18.0.tar.gz

解压压缩包
tar zxvf nginx-1.18.0.tar.gz    (解压)

tar zcvf nginx-1.18.0.tar.gz   (压缩)


1.4#编译一下他的用户和所属组以及配置安装路径--生成马克file文件
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module



注解:
您提供的命令是对 ./configure 脚本的调用,该脚本通常位于采用 GNU Autotools 构建系统的软件项目源代码目录中。这个脚本用于为项目的编译和安装做前期准备,根据用户提供的配置选项生成相应的 Makefile 文件。具体到您给出的命令:

[root@node-1 ~]
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx \
--with-http_ssl_module --with-http_stub_status_module


各个选项含义如下:

- --user=nginx: 指定编译安装后,Nginx 服务运行时所属的系统用户为 nginx。这意味着当 Nginx 服务启动时,将以 nginx 用户的身份运行。

- --group=nginx: 指定编译安装后,Nginx 服务运行时所属的系统组为 nginx。这意味着当 Nginx 服务启动时,将以 nginx 组的成员身份运行。

- --prefix=/usr/local/nginx: 设置 Nginx 的安装目录为 /usr/local/nginx。这意味着编译完成后,Nginx 的可执行文件、配置文件、库文件、文档等将被安装到这个路径下。例如,Nginx 主程序通常会被安装到 /usr/local/nginx/sbin/nginx,配置文件则位于 /usr/local/nginx/conf/nginx.conf。

- --with-http_ssl_module: 启用 SSL/TLS 支持模块。配置此项后,编译出的 Nginx 将具备处理 HTTPS 请求的能力,允许网站提供安全的加密通信。

- --with-http_stub_status_module: 启用 stub_status 模块。该模块提供了一个简单的 HTTP 接口,可以用来查询 Nginx 服务器的基本状态信息,如当前活动连接数、处理过的请求总数等。这对于监控 Nginx 服务器的运行状态非常有用。

执行以上命令后,./configure 脚本将检查系统环境,确认依赖项是否满足,并根据指定的选项生成相应的 Makefile。接下来,用户通常会执行 make 命令编译源代码,然后执行 make install 命令将编译好的程序安装到指定的位置。这样,一个带有 SSL 支持和 stub_status 模块的 Nginx 服务器就安装完成了,并将以 nginx 用户和组的身份运行。



make  

make install  

启动nginx:/usr/local/nginx/sbin/nginx
关闭nginx:/usr/local/nginx/sbin/nginx -s stop
检查nginx 是否异常:/usr/local/nginx/sbin/nginx  -t

重启nginx: nginx  -s reload




1.5#定义一下软连接(提高效率)
每次都需要输入路径才可以重启 检查等操作比较繁琐

用软连接定义
ln -s /usr/local/nginx/sbin/nginx /bin/nginx

这样就可以了

启动  : nginx 
停止:nginx -t stop
重启 :  nginx -s reload
检查:   nginx -t








1.6 #编译php环境

cd /usr/local/src/
rz命令上传
#tips:这里上传php的源码包
tar zxvf php-7.2.29.tar.gz 

cd ./php-7.3.9


#tips:编译安装
./configure --prefix=/usr/local/php --exec-prefix=/usr/local/php --with-mysqli --with-pdo-mysql --with-gd --bindir=/usr/local/php/bin --sbindir=/usr/local/php/sbin --includedir=/usr/local/php/include --libdir=/usr/local/php/lib/php --mandir=/usr/local/php/php/man --with-config-file-path=/usr/local/php/etc --with-openssl --enable-mbstring --enable-fpm


make && make install    #编译 编译安装



cp php.ini-production /usr/local/php/etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
cp /usr/local/php/etc/php-fpm.conf.default  /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default  /usr/local/php/etc/php-fpm.d/www.conf
ln -s /usr/local/php/bin/php /usr/local/bin
echo -e "\033[31m php部署成功 \033[0m"


启动php: /etc/init.d/php-fpm start   

使用netstat -tuln 查看 如果有 9000 端口就是正常 


1.7 安装数据库

#tips:这里就用这个yum安装吧 ,编译MySQL耗时间


----------yum方式

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
 yum -y install mysql-community-server



[root@node-1 ~]#systemctl start mysql
[root@node-1 ~]#systemctl status mysql     看一下状态
[root@node-1 ~]# systemctl start mysql.service  设置自启动

ss -tulpn |grep mysql

数据库接口 3306





--------编译安装mysql 数据库


基于CentOS7  二进制安装MySQL8.0(5.7+适用)

1、创建用户
[root@node-1 ~]# groupadd mysql
[root@node-1 ~]# useradd -r -g mysql -s /usr/sbin/nologin mysql
 

2、创建目录
[root@node-1 ~]# mkdir /data/mysql -p
[root@node-1 ~]# chown -R mysql.mysql /data/mysql
 

3、准备二进制程序

[root@node-1 ~]# wget https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.32-linux-glibc2.12-x86_64.tar
--2023-06-07 10:54:29--  https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.32-linux-glibc2.12-x86_64.tar
正在解析主机 cdn.mysql.com (cdn.mysql.com)... 104.70.237.54
正在连接 cdn.mysql.com (cdn.mysql.com)|104.70.237.54|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1005660160 (959M) [application/x-tar]
正在保存至: “mysql-8.0.32-linux-glibc2.12-x86_64.tar”

100%[====================================================================================================>] 1,005,660,160 26.6MB/s 用时 29s    

2023-06-07 10:54:58 (32.8 MB/s) - 已保存 “mysql-8.0.32-linux-glibc2.12-x86_64.tar” [1005660160/1005660160])

[root@node-1 ~]# tar xvf mysql-8.0.32-linux-glibc2.12-x86_64.tar
mysql-test-8.0.32-linux-glibc2.12-x86_64.tar.xz
mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz
mysql-router-8.0.32-linux-glibc2.12-x86_64.tar.xz
[root@node-1 ~]# tar xf mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
[root@node-1 ~]# cd /usr/local
[root@node-centos7-70 local]# ln -sv mysql-8.0.32-linux-glibc2.12-x86_64 mysql
"mysql" -> "mysql-8.0.32-linux-glibc2.12-x86_64"

 

4、安装依赖包
[root@node-1 ~]# yum install -y libaio numactl-libs
 

5、设置PATH环境变量
[root@node-1 ~]# echo "PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh
[root@node-1 ~]# . /etc/profile.d/mysql.sh
 

6、创建配置文件

[root@node-1 ~]# tee > /etc/my.cnf << EOF
[mysqld]
datadir=/data/mysql
socket=/data/mysql/mysql.sock
pid-file=/data/mysql/mysql.pid
log-error=/data/mysql/mysql.log

[client]
socket=/data/mysql/mysql.sock
EOF

 

7、创建数据库文件,并提取root密码

[root@node-1 ~]# mysqld --initialize --user=mysql --datadir=/data/mysql
[root@node-1 ~]# grep password /data/mysql/mysql.log
2023-06-07T03:20:09.342795Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ,*9LyAr6wrr#
[root@node-1 ~]# awk '/temporary password/{print $NF}' /data/mysql/mysql.log 
,*9LyAr6wrr#

 

8、创建服务脚本,并启动服务
[root@node-1 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@node-1 ~]# chkconfig --add mysqld
[root@node-1 ~]# service mysqld start
Starting MySQL... SUCCESS! 
  

9、修改初始密码,测试访问数据库

[root@node-1 ~]# mysqladmin -uroot -p',*9LyAr6wrr#' password 'mysql'
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
[root@node-1 ~]# mysql -uroot -pmysql
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.32 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> 












为root账户设置数据库密码
[root@node-1 ~]#mysql_secure_installation  #初始化MySQL
Enter current password for root (enter for none):   <---输入现在的root密码,因为我们还没设置,直接回车
Set root password? [Y/n] Y                                    <---是否设定root密码,当然设置了,输入Y回车
New password:                                                      <---输入root密码,并回车,输入的过程中不会有任何显示
Re-enter new password:                                        <---再次输入root密码,并回车,输入的过程中不会有任何显示
Remove anonymous users? [Y/n] Y                      <---是否删除匿名用户,删除,输入Y回车
Disallow root login remotely? [Y/n] Y                     <---是否删禁止root用户远程登录,当然禁止,输入Y回车
Remove test database and access to it? [Y/n]      <---是否删除测试数据库test,看个人喜好
Reload privilege tables now? [Y/n] Y                    <---刷新权限,输入Y回车
最后出现:Thanks for using MySQL!
MySql密码设置完成,重新启动 MySQL:


tips:数据库密码一般设置就比较复杂的,在生产环境中,不过这里就不设置复杂的了,直接123


mysql -uroot -p"123"     #创建一个root账户的数据库密码


create database  wordpress;    #新建一个数据库

show databases;    #查看一下是否存在




1.8#修改nginx配置文件
cd /usr/local/nginx/conf
打开 多域名配置如下:

vi /usr/local/nginx/conf/nginx.conf
vim nginx.conf
参考这个配置文件

[root@web3 conf]#cat nginx.conf
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       81;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
include /usr/local/nginx/conf/vhost/*.conf; 
}

 

重启nginx 
在cd /usr/local/nginx/conf/vhost 目录新建配置文件
 
vi www.conf 添加如下

  server {
       listen        80;
       server_name   www.it.com localhost;
       location  / {
         root  /html/www;
         index index.html index.php;
       }


location ~ \.php$ {
 fastcgi_pass   127.0.0.1:9000;
 fastcgi_index  index.php;
#fastcgi_param  SCRIPT_FILENAME  /html/www$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /html/www$fastcgi_script_name;
include        fastcgi_params;        }





    }



nginx -t   检查一下
nginx  -s relaod 重启启动nginxls



#!/bin/[root@node-1 ~]
yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel
yum install -y libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel
yum install -y  glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel 
yum install -y e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers




1.9 # 检查测试一下php

vi index.php

<?php 
        phpinfo(); 
?>


nginx -t
nginx -s reload
或者  

 /usr/local/nginx/sbin/nginx -s reload
 
 
 
查看index.php页面显示
http://10.0.1.102




2.0 #测试php和mysql是否成功测试

vim test_mysql.php
       <?php
        $servername = "localhost";
        $username = "root";
        $password = "oldboy123";
        //$link_id=mysql_connect('主机名','用户','密码');
        //mysql -u用户 -p密码 -h 主机
        $conn = mysqli_connect($servername, $username, $password);
        if ($conn) {
              echo "mysql successful by root !\n";
           }else{
              die("Connection failed: " . mysqli_connect_error());
           }
       ?>
       
       
       
       

Nginx访问PHP文件的File not found错误处理,两种情况
转载 2017年05月09日 14:05:27
标签:
php /
nginx
这个错误很常见,原有有下面两种几种
php-fpm找不到SCRIPT_FILENAME里执行的php文件
php-fpm不能访问所执行的php,也就是权限问题
第一种情况
更改配置文件nginx.conf 
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 
替换成下面
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
然后重新加载nginx配置文件 
/etc/init.d/nginx reload










#tips:如果你开启了多域名的话,可能出现你的ip只会访问某一个发布目录下的网页,因为我们在主配置文件里设置了多域名引用,那么多域名引用,你用ip去访问只能显示一个,所以我么需要设置域名解析,来帮助我们识别每个网站。
如果你只能用ip访问,就需要站是把其他网站的配置文件删掉,做个备份,只用一个测试网站的配置文件





发布一个博客


1.#切换到发布目录下
cd /html/www
rz  上传你的源码包


tar 格式
tar zxvf 源码包      解压
tar zcvf 源码包      压缩

zip 格式
unzip  源码包



#tips1:上传的是zip格式的,就需要安装yum -y install unzip 来解压
#tips2:不要忘了你的nginx配置目录要配置正确的发布目录,否则会报403错误


2.配置nginx.conf ---发布目录
cd /usr/local/nginx/conf/vhost/
ls
vim www.conf


3.安装论坛  
tips:如果输入ip地址或者域名无法跳转的的话,那就复制下面我这段地址,把其他的ip地址替换你自己的就可以了或者域名



http://10.0.1.102/upload/install/

chmod -R 777 upload/      #给一下权限,如果不给的话,目录文件权限会检查到的,安装会出问题






#温馨小提示

如果出现无法连接数据库,在数据库服务器哪里输入127.0.0.1,就可以了




效果如下图

img

2.部署搭建yum--lnmp

#步骤
tips:安装时如果没有依赖包,这时就要更新一下yum源了

没有更新yum源的,可以更新一下

1. 备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2. 下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/

2.1各版本
centos8

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo


centos6
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo


CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo



3.各版本epel源

3.1 备份(如有配置其他epel源)
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup

3.2 下载新repo 到/etc/yum.repos.d/

epel(RHEL 8)
1)安装 epel 配置包

yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm

2)将 repo 配置中的地址替换为阿里云镜像站地址
sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*



epel(RHEL 7)

wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo


epel(RHEL 6) (epel6官方源已下线,建议切换epel-archive源)

wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-archive-6.repo



4.更新缓存和软件
yum clean all
yum makecache
yum update


tips:建议在这里设置一下虚拟机快照,不然每次都要这样,会很耽误时间









#1.  安装nginx 
yum install epel-release -y
yum install nginx -y
[root@node-1 ~]# systemctl start nginx.service
[root@node-1 ~]# systemctl status nginx.service  看一下状态
[root@node-1 ~]# systemctl enable nginx.service   开机自启动

#2. 安装开发包
yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel

#3.  安装数据库

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
#rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum -y install mysql-community-server


[root@node-1 ~]#systemctl start mysql
[root@node-1 ~]#systemctl status mysql     看一下状态
[root@node-1 ~]# systemctl start mysql.service  设置自启动



#3.1设置MySQL root账户的密码
tips:如果你有就不用设置了


为root账户设置密码
[root@node-1 ~]#mysql_secure_installation  #初始化MySQL
Enter current password for root (enter for none):   <---输入现在的root密码,因为我们还没设置,直接回车
Set root password? [Y/n] Y                                    <---是否设定root密码,当然设置了,输入Y回车
New password:                                                      <---输入root密码,并回车,输入的过程中不会有任何显示
Re-enter new password:                                        <---再次输入root密码,并回车,输入的过程中不会有任何显示
Remove anonymous users? [Y/n] Y                      <---是否删除匿名用户,删除,输入Y回车
Disallow root login remotely? [Y/n] Y                     <---是否删禁止root用户远程登录,当然禁止,输入Y回车
Remove test database and access to it? [Y/n]      <---是否删除测试数据库test,看个人喜好
Reload privilege tables now? [Y/n] Y                    <---刷新权限,输入Y回车
最后出现:Thanks for using MySQL!
MySql密码设置完成,重新启动 MySQL:


tips:数据库密码一般设置就比较复杂的,在生产环境中,不过这里就不设置复杂的了,直接123

#4. 安装php
 yum -y install php php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap




#4.2  安装php扩展支持mysql 
 [root@node-1 ~]# yum install  php-tidy php-common php-devel php-fpm php-mysql -y
[root@node-1 ~]# systemctl start php-fpm.service
[root@node-1 ~]# systemctl status php-fpm.service
[root@node-1 ~]# systemctl enable php-fpm.service   设置自启动




tips:有一个9000端口代表php启动了
[root@node-1 www]# ss -tulpn
Netid State      Recv-Q Send-Q      Local Address:Port                     Peer Address:Port              
tcp   LISTEN     0      128             127.0.0.1:9000                                *:*           




#4.1配置nginx
 
进入nginx 配置文件目录
tips:由于我们是yum安装的,所以配置文件都在etc下面,如果这个conf.d这个文件夹,可以新建一下,再进去创建www.conf配置文件,将内容填充进去



cd /etc/nginx/conf.d

vi www.conf 添加如下


server {
       listen        80;
       server_name   www.it.com;
       location  / {
         root  /html/www;         #发布目录                                                                                                   
         index index.html index.php;
       }
location ~ \.php$ {
 fastcgi_pass   127.0.0.1:9000;
 fastcgi_index  index.php;
fastcgi_param SCRIPT_FILENAME /html/www$fastcgi_script_name;                                      #修改成发布目录
include        fastcgi_params;        
}
    }
    
    
    
#可能会遇到的问题 
如果多域名配置没有打开 ,在这/etc/nginx/conf.d新建配置是不会生效的 

在 vi /etc/nginx/nginx.conf配置文件需要有这个配置文件才会生效 检查下
include /etc/nginx/conf.d/*.conf;
配置文件详细内容
cd /etc/nginx/
vim nginx.conf




[root@node-1 nginx]# vim nginx.conf

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;    重点就是这个位置





#5.发布测试页测试是否ok
tips:如果没有这个目录自己新建一下mkdir -p /html/www

cd  /html/www

vi index.php

将以下内容填充进去


<?php 
        phpinfo(); 
?>









效果图如下
posted @ 2024-04-01 18:26  三思博客  阅读(1)  评论(0编辑  收藏  举报