6z6z软件下载中心,为您提供安全的软件下载!

首页 软件下载 端游下载 安卓专区 苹果专区 新闻资讯 游戏攻略 软件教程 小程序 专题库

当前位置:首页 > 软件教程 > 电脑教程

CentOS7上搭建Nginx+Mono运行asp.net环境的配置方法

我要评论

下面来讲讲在实操vmware架设centos7系统配置搭建Nginx+Mono运行asp.net 中CentOS7上搭建Nginx+Mono运行asp.net环境的配置方法。

相关推荐:centos7配置NAT固定IP连网教程 如何配置NAT固定IP连网

1、下载资源包

Mono下载:官网:http://download.mono-project.com/sources/mono/(请下载最新版)
命令:wget http://download.mono-project.com/sources/mono/mono-6.13.0.116.tar.xz

libgdiplus下载:http://download.mono-project.com/sources/libgdiplus/(请下载最新版)
命令:wget http://download.mono-project.com/sources/libgdiplus/libgdiplus-6.0.tar.gz

xsp下载:http://download.mono-project.com/sources/xsp/(请下载最新版)
命令:wget http://download.mono-project.com/sources/xsp/ xsp-4.7.1.tar.gz

pcre下载(找不到官网,如果下载不了或想下载新版本请自行百度)
命令:wget https://jaist.dl.sourceforge.net/project/pcre/pcre/8.44/pcre-8.44.tar.bz2

相关推荐:VMware的centos7配置NAT方式连网后主机访问外网的解决方法

2、利用系统自带的yum命令安装、升级所需的程序库:

[root@localhost]# sudo -s
[root@localhost]# LANG=C
[root@localhost]# yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel [root@localhost]# bzip2 bzip2-devel bison pkgconfig glib2-devel gettext make
[root@localhost]# yum -y install gcc gcc-c++ bison pkgconfig glib2-devel gettext make libpng-devel libjpeg-devel libtiff-devel libexif-devel giflib-devel libX11-devel freetype-devel fontconfig-devel  cairo-devel

3、安装pcre:

[root@localhost]# tar -xvf pcre-8.44.tar.bz2
[root@localhost]# cd pcre-8.44
[root@localhost pcre-8.44]# ./configure --prefix=/opt/mono
[root@localhost pcre-8.44]# make && make install
----------------如果遇到以下错误开始----------------------
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /usr/local/src/pcre-8.35/missing aclocal-1.14 -I m4
/usr/local/src/pcre-8.35/missing: line 81: aclocal-1.14: command not found
WARNING: 'aclocal-1.14' is missing on your system.
         You should only need it if you modified 'acinclude.m4' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'aclocal' program is part of the GNU Automake package:
         
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         
         
         
make: *** [aclocal.m4] 错误 127

[root@localhost pcre-8.44]# autoreconf -ivf
----------------如果遇到以下错误结束----------------------
[root@localhost pcre-8.44]# echo "/opt/mono/lib" > /etc/ld.so.conf.d/mono.conf
[root@localhost pcre-8.44]# ldconfig

4、安装libgdiplus:

[root@localhost]# tar -xvf libgdiplus-6.0.tar.bz2
[root@localhost]# cd libgdiplus-6.0
[root@localhost libgdiplus-6.0]# ./configure --prefix=/opt/mono
[root@localhost libgdiplus-6.0]# make && make install
[root@localhost libgdiplus-6.0]# echo "/opt/mono/lib" > /etc/ld.so.conf.d/mono.conf
[root@localhost libgdiplus-6.0]# ldconfig

5、安装mono:
[root@localhost]# tar -xvf mono-6.13.0.116.tar.xz
[root@localhost]# cd mono-6.13.0.116
[root@localhost mono-6.13.0.116]# ./configure --prefix=/opt/mono
---------------------------------------------可能会有插曲开始-------------------------------------------
CentOS7上搭建Nginx+Mono运行asp.net环境的配置方法
如果出现以上错误,需要安装Python的版本 >= 3.2

请参考:CentOS7 Python2 和Python3 共存(Python3安装)进行操作
---------------------------------------------可能会有插曲结束-------------------------------------------

[root@localhost mono-6.13.0.116]# make && make install //此处时间较长
echo export PKG_CONFIG_PATH=/opt/mono/lib/pkgconfig:$PKG_CONFIG_PATH>>~/.bash_profile
echo export LD_LIBRARY_PATH=/opt/mono/lib:$LD_LIBRARY_PATH>>~/.bash_profile
echo export PATH=/opt/mono/bin:$PATH>>~/.bash_profile
source ~/.bash_profile

输入 mono -V 如有mono版本信息,则安装成功.
6、安装XSP:
tar -xvf xsp-4.7.1.tar.gz
./configure --prefix=/opt/mono
make && make install

7、配置Nginx:
vi /usr/local/nginx/conf/vhost/www.域名.conf
server { 
listen 80;
    server_name www.域名.com;
        location / {
        root /home/web/www.域名.com;
        index index.html index.htm default.aspx Default.aspx;
        fastcgi_index Default.aspx;
        fastcgi_pass 127.0.0.1:9001;
        include /usr/local/nginx/conf/fastcgi_params;
        }
 }

注:因为按需求要同时跑PHP+asp,9000端口被PHP占用了,这里使用9001端口!如果先配置好PHP再配置asp,发现访问asp的静态网页报404,文件又确实存在的时候就是端口冲突了。
8、配置fastcgi_params增加下面三行:
vi /usr/local/nginx/conf/fastcgi_params
fastcgi_param PATH_INFO   "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTP_HOST $host;
9、启动:
1、重启nginx:
/usr/local/nginx/sbin/nginx -s reload

2、启动 fastcgi_mono服务器
nohup fastcgi-mono-server4 /applications=/:/home/web/test.com/manhua /socket=tcp:127.0.0.1:9001 &

3、脚本启动fasfcgi_mono
如果你的mono站点以fastcgi方式运行,且不想每次重启服务器都手动启动fastcgi-mono-serverX,那么下面的脚本将能省去这一步骤(WEBAPPS变量代表了要启动的站点,按需修改即可)
-------------------------------------------------------脚本部份开始-----------------------------------------------
#!/bin/sh
 
### BEGIN INIT INFO
# Provides:          monoserve.sh
# Required-Start:    $local_fs $syslog $remote_fs
# Required-Stop:     $local_fs $syslog $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start fastcgi mono server with hosts
### END INIT INFO
 
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/mono
NAME=monoserver
DESC=monoserver
 
MONOSERVER=$(which fastcgi-mono-server2)
MONOSERVER_PID=$(ps auxf | grep fastcgi-mono-server2.exe | grep -v grep | awk '{print $2}')
 
#WEBAPPS=www.domain1.xyz:/:/var/www/domain1.xyz/,www.domain2.xyz:/:/var/www/domain2.xyz/

WEBAPPS="www.domain1.xyz:/:/var/www/domain1.xyz/,www.domain2.xyz:/:/var/www/domain2.xyz/"

case "$1" in
        start)
                if [ -z "${MONOSERVER_PID}" ]; then
                        echo "starting mono server"
                        ${MONOSERVER} /applications=${WEBAPPS} /socket=tcp:127.0.0.1:9001 &
                        echo "mono server started"
                else
                        echo ${WEBAPPS}
                        echo "mono server is running"
                fi
        ;;
        stop)
                if [ -n "${MONOSERVER_PID}" ]; then
                        kill ${MONOSERVER_PID}
                        echo "mono server stopped"
                else
                        echo "mono server is not running"
                fi
        ;;
esac
 
exit 0

-------------------------------------------------------脚本部份结束-----------------------------------------------

然后添加执行权限

chmod +x /etc/init.d/monoserve
再然后安装脚本

update-rc.d monoserve defaults
注:这里启动所用的端口必须要和nginx中配置的ASP端口保持一至.
 

相关推荐:vmware共享主机目录centos7教程 共享目录centos7使用配置

相关推荐:vmware映射端口远程访问方法 实现远程访问操作方法

查看更多资讯请关注6z6z下载站