Centos 7 安裝LAMP以及在Apache上安裝positiveSSL。

來源:互聯網
上載者:User

標籤:

 

簡介

     LAMP(linux , Apache, mysql , php)是整合動態網站經常使用的一套開源軟體,實際包含linux作業系統,Apache web伺服器,mysql(mariadb 分支)資料庫,還有處理動態內容的php指令碼語言。這裡簡要介紹一下自己在Centos 7上的安裝過程,體驗。

關於LAMP

步驟一:安裝Apache

  首先yum安裝httpd:    sudo yum install httpd

  然後啟動httpd服務:     sudo systemctl start httpd.service    這裡是centos7裡建立的systemctl命令體系來管理各種服務,啟動後可在瀏覽器裡輸入自己ip訪問驗證。

  最後設定成開機啟動:    sudo systemctl enable httpd.service 

步驟二:安裝Mysql(MariaDB)

  同樣yum安裝:  sudo yum install mariadb-server mariadb

  然後啟動:  sudo systemctl start mariadb.service 

  啟動好後設定一下安全密碼等:  sudo mysql_secure_installation  列出了一些互動選項,出了設定密碼其他的都可以enter通過。

  設定成開機啟動:  sudo systemctl enable mariadb.service 

步驟三:安裝PHP

  yum安裝:  sudo yum install php php-mysql  

  之後重啟Apache:  sudo systemctl restart httpd.service 

  可以在、var/www/html/下建立一個測試指令碼info.php : sudo vim /var/www/html/info.php  輸入以下內容:  <?php phpinfo();?>

  然後瀏覽器登入http://ip/info.php,如果可以看見列出一些php版本資訊之類的,表明安裝成功。

 

關於安裝PositiveSSL

步驟一:安裝Apache ssl模組:  sudo yum install mod_ssl  後重啟Apache;

  這樣帶來兩個變化,首先建立了一個預設的ssl認證,路徑在/etc/pki/tls中,另外出現了/etc/httpd/conf.d/ssl.conf的設定檔。

步驟二:上傳自己的ssl認證到/etc/pki/tls中。申請過程見前面的另一篇,申請成功後會獲得四個認證包括:

  *yourdomainname*.crt

  COMODORSADomainValidationSecureServerCA.crt

  COMODORSAAddTrustCA.crt

  AddTrustExternalCARoot.crt

  要用cat命令將從根憑證開始產生憑證鏈結才可以工作:  cat COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt >> bundle.crt

  同時自己的私密金鑰server.key (也在本步驟提到的那個另一篇文章中產生過),也要複製到這個檔案夾下。

步驟三:修改/etc/httpd/conf.d/ssl.conf。修改如下幾條:

  SSLCertificateFile /etc/pki/tls/*yourdomainname*.crt

  SSLCertificateKeyFile /etc/pki/tls/myserver.key

  SSLCACertificateFile /etc/pki/tls/bundle.crt

  注釋掉第五行:  #listen 443 https 

  修改/etc/httpd/conf/httpd.conf.在第42行listen 80 下邊添加一行:  Listen 443   之後重啟Apache即可。

  上面兩條要對於443連接埠進行修改,否則會使443連接埠起不來,或者重啟Apache時提示Job for httpd.service failed. See ‘systemctl status httpd.service‘ and ‘journalctl -xn‘ for details. 細看日誌記錄說 make_sock: could not bind to address [::]:443,問題原因是Apache設定檔可能在多於一處進行了監聽443連接埠的配置,這裡我是將ssl.conf 裡的配置注釋掉,在httpd.conf裡進行全域配置,重啟Apache後發現https://ip可以訪問了,而且網域名稱前面成功出現了綠鎖。 

 

---恢複內容結束---

Centos 7 安裝LAMP以及在Apache上安裝positiveSSL。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.