Ubuntu centos系统——apache如何解决跨域资源访问
2017-12-05 10:09
441 查看
参考文档:HTTP://blog.csdn.net/ownfire/article/details/46707229 http://www.mechonomics.com/enabling-cors-cross-origin-resource-sharing-for-apache2-on-ubuntu-12-04/ 1. sudo a2enmod头文件2.sudo gedit /etc / apache2 / sites-available /000-default.conf编辑添加:LoadModule headers_module modules / mod_headers.so标头集Access-Control-Allow-Origin *如下:<VirtualHost *:80> LoadTileConfigFile /usr/local/etc/renderd.conf ModTileRenderdSocketName /var/run/renderd/renderd.sock LoadModule headers_module modules/mod_headers.so # Timeout before giving up for a tile to be rendered ModTileRequestTimeout 0 # Timeout before giving up for a tile to be rendered that is otherwise missing ModTileMissingRequestTimeout 30 # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@ localhost DocumentRoot / var / www / html 标头集Access-Control-Allow-Origin * #可用的日志级别:trace8,...,trace1,debug,info,notice,warn, #错误,暴击,警报,emerg。 #也可以配置特定的日志级别 #模块,例如 #LogLevel info ssl:warn ErrorLog $ {APACHE_LOG_DIR} /error.log CustomLog $ {APACHE_LOG_DIR} /access.log合并 #对于来自conf-available /的大多数配置文件, #在全球范围内启用或禁用,有可能 #仅包含一个特定虚拟主机的行。例如 #下面的行只启用该主机的CGI配置 #在通过“a2disconf”全局禁用之后。 #include conf-available / serve-cgi-bin.conf</虚拟主机>#vim:syntax = apache ts = 4 sw = 4 sts = 4 sr noet3.重启阿帕奇服务apache2重新启动测试跨域访问即可centos系统在httpd.conf里面加这两句就可以使用LoadModule headers_module modules / mod_headers.so标头集Access-Control-Allow-Origin *Apache服务器配置的方法,包括修改服务器配置文件的方法和如何编辑httpd.conf。接下来,通过本文给大家重点讲解,需要的朋友参考下吧1.修改服务器配置文件?
2.编辑httpd.conf文件找下面这行,把#去掉,目的是开启Apache的头信息自定义模块?
重点内容?
意思是对这个域名的资源进行访问时,添加一个头信息最后重启服务器生效二,查看Linux系统版本的命令(3种方法):1,lsb_release -a,即可列出所有版本信息:以root身份登录到服务器,然后重新启动计算机,然后重新启动计算机,然后重新启动计算机。 noarch:printing-4.0-amd64:printing-4.0-noarch分销商编号:CentOS说明:CentOS 6.5(Final)版本:6.5Codename:Final这个命令适用于所有的Linux发行版,包括RedHat,SUSE,Debian等等发行版。2,cat / etc / redhat-release,这种方法只适合Redhat系的Linux:[root @ S-CentOS home]#cat / etc / redhat-releaseCentOS release 6.5(Final)3,cat / etc / issue,此命令也适用于所有的Linux发行版。[root @ S-CentOS home]#cat / etc / issueCentOS release 6.5(Final)Kernel \ r on \ m
centos查看apache用的是哪个httpd.conf
httpd -V 得到类似如下结果:-D HTTPD_ROOT="/etc/httpd"-D SERVER_CONFIG_FILE="conf/httpd.conf"
然后,两个拼起来就是你要找的路径Task: Start Apache 2 Server /启动apache服务# /etc/init.d/apache2 startor$ sudo /etc/init.d/apache2 startTask: Restart Apache 2 Server /重启apache服务# /etc/init.d/apache2 restartor$ sudo /etc/init.d/apache2 restartTask: Stop Apache 2 Server /停止apache服务# /etc/init.d/apache2 stopor$ sudo /etc/init.d/apache2 stop工欲善其事,必先利其器。
相关文章推荐
- ubuntu-apache如何解决跨域资源访问
- Ubuntu——apache如何解决跨域资源访问
- apache如何解决跨域资源访问
- apache如何解决跨域资源访问
- apache如何解决跨域资源访问
- ubuntu系统下访问xp系统下中文乱码解决方法
- Windows 7系统如何解决“无法访问windows installer服务“问题
- windows如何顺利访问centos,ubuntu?
- Win XP系统下局域网内无法访问其他计算机的共享如何解决
- CentOS安装Apache服务器后无法访问解决方法
- 关于Iframe如何跨域访问Cookie和Session的解决方法
- Linux(CentOS)系统下安装好apache(httpd)服务后,其他电脑无法访问的原因
- CentOS 安装 Apache 后其他机器无法访问的解决方法
- CentOS 安装 Apache 后其他机器无法访问的解决方法
- 如何通过IP访问virtualbox虚拟机的ubuntu server系统
- CentOS 5.2 安装httpd(Apache)服务器后无法访问解决方法
- 如何解决xp文件夹权限,数据库只读,“ASP.NET 未被授权访问所请求的资源”
- 如何在Ubuntu系统中重新安装不同版本的Ubuntu!(……Not a COM32R image ……“错误的解决办法!
- 如何优化代码节约系统资源解决重复实例化对象的问题——神奇的单例模式(C#设计模式)
- 如何解决LoadRunner监控Windows资源拒绝访问的错误