馬哥教育21期網絡班—第12周課程+練習—-LAMP練習中

  • 為第4題中的第2個虛擬主機提供https服務,使得用戶可以通過https安全的訪問此web站點;

  • (1)要求使用證書認證,證書中要求使用的國家(CN)、州(HA)、城市(ZZ)和組織(MageEdu);

  • (2)設置部門為Ops,主機名為www2.stuX.com,郵件為admin@stuX.com; [

root@centos CA]# touch index.txt serial
[root@centos CA]# echo 01 > serial 
[root@centos CA]# (umask 077;openssl genrsa -out ./private/cakey.pem 1024)
Generating RSA private key, 1024 bit long modulus
.......................................................++++++
.......++++++
e is 65537 (0x10001)
[root@centos CA]# openssl req -new  -x509 -key ./private/cakey.pem -out ./cacert.pem
[root@centos CA]# cd /usr/local/apache/
[root@centos apache]# mkdir ssl
[root@centos apache]# (umask 077;openssl genrsa -out ./ssl/http.key 1024)
[root@centos CA]# cd /usr/local/apache/
[root@centos apache]# mkdir ssl
[root@centos apache]# (umask 077;openssl genrsa -out ./ssl/http.key 1024)
Generating RSA private key, 1024 bit long modulus
..................................++++++
.......................................++++++
e is 65537 (0x10001)
[root@centos apache]# openssl req -new -key ./ssl/http.key -out ./ssl/http.crst -days 3600[root@centos apache]# openssl ca -in ./ssl/http.crst -out ./ssl/http.crt -days 3600[root@centos ~]# cd /usr/local/apache/ssl/
[root@centos ssl]# ls
http.crst  http.crt  http.key
之后修改/etc/httpd24/httpd.conf
LoadModule ssl_module modules/mod_ssl.so
Include /etc/httpd24/extra/httpd-ssl.conf
然后編輯/etc/httpd24/extra/httpd-ssl.conf如下
<VirtualHost _default_:443>
    DocumentRoot "/web/vhost/www2/"
    ServerName www2.stuX.com
    ErrorLog "/var/log/httpd/www2.err"
    CustomLog "/var/log/httpd/www2.access" common
<Directory "/web/vhost/www2/">
 AllowOverride None
    Options None
    Require all granted
</Directory>
SSLCertificateFile "/usr/local/apache/ssl/http.crt"SSLCertificateKeyFile "/usr/local/apache/ssl/http.key"</VirtualHost>

QQ截圖20160924234005.png

6、在LAMP架構中,請分別以php編譯成httpd模塊形式

yum groupinstall "Development Tools" "Server Platform Development"------>安裝包組1、編譯安裝Apachehttpd-2.4.9需要較新版本的apr和apr-util,因此需要事先對其進行升級
(1)、編譯安裝apr
tar xf apr-1.5.0.tar.bz2
cd apr-1.5.0
 ./configure --prefix=/usr/local/apr 
make && make install
(2)、編譯安裝apr-util
tar xf apr-util-1.5.3.tar.bz2 
cd apr-util-1.5.3./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
 make && make install
(3)、編譯安裝httpd
groupadd -r apache
useradd -r -g apache apahce
yum -y install pcre-devel ---->安裝pcre-devel支持
tar xf httpd-2.4.9.tar.bz2
cd httpd-2.4.9./configure --prefix=/usr/local/apache --sysconf=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=event
編譯的時候報這個錯誤------------------------------------------------------------------------------------------------------------
checking whether to enable mod_ssl… configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
yum install openssl-devel----->解決
make && make install3、修改httpd的主配置文件,設置其Pid文件的路徑
編輯vim /etc/httpd24/httpd.conf,添加如下行即可:PidFile  "/var/run/httpd/httpd24.pid"提供httpd 運行腳本
 cd /etc/rc.d/init.d/
 cp httpd httpd24 
 vim httpd24 
 apachectl=/usr/local/apache/bin/apachectl ---------------->改的
 httpd=${HTTPD-/usr/local/apache/bin/httpd}
 pidfile=${PIDFILE-/var/run/httpd/httpd24.pid}
 lockfile=${LOCKFILE-/var/lock/subsys/httpd24}
 chkconfig --add httpd24 
 chkconfig --list httpd24
 httpd24        	0:關閉	1:關閉	2:關閉	3:關閉	4:關閉	5:關閉	6:關閉
 httpd -t ------------>檢查語法
 hash -r --------------->清除緩存
 vim /etc/profile.d/httpd.sh
 export PATH=/usr/local/apache/bin$PATH-------------->定義PATH讀取
 . /etc/profile.d/httpd.sh ------------->重讀配置文件
  service httpd24 start
 ss -tnl ---------------->查看80端口是否被監聽到
 ps aux | grep httpd----->查看工作模式
 vim /etc/httpd24/httpd.conf ----------->配置文件 LoadModule deflate_module modules/mod_deflate.so----------->啟用 2、編譯安裝mariadb
 tar xf  mariadb-5.5.36-linux-x86_64.tar.gz -C /usr/local 
 ---------------------------------------------------------------
 準備數據目錄
 mkdir -pv /mydata/data------>創建數據存放目錄
 -----------------------------------------------------------------
  配置mariadb----->
  ----------------------------------------------------------------
groupadd -r -g 306 mysql
useradd -r -g 306 -u 306 mysql
cd /usr/local/
ln -sv mariadb-5.5.36-linux-x86_64 mysql
cd /usr/local/mysql
chown -R root:mysql ./*
scripts/mysql_install_db --datadir=/mydata/data --user=mysql
cp supper-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld  --->添加
chkconfig --list mysqld --->查看
mkdir /etc/mysql
cp support-files/my-large.cnf /etc/mysql/my.cnf
添加三個選項:
datadir = /mydata/data
innodb_file_per_table = on
skip_name_resolve = on
service  mysqld start
/usr/local/mysql/bin/mysql_secure_installation------------>安全初始化
mysql優化
編輯/etc/man.config,添加如下行即可:MANPATH  /usr/local/mysql/man7、輸出mysql的頭文件至系統頭文件路徑/usr/include:
這可以通過簡單的創建鏈接實現:
ln -sv /usr/local/mysql/include  /usr/include/mysql8、輸出mysql的庫文件給系統庫查找路徑:
echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
而后讓系統重新載入系統庫:
ldconfig9、修改PATH環境變量,讓系統可以直接使用mysql的相關命令。
vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH. /etc/profile.d/mysql.sh
 ---------------------------------------------------------------
 安裝php
解決依賴關系
yum -y groupinstall "Desktop Platform Development" yum -y install bzip2-devel libmcrypt-devel libxml2-devel
--------------------------------------------------------------2、編譯安裝php-5.4.0tar xf php-5.4.0.tar.bz2
cd php-5.4.0./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2  --enable-maintainer-zts
make
make test
make intall
--------------------------------------------------------------------------------------------------------------------------------------
為php提供配置文件:
 cp php.ini-production /etc/php.ini
 --------------------------------------------------------------------------------------------------------------- 3、 編輯apache配置文件httpd.conf,以apache支持php
 # vim /etc/httpd/httpd.conf 1、添加如下二行   AddType application/x-httpd-php  .php   AddType application/x-httpd-php-source  .phps 2、定位至DirectoryIndex index.html 
   修改為:    DirectoryIndex  index.php  index.html
    ---------------------------------------------------------------
   而后重新啟動httpd,或讓其重新載入配置文件即可測試php是否已經可以正常使用
 如果不能正常使用 vim /etc/rc.d/init.d/httpd24 
pidfile=${PIDFILE-/usr/local/apache/logs/httpd.pid}-------->修改
測試頁面index.php示例如下:
    <?php
      $link = mysql_connect('127.0.0.1','root','mageedu');      if ($link)
        echo "Success...";      else
        echo "Failure...";
 		phpinfo();
      mysql_close();
    ?>

2.4模塊.png

2.4模塊2.png

原創文章,作者:N21_ Dominic,如若轉載,請注明出處:http://www.www58058.com/49001

(0)
N21_ DominicN21_ Dominic
上一篇 2016-09-26
下一篇 2016-09-26

相關推薦

  • 第二周作業

    一、文件管理命令以及演示方法  1.1. mkdir命令     作用:創建文件夾     基本用法:mkdir [OPTION]… DIRECTORY…     參數:   &nbsp…

    Linux干貨 2016-08-22
  • 第四天作業

    1 、創建 用戶gentoo ,附加組為bin 和root ,默認shell為/bin/csh ,注釋信息為"Gentoo Distribution" 1 useradd -G bin,root -s /bin/csh -c "Gentoo Distribut…

    Linux干貨 2016-08-04
  • 2016全球運維大會,優云蔣君偉演講“CMDB+自動化的管理融合”成一大亮點

    2016全球運維大會于9月23日-24日在上海盛大開幕。作為國內運維行業的重量級大會,優云產品總監蔣君偉在自動化專場與來自全國各地的運維同行一起探討、分享業內自動化運維的最佳實踐?,F場情緒熱烈,氣氛高漲,成為了本屆全球運維大會的一大亮點。 全新梳理自動化與CMDB的融合之道 全球運維大會當天,運維自動化專場很多大牛針對自動化運維管理中的CMDB進行了激烈的討…

    Linux資訊 2016-12-05
  • 【社招】【小米-北京】運維開發工程師

    【社招】【小米-北京】運維開發工程師 【工作地點】北京市海淀區安寧莊東路72號科利源大廈 【薪酬福利】15k-30k 期權獎勵、六險一金、水果花茶、班車、健身房、食堂 【投遞方式】郵件主題“崗位+姓名”發送至lipengcheng3@xiaomi.com   崗位職責: 提高系統運維的自動化,主要包括運維平臺、PaaS、監控系統,自動化部…

    Linux干貨 2017-07-28
  • grep與正則表達式

    一、grep        grep常用于文本搜索。通過自定義的模式(pattern),篩選出使用者需要的文本內容。除了有grep,還有egrep和fgrep。其中egrep = grep  –E,而fgrep則是不支持正則表達式。     &nbs…

    2017-07-29
  • Linux之初見

     前言        第一次聽到Linux的大名是在進行網絡培訓的時候,隔壁的紅帽子培訓時聽到的。由于這樣,導致我很長一段時間都以為Linux就是紅帽,紅帽就是Linux,當聽到Ubantu的時候,還以為又是另一個全新的,區別于windows和Linux的版本,現在想起來很是羞愧。近期因為…

    Linux干貨 2016-02-14

評論列表(1條)

  • 馬哥教育
    馬哥教育 2016-10-24 23:07

    總結的很好,

欧美性久久久久