首頁>技術>

Linux 版本資訊: CentOS版本:CentOS-7-x86_64-DVD-1611

安裝

yum install httpd

配置

修改配置檔案,儲存退出:vi /etc/httpd/conf/httpd.conf預設埠80改成81

將#ServerName xxx設定改成ServerName localhost:81

修改DocumentRoot xxx 路徑DocumentRoot /usr/local/java/apache-static-data【注意:配置的DocumentRoot 路徑/usr/local/java/apache-static-data 需要建立檔案不然會報錯】

將<Directory “/var/www/html”>替換成<Directory “/usr/local/java/apache-static-data”>

儲存退出之後,建立配置的資料夾mkdir /usr/local/java/apache-static-data

設定跨域

vi /etc/httpd/conf/httpd.conf新增如下配置

LoadModule headers_module modules/mod_headers.so<Directory />AllowOverride NoneHeader set Access-Control-Allow-Origin *Header set Access-Control-Allow-Methods *Header set Access-Control-Allow-Headers content-type,authorization Header set Access-Control-Max-Age '1728000'Header set Content-Security-Policy upgrade-insecure-requests</Directory>123456789

重啟 apapcheservice httpd restart

啟動

啟動:systemctl start httpd檢視程序:ps -ef|grep httpd

設定開機啟動systemctl enable httpd

–permanent永久生效,沒有此引數重啟後失效:firewall-cmd --zone=public --add-port=81/tcp --permanent

重新整理:firewall-cmd --reload

訪問:ip:埠

遷移資源

透過xftp工具連線將靜態資源(fourd-static)放至/usr/local/java/apache-static-data目錄下

開啟瀏覽器訪問驗證:

17
最新評論
  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • 教你幾招演算法筆試的套路