顯示具有 Server::Web Server 標籤的文章。 顯示所有文章
顯示具有 Server::Web Server 標籤的文章。 顯示所有文章

2017年1月9日 星期一

在 CentOS7/RHEL7上,為 Nginx 加上 Perl CGI 模組

設定提要:
  • Nginx Web Server 以及 php 套件安裝,請參考這一篇
快速設定流程:
  1. 安裝 EPEL 套件:
    #yum install epel-release
    #yum upgrade epel-release
    
  2. 利用 YUM ,安裝 fcgiwrap 以及 spawn-fcgi:
    #yum install fcgiwrap spawn-fcgi
    
  3. 設定系統參數,方便 spawn-fcgi 運用:
    #vim /etc/sysconfig/spawn-fcgi
    FCGI_SOCKET=/var/run/fcgiwrap.socket
    FCGI_PROGRAM=/usr/sbin/fcgiwrap
    FCGI_USER=nginx
    FCGI_GROUP=nginx
    FCGI_EXTRA_OPTIONS="-M 0700"
    OPTIONS="-u $FCGI_USER -g $FCGI_GROUP -s $FCGI_SOCKET -S $FCGI_EXTRA_OPTIONS -F 1 -P /var/run/spawn-fcgi.pid -- $FCGI_PROGRAM"
    
  4. 啟動 spawn-fcgi 服務:
    #systemctl enable spawn-fcgi
    #systemctl start spawn-fcgi
    
  5. 修改 Nginx 設定檔內容:
    #
    server {
    (中間其他設定omit)
    location /monitorix/ {
            alias /var/lib/monitorix/www/;
            index index.html;
        }
        location /monitorix-cgi/ {
            gzip off;
            alias /var/lib/monitorix/www/cgi/;
            fastcgi_pass unix:/var/run/fcgiwrap.socket;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        }
    (中間其他設定omit)
    }
    
  6. 重新啟動 nginx 服務:
    #systemctl restart nginx
    
  7. 寫一測試檔案:
    #vim /var/share/nginx/html/test.cgi
    #!/usr/bin/perl -w
    print "Content-type: text/html\n\n";    
    print "<html><head><title>Hello World!! </title></head>\n";
    print "<body><h1>Hello world</h1>
    </body></html>\n";
    
  8. 設定權限:
    #chmod 0755 /var/share/nginx/html/test.cgi
    #chown nginx.nginx /var/share/nginx/html/test.cgi
    
  9. 利用 firefox 測試!(http://localhost/test.cgi)

參考文獻:
  • https://www.howtoforge.com/serving-cgi-scripts-with-nginx-on-centos-6.0-p2

2016年9月30日 星期五

在 CentOS7/RHEL7上,使用 Nginx 設定基本 Web 帳號密碼

設定提要:
  • 利用 Nginx 作為 Web 平台,實作 Web 站台帳密登入機制
  • 請先安裝 Nginx Web 平台!可參考這一篇文章!
快速設定流程:
  1. 利用 yum 進行相關套件安裝:
    #yum -y install httpd-tools
    
  2. 設定帳號與密碼:
    #htpasswd -c /etc/nginx/.htpasswd nginx
    (查看密碼內容:)
    # cat /etc/nginx/.htpasswd
    
  3. 修改 Nagios 設定檔 /etc/nginx/nginx.conf:
    # vim /etc/nginx/nginx.conf
    (追加下列設定參數:)
    auth_basic "Private Property";
    auth_basic_user_file /etc/nginx/.htpasswd;
    
  4. 重新啟動 Nagios:
    # systemctl reload nginx
    
※附註:
  • 限制指定的目錄:
    #vim /etc/nginx/conf.d/default.conf
    (加入下列設定參數)
    location ~ ^/admin/.* {
            root /usr/share/nginx/html;
            index index.php index.html index.htm;
            location ~ \.php$ {
               try_files $uri = 404;
               fastcgi_pass unix:/var/opt/remi/php70/run/php-fpm/php-fpm.sock;
               fastcgi_index  index.php;
               fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
               include        fastcgi_params;
            }
            auth_basic "Administrator Login";
            auth_basic_user_file /usr/share/nginx/html/.htpasswd;
    }
    
參考文獻:
  • http://tonyhack.familyds.net/wordpress/?p=1998

2016年7月31日 星期日

在 CentOS7/RHEL7 上架設 Nginx Web Server(二)

設定目標:
  • 在 Centos 7 上架設 Nginx 1.10.1 + Php 7.0 (Remi) 套件!
Nginx Web Server 快速設定流程:
  1. 編寫最新的 Nginx 套件位置:
    #vim /etc/yum.repos.d/nginx.repo
    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/centos/7/$basearch/
    gpgcheck=0
    enabled=1
    
  2. 安裝最新的 Nginx 套件:
    # yum install nginx-*
    
  3. 開啟防火牆:
    # firewall-cmd --permanent --add-service=http
    # firewall-cmd --reload
    
  4. 啟動 Nginx 服務:
    #systemctl enable nginx.service
    #systemctl start nginx.service
    #systemctl status nginx.service -l
    
PHP 7 (Remi) 快速設定流程:
  1. 安裝 Remi 套件的 repo 檔案:
    #wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
    #rpm -Uvh remi-release-7.rpm
    
  2. 安裝 PHP 7.0 套件:
    # yum install php70 php70-php-fpm php70-php-mbstring php70-php-mcrypt php70-php-gd
    
  3. 修改 php-fpm 設定檔:
    #vim /etc/opt/remi/php70/php-fpm.d/www.conf
    user = nginx
    group = nginx
    listen = /var/run/php-fpm.sock
    listen.owner = nginx
    listen.group = nginx
    listen.mode = 0666
    
  4. 啟動 php-fpm 服務:
    # systemctl enable php70-php-fpm.service
    # systemctl start php70-php-fpm.service
    
  5. 修改 Nginx 設定檔:
    # vim /etc/nginx/conf.d/default.conf
    (修改下列設定:)
        access_log  /var/log/nginx/access.log  main;
        error_log /var/log/nginx/error.log warn;
        
        location / {
            root   /usr/share/nginx/html;
            index  index.php index.html index.htm;
        }
    
        location ~ \.php$ {
            root           /usr/share/nginx/html;
        #    fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass unix:/var/run/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
        :
        :
    
  6. 動新啟動 nginx:
    #systemctl restart nginx.service
    
  7. 開啟 SELinux 設定:
    #setsebool -P httpd_can_network_connect on
    

2016年7月29日 星期五

在 CentOS7/THEL7 上最佳化 Nginx Web Service

參考文獻:

  1. http://www.linuxde.net/2013/08/15150.html#comments
  2. https://blog.longwin.com.tw/2013/02/nginx-add-worker_connections-2013/

2016年7月23日 星期六

Nginx 的監控程式

網路資源:

  1. https://www.datadoghq.com/blog/how-to-collect-nginx-metrics/
  2. https://www.datadoghq.com/blog/how-to-monitor-nginx/
  3. https://blog.serverdensity.com/monitor-nginx/
  4. https://easyengine.io/tutorials/nginx/status-page/
  5. https://www.scalyr.com/community/guides/how-to-monitor-nginx-the-essential-guide
  6. http://www.slideshare.net/serverdensity/how-to-monitor-nginx

2016年7月8日 星期五

在 CentOS7/RHEL7 上架設 Nginx Web Server(四)

設定目標:
  • 設定 Nginx Web Server,架設 Reverse Proxy Server 服務!

事前準備:
  • 請先參考這一篇文件,架設好 Nginx Web Server!

快速設定流程:
  1. 編寫 Nginx 預設設定檔:
    #vi /etc/nginx/nginx.conf
    (註解以下設定:)
    # server {
       :
       :
    #  }
    
  2. 編寫 for proxy 的設定檔:
    #vi /etc/nginx/conf.d/proxy.conf
    upstream proxy {
        server 192.168.5.61:80;
    }
    
    server {
        listen      80 default;
        server_name www.example.com;
    
        access_log  /var/log/nginx/jenkins.access.log;
        error_log   /var/log/nginx/jenkins.error.log;
    
        proxy_buffers 16 64k;
        proxy_buffer_size 128k;
    
        location / {
            proxy_pass  http://proxy;
            proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
            proxy_redirect off;
    
            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_set_header    X-Forwarded-Proto https;
        }
    }
    
  3. 啟動 Nginx :
    #systemctl enable nginx.service
    #systemctl start nginx.service
    
  4. 啟動防火牆:
    #firewall-cmd --permanent --add-service=http
    #firewall-cmd --reload
    

參考文獻:

  1. https://www.nginx.com/resources/admin-guide/reverse-proxy/
  2. http://shazi.info/centos-6-%E5%BB%BA%E7%AB%8B-nginx-reverse-proxy/
  3. https://www.twstar.biz/43151.html
  4. http://icodding.blogspot.tw/2015/08/nginx.html
  5. https://snippetinfo.net/media/671/
  6. https://deviantengineer.com/2015/05/nginx-reverseproxy-centos7/
  7. https://www.rosehosting.com/blog/install-and-configure-jenkins-with-nginx-as-a-reverse-proxy-on-centos-7/

2016年7月5日 星期二

在 CentOS7/RHEL7 上安裝 Memcached 套件

安裝前注意事項:
  • 基本 Web 站台設定,請參考這一篇文章!
  • 若想使用 Nginx 當 Web 運作平台,請參考這一篇文章!
基本安裝流程 (在 Apache Web 平台上):
  1. 安裝 Memcached 套件:
    #yum install memcached
    
  2. 檢查設定檔內容:
    #vim /etc/sysconfig/memcached
    PORT="11211"         ##使用埠號 11211
    USER="memcached"
    MAXCONN="1024"       ##最大連線使用數
    CACHESIZE="512"       ##使用 512MB 記憶體
    OPTIONS=""
    
  3. 啟動 Memcached 套件:
    #systemctl enable memcached
    #systemctl start memcached
    
  4. 開啟防火牆設定:
    #firewall-cmd --permanent --add-port=11211/tcp
    #firewall-cmd --reload
    
  5. 讓 php 套件使用 memcached ,需安裝下列套件:
    #yum -y install php-pecl-memcache
    
  6. 重新啟動 Apache Web Server:
    #systemctl restart httpd
    

在 Ngnix 平台上的應用:
  1. 修改 Nginx 設定檔:
    #vim /etc/nginx/conf.d/default.conf
    
    server {
       :
       (加入以下的設定值:)
       :
       location ^~ /cache/ {
            set            $memcached_key $request_uri;
            memcached_pass 127.0.0.1:11211;
        }
        :
        :
    }
    
  2. 重新啟動 Nginx :
    #systemctl restart nginx
    
  3. ※注意:參考資料~~~
    • http://nginx.org/en/docs/http/ngx_http_memcached_module.html
    • http://blog.octo.com/en/http-caching-with-nginx-and-memcached/
    • http://www.ttlsa.com/nginx/application-of-nginx_memcached-to-construct-the-page-cache/
    • http://www.icyfire.me/2014/11/30/use-nginx-and-memcached-to-cache-pages.html

安裝 phpMemcachedAdmin 套件
  • 下載 phpMemcachedAdmin 套件:
    #cd /var/www/html
    #wget http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.2-r262.tar.gz
    
  • 解壓縮 phpMemcachedAdmin 套件:
    #mkdir phpMemcachedAdmin
    #tar zxvf phpMemcachedAdmin-1.2.2-r262.tar.gz -C phpMemcachedAdmi
    
  • 設定相關權限:
    #chown -R apache.apache phpMemcachedAdmin
    #restorecon -R /var/www/html
    #setsebool -P httpd_can_network_memcache on
    #setsebool -P httpd_unified on
    #grep httpd /var/log/audit/audit.log | audit2allow -M http
    #semodule -i httpd.pp
    
  • 重新啟動 Apache Web Server:
    #systemctl restart httpd
    
  • 利用 Firefox 查看網頁:
    http://127.0.0.1/phpMemcachedAdmin/
參考文獻:
  1. http://www.phpini.com/php/rhel-centos-7-install-php-memcached
  2. http://www.liquidweb.com/kb/how-to-install-the-memcached-php-extension-on-centos-7/
  3. http://www.liquidweb.com/kb/how-to-install-memcached-on-centos-7/
  4. https://devops.profitbricks.com/tutorials/install-and-configure-memcached-on-centos-7/
  5. http://blog.elijaa.org/phpmemcachedadmin-installation-guide/
  6. http://www.techoism.com/install-phpmemcachedadmin-on-linux/

2016年6月27日 星期一

在 CentOS7/RHEL7 上安裝 Bootstrap 套件

安裝前注意事項:
  • 基本 Web 站台設定,請參考這一篇文章!
基本安裝流程:
  1. 安裝 EPEL 套件:
    #yum -y install epel-release
    
  2. 安裝 git 套件:
    #yum -y install git
    
  3. 由 GitHub 網站,下載 BootStrap 套件:
    #cd /var/www/html
    #git clone https://github.com/twbs/bootstrap.git
    
  4. 利用 Firefox 連到 BootStrap 起始網頁看看:
    http://127.0.0.1/bootstrap/docs/examples/starter-template/
參考文獻:
  1. https://github.com/twbs/bootstrap
  2. https://gist.github.com/kmassada/73678d48dcf6b23b6f0a
  3. http://getbootstrap.com/
  4. https://kkbruce.tw/bs3/Gettingstarted

2016年5月28日 星期六

在 CentOS7/RHEL7 上架設 Nginx Web Server(一)

設定目標:
  • 在 Centos 7 上架設 Nginx Web Server!
Nginx Web Server 快速設定流程:
  1. 編寫最新的 Nginx 套件位置:
    #vim /etc/yum.repos.d/nginx.repo
    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    gpgcheck=0
    enabled=1
    
  2. 利用 yum 安裝
    #yum -y install nginx
    
  3. 啟動防火牆:
    #firewall-cmd --permanent --zone=public --add-service=http
    #firewall-cmd --permanent --zone=public --add-service=https
    #firewall-cmd --reload
    
  4. 啟動 Nginx:
    #systemctl enable nginx.service
    #systemctl start nginx
    

讓 Nginx 加入 php 模組:
  1. 利用 yum 安裝
    #yum -y install php-fpm
    
  2. 編寫 php-fpm 預設檔:
    #vim /etc/php-fpm.d/www.conf
    user = nginx
    group = nginx
    
  3. 啟動 php-ftm 功能:
    #systemctl enable php-fpm.service
    #systemctl start php-fpm
    
  4. 編寫 Nginx 預設檔:
    #vim /etc/nginx/conf.d/default.conf
    (修改下列項目:)
     location ~ \.php$ {
            root           /usr/share/nginx/html;
            fastcgi_pass unix:/var/run/php-fpm/php5-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
     location ~ /\.ht {
            deny  all;
        }
    
  5. 重新啟動 Nginx:
    #systemctl restart nginx
    
  6. 改成 Socket 的使用方式:
    #vim /etc/sysconfig/memcached
    OPTIONS="-s /tmp/memcached.sock -a 666"
    #MEMCACHED_ARGS="-s /tmp/memcached.sock -a 666"
    
  7. 檢查一下成果:
    #echo stats | nc -U /tmp/memcached.sock
    
  8. 修改 memcached.ini 設定檔內容:
    #/etc/php/conf.d/memcached.ini
    extension=memcached.so
    session.save_handler="memcached"
    session.save_path="/tmp/memcached.sock"
    
  9. 編修 Nginx 預設檔:
    #vim /etc/nginx/conf.d/default.conf
    server {
       :
    (加入以下內容:)
       location ^~ /cache/ {
               set            $memcached_key $request_uri;
               #memcached_pass 127.0.0.1:11211;
               memcached_pass unix:/tmp/memcached.sock;
        }
        :
    
  10. 重新啟動 Nginx:
    #systemctl restart nginx
    

參考文獻:

  1. https://www.howtoforge.com/tutorial/install-nginx-with-php-and-mysql-lemp-stack-on-centos/
  2. http://blog.itist.tw/2016/01/installing-lemp-stack-with-centos-7-nginx-mariadb-php-7.html
  3. http://www.phpini.com/linux/rhel-centos-7-install-nginx-mysql-php-lemp
  4. http://www.server-world.info/en/note?os=CentOS_7&p=nginx&f=1
  5. https://www.digitalocean.com/community/tutorials/how-to-upgrade-to-php-7-on-centos-7

2016年5月27日 星期五

在 CentOS7/RHEL7 上架設 HTTP 負載平衡系統

設定目標:
  • 在 Centos 7 上架設 HAProxy Server,將流量分配至後方的多個 Web 站台!
  • 後方的 Web 站台,不拘任何套件平台,可以是 Apache 也可以是 Nginx!
    • 請參考這一篇的設定,架設好 Web Server!
快速設定流程:
  1. 利用 yum 安裝
    #yum install 
    

參考文獻:

  1. http://www.server-world.info/en/note?os=CentOS_7&p=haproxy&f=1

在 CentOS7/RHEL7 上架設多個 PHP 版本的 Web Server

設定目標:
  • 在 Centos 7 上安裝多個 php 版本的 Web Server!
  • Web Server 可以是 Apache 套件,也可以是 Nginx 套件!
    • 請參考這一篇的設定,架設好 Web Server!
快速設定流程:
  1. 利用 yum 安裝
    #yum install 
    

參考文獻:

  1. http://serverfault.com/questions/671400/multiple-versions-of-php-through-nginx
  2. http://www.server-world.info/en/note?os=CentOS_7&p=nginx&f=9
  3. https://www.digitalocean.com/community/tutorials/how-to-host-multiple-websites-securely-with-nginx-and-php-fpm-on-ubuntu-14-04
  4. https://serversforhackers.com/video/php-fpm-multiple-resource-pools
  5. https://www.howtoforge.com/how-to-use-multiple-php-versions-php-fpm-and-fastcgi-with-ispconfig-3-ubuntu-12.10
  6. https://www.howtoforge.com/perfect-server-centos-7-x86_64-nginx-dovecot-ispconfig-3

2016年5月9日 星期一

在 CentOS7/RHEL7 上設定需要帳密登入的 Web站台

進階設定目標:
  • 在 Web 虚擬主機上,設置需要使用者帳密才可登入的網站!
注意事項:
  • 基本 Web 站台設定,請參考這一篇文章!
  • Web 虚擬主機設定,請參考第二篇文章!
  • https 連線加密的站台設定,請參考第三篇文章!
進階設定流程(一):
  1. 在 /etc/httpd/conf.d 目錄中,編寫之前的設定檔 vhosts.conf :
    #vim /etc/httpd/conf.d/vhosts.conf
    <VirtualHost *:80>
       ServerName test1.example.com
       DocumentRoot /var/www/vhosts/test1
       <Directory /var/www/vhosts/test1/sec>
           AuthType Basic
           AuthName "Restricted Area"
           AuthUserFile /var/www/vhosts/.htpasswd
           require valid-user
       </Directory>
    </VirtualHost>
    
  2. 新增 .htpasswd 檔案:
    #cd /var/www/vhosts/.htpasswd
    #htpasswd -c .htpasswd peter
    (記得要輸入密碼)
    
    (再增加使用者時,不用 -c 參數)
    #htpasswd .htpasswd eric
    
  3. 修改 .htpasswd 權限:
    #chmod 0411 .htpasswd
    
  4. 重新啟動 Apache :
    #systemctl restart httpd
    
參考資料:
  1. http://www.seas.upenn.edu/cets/answers/auth-htpasswd.html

在 CentOS7/RHEL7 上設定 Web 連線加密站台

進階設定目標:
  • 在同一 Web 主機上,設置加密與不加密兩類網站!
注意事項:
  • 基本 Web 站台設定,請參考這一篇文章!
  • Web 虚擬主機設定,請參考第二篇文章!
進階設定流程(一):
  1. 安裝 Apache 所需要的架密模組:
    #yum -y install mod_ssl openssl
    
  2. 產生一張自我簽署的憑證
    ## 產生私鑰
    #openssl genrsa -out ca.key 2048
    
    ## 產生 CSR
    #openssl req -new -key ca.key -out ca.csr
    
    ## 產生自我簽署的金鑰
    #openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt
    
    ## 複製檔案至正確位置
    #cp ca.crt /etc/pki/tls/certs
    #cp ca.key /etc/pki/tls/private/ca.key
    #cp ca.csr /etc/pki/tls/private/ca.csr
    
  3. 處理 SELiux 設定:
    #restorecon -RvF /etc/pki
    
  4. 設定成虚擬主機:
    #vim /etc/httpd/conf.d/ssl_vhosts.conf
    
    LoadModule ssl_module modules/mod_ssl.so
    
    #Listen 443
    <VirtualHost *:443>
        ServerName sec.example.com
        DocumentRoot /var/www/vhosts/sec
        SSLEngine on
        SSLCertificateFile "/etc/pki/tls/certs/ca.crt"
        SSLCertificateKeyFile "/etc/pki/tls/private/ca.key"
    </VirtualHost>
    
  5. 加密站台目錄與網頁的處理:
    #mkdir -p /var/www/vhosts/sec
    #cd /var/www/vhosts/sec
    #vim index.html
    Hi~~This is a secrete site !!
    
參考資料:
  1. https://wiki.centos.org/zh-tw/HowTos/Https
  2. https://httpd.apache.org/docs/2.4/ssl/ssl_howto.html
  3. http://linux.vbird.org/linux_server/0360apache.php#www_basic_pkg

2016年5月8日 星期日

在 CentOS7/RHEL7 上設定 Web 虚擬主機

進階設定目標:
  • 在同一 Web 主機上,設置不同網址網站!
  • 將 RoundCube 站台,變成 Webmail 站台
注意事項:
  • 基本 Web 站台設定,請參考這一篇文章!
進階設定流程(一):
  1. 在 /etc/httpd/conf.d 目錄中,自由新增檔案:
    #cd /etc/httpd/conf.d
    #vim vhosts.conf
    <VirtualHost _default_:80>
       ServerName www.example.com
       DocumentRoot /var/www/html
    </VirtualHost>
    <VirtualHost *:80>
       ServerName test1.example.com
       DocumentRoot /var/www/vhosts/test1
    </VirtualHost>
    
  2. 建立放置虚擬網站目錄:
    #mkdir -p /var/www/vhosts/test1
    
  3. 在虚擬網站目錄內,新增測試用網頁:
    #vim /var/www/vhosts/test1/index.html
    Hello!! Test1 Web Site !!
    
  4. 新增 DNS 記錄:
    #vim /var/named/example.zone
    (新增在最後一行)
    test1    IN  A  192.168.5.2
    
    注意事項:請參考這一篇的 DNS Server 設定!
  5. 重新啟動 DNS Server:
    #systemctl restart named
    
  6. 重新啟動 Web Server:
    #systemctl restart httpd
    
進階設定流程(二):
  1. 在 /etc/httpd/conf.d 目錄中,編輯 roundcubemail.conf 檔案:
    #vim /etc/httpd/conf.d/roundcubemail.conf
    Alias /roundcubemail /usr/share/roundcubemail
    (增加下列幾行:)
    <VirtualHost *:80>
       ServerName webmail.example.com
       DocumentRoot /usr/share/roundcubemail
    
    <Directory /usr/share/roundcubemail/bin/>
       :
       : (中間原來設定不動!)
       :
       :
    </Directory>
    (新增下列這行,為最後一行設定值)
    </VirtualHost>
    
  2. 新增 DNS 記錄:
    #vim /var/named/example.zone
    (新增在最後一行)
    webmail    IN  A  192.168.5.2
    
  3. 重新啟動 DNS Server:
    #systemctl restart named
    
  4. 重新啟動 Web Server:
    #systemctl restart httpd
    

2016年3月21日 星期一

在 CentOS7/RHEL7 上設定 Web Server

基本設定流程:
  1. 安裝 Web Server 套件:
    #yum -y install httpd
    
  2. 設定啟動 Web Server 服務:
    #systemctl enable httpd.service
    #systemctl start httpd.service
    #systemctl status httpd.service
    
  3. 設定開通防火牆:
    #firewall-cmd --permanent --add-service=http
    #firewall-cmd --reload
    
Apache 相關設定檔案:
  1. 主要設定檔:/etc/httpd/conf/httpd.conf
  2. 設定檔目錄:/etc/httpd/conf.d/
  3. 網頁放置目錄:/var/www/html

安裝 PHP 模組:
  1. 安裝 PHP 模組套件:
    #yum -y install php php-bcmath php-cli php-common php-dba php-devel php-embedded php-enchant php-fpm php-gd php-intl php-ldap php-mbstring
    #yum -y install php-mysqlnd php-odbc php-pdo php-process php-pspell php-recode php-snmp php-soap php-xml php-xmlrpc rrdtool-php uuid-php php-pecl-memcache
    
    或是
    #yum -y install php-* --skip-broken php-mysql
  2. 重新啟動 Web Server 服務:
    #systemctl restart httpd.service