ubuntu二级域名转发和同时附上php java同时存在环境

目前项目以部署了一套java web环境,但后来想在work.域名.com部署一套PHP 工作流系统

一.前言

在阿里云域名设置二级域名

部署号java 环境(tomcat MysqL java sdk),[若不熟悉可见jdk tomcat mysql安装]

然后www.域名.com,访问成功

二.安装PHP

sudo apt-get install PHP5 libapache2-mod-PHP5
sudo /etc/init.d/apache2 restart(重启apache)

三.安装apache2

1.输入命令:sudo apt-get install apache2即可安装,

安装完后,打开浏览器,在地址栏输入:localhost或者http://127.0.0.1
看到It works,表示安装成功!
认根目录:/var/www/

2.让apache和PHP支持PHP


sudo apt-get install libapache2-mod-auth-MysqL
sudo apt-get install PHP5-MysqL
sudo /etc/init.d/apache2 restart(重启apache)

3.然后在/var/www/ 下新建test.PHP,如下内容上传后,访问,会提示成功

<?PHP 
echo "PHP 程序.....start MysqL connect..."; 
try{      
  
#$link=MysqL_connect("120.26.130.20","root","1314159"); 
$link=MysqL_connect("127.0.0.1","1314159"); 
if(!$link) echo "FAILD!连接错误用户名密码不对"; 
else echo "OK!可以连接"; 
}catch(PDOException $e){  
    echo "error".$e->getMessage()."</br>";  
    die();  
}  

?> 
4.将apache2 端口设置8081

在ports.conf 设置Listen 8081,并sites-available/000-defaut.conf设置<VirtualHost *:8081>

并将 tomcat 设置8080;

四.安装Nginx

1. apt-get install Nginx

2.访问 会 提示Nginx 成功

3./etc/Nginx/sites-available/default替换server 节点

server {  
    listen       80;  
    server_name  域名.com;  
    location / {  
        proxy_pass http://localhost:8080/;  
        proxy_set_header   Host    $host;  
        proxy_set_header   X-Real-IP   $remote_addr;  
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;  
    }  
}server {  
    listen       80;  
    server_name  www.域名.com;  
    location / {  
       proxy_pass http://localhost:8080/;  
        proxy_set_header   Host    $host;  
        proxy_set_header   X-Real-IP   $remote_addr;  
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;  
    }  
}  
server {  
    listen       80;  
    server_name  work.域名.com;  
    location / {  
        proxy_pass http://localhost:8081/;  
        proxy_set_header   Host    $host;  
        proxy_set_header   X-Real-IP   $remote_addr;  
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;  
    }  
}  
server {  
    listen       80;  
    server_name  www.work.域名.com;  
    location / {  
        proxy_pass http://localhost:8081/;  
        proxy_set_header   Host    $host;  
        proxy_set_header   X-Real-IP   $remote_addr;  
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;  
    }  
}  

参考资料

1.service Nginx status

etc/init.d/MysqLd start

sudo /etc/init.d/apache2 restart

2.手把手教你在ubuntu上安装apache和mysql和php

相关文章

ubuntu退出redis的示例:指定配置文件方式启动源码redis:roo...
ubuntu中mysql改密码忘了的解决方法:1.在终端中切换到root权...
ubuntu安装mysql失败的解决方法原因:可能是原有的MySQL还有...
使用centos和ubuntu建站的区别有以下几点1.CentOS是Linux发行...
ubuntu图形界面和字符界面切换的方法:可以通过快捷键CTRL+A...
ubuntu中重启mysql失败的解决方法1.首先,在ubuntu命令行中,...