馬哥教育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 07:43
下一篇 2016-09-26 07:43

相關推薦

  • Python基礎篇之過程型程序設計

    一、Python過程型程序設計 面向過程 以指令為中心,由指令處理數據 如何組織代碼解碼問題 面向對象 以數據為中心,所有的處理代碼都圍繞數據展開 如何設計數據結構組織數據,并提供對此類數據所允許處理操作 簡單方法: 1)、編譯安裝新版本至某特定路徑 # yum install readline-devel # tar xf Python-2.7.6.tar…

    2018-01-11
  • redis基礎配置

    主程序:redis-server 配置文件:/etc/redis.conf 目錄: 1.redis-cli命令 2.conf配置文件 3.主從復制原理與架構實現 4.redis的高可用方案 – sentinel 2.conf配置文件 #### GENERAL #### daemonize yes #以守護進程的方式運行 pidfile “/var…

    Linux干貨 2017-08-08
  • block(data block,directory block)、inode、塊位圖、inode位圖和super block概念詳解

    一.基本概念:      1.block:文件系統中存儲數據的最小單元,ext3文件系統中,創建時默認4k,分為存儲文件數據的data block和存儲目錄數據的directory block      2.inode:又稱“索引節點”,每一個inode對應一個文件或目錄,記錄了…

    Linux干貨 2016-03-04
  • keepalived雙主模型高可用Nginx服務

    配置前提: (1) 各節點時間必須同步;             ntp, chrony (2) 確保iptables及selinux不會成為阻礙; (3) 各節點之間可通過主機名互相通信(對KA并非必須);   &nb…

    2017-07-06
  • 新的旅途

    三月末的北京已經讓人感覺有些炎熱,這是我第一次來北京。對我而言這是我人生的另一個起點,押上了我所有驕傲承載著我的夢想對未來所有的期望。這是一場豪賭,新的旅途,從今天開始。

    2018-03-26
  • 第十周練習-腳本部分

    1、寫一個腳本 (1) 能接受四個參數:start, stop, restart, status start: 輸出“starting 腳本名 finished.” … (2) 其它任意參數,均報錯退出; #!/bin/bash # case $1 in start)     echo&…

    Linux干貨 2016-12-31

評論列表(1條)

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

    總結的很好,

欧美性久久久久