ubuntu下安装nginx+php 遇到的问题 并且与tomcat共存

1、安装nginx

apt install nginx

2、安装php7.0

apt install php7.0

3、php7.0-fpm(php与nginx之间的连接器)

apt install php7.0-fpm

4、配置文件/etc/nginx/sites-enabled/default

location ~ \.php$ {
                root    /var/www/html;                                  #php文件所在的根目录
                fastcgi_pass 127.0.0.1:9000;                      #fpm监听的IP和端口
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;

        }

5、启动两个进程

service nginx start

service php7.0-fpm start

6、编辑目录/var/www/html文件

7、启动nginx时遇到的问题

查看nginx启动失败的原因:systemctl status nginx.service


这是配置文件4的问题,我的配置文件如下:


8、nginx与tomcat可以共存,只需要端口号不一样就可以

9、tomcat重启服务

编辑文件vim /etc/init.d/tomcat

cd /root/temp/apache-tomcat-8.5.29/
#./bin/startup.sh

case "$1" in
    start)
    ./bin/startup.sh
    exit 1;;

    stop)
    ./bin/shutdown.sh
    exit 1;;
esac

启动:/etc/init.d/tomcat start

查看tomcat是否启动:ps -ef |grep tomcat

停止进程:pkill -9 tomcat

占用80端口的:netstat -na | grep 80

猜你喜欢

转载自blog.csdn.net/yangyun_1999/article/details/79759007