apache2上面有php服务器已经配置好的。只是想用Nginx代理apache2.
Nginx上有Tomat服务器,代理后就相当于有PHP服务器,JSP服务器,还有一个静态博客
1:修改apache2端口
vim /etc/apache2/ports.conf
添加下面代码
NameVirtualHost *:9000
Listen 9000
2:vim sites-available/000-default.conf
先删除原先的代码,把下面代码复制进去
<VirtualHost *:80>
ServerName nextcloud.saiita.cn
ServerAdmin webmaster@localhost
DocumentRoot /var/www/nextcloud
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
3:安装nginx
sudo apt-get install nginx
4:vim /etc/nginx/sites-enabled/defult
删除原先的配置代码,把下面代码复制进去
# Hexo 博客
server {
listen 80;
listen [::]:80;
server_name www.saiita.cn;
root /var/www/blog/public;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
#Tomcat 服务器
server {
listen 80;
listen [::]:80;
server_name map.saiita.cn;
root /var/www/map/webapps/ROOT;
index index.html index.jsp index.jspx;
location ~ .(jsp|jspx|do|action)?$
{
#==========Nginx提供的代理============
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#=== 如果遇到.jsp .jspx .do .action 的请求就进入该服务器(tomcat)===
proxy_pass http://map.saiita.cn:8080;
}
location / {
try_files $uri $uri/ =404;
}
}
# nextcloud
server {
listen 80;
server_name nextcloud.saiita.cn;
location / {
proxy_pass http://localhost:9000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
}
}
# phpmyadmin
#server {
# listen 80;
# server_name phpmyadmin.saiita.cn;
# location / {
# proxy_pass http://localhost:9000;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_redirect off;
# }
# }
5:重启相关程序
sudo systemctl restart php7.0-fpm nginx apache2
本作品采用知识共享署名-相同方式共享 4.0 国际许可协议进行许可。