-
為第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>
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(); ?>
原創文章,作者:N21_ Dominic,如若轉載,請注明出處:http://www.www58058.com/49001
總結的很好,