CenOS 7 rpm包安裝lamp
CentOS 7 LAMP
vhost1: phpMyadmin 佈署pma.mykernel.cn https
vhost2: wordpress 佈署wp.mykernel.cn
vhost3: Discuz 佈署dz.mykernel.cn
實驗環境
關閉防火牆: iptables -F
搭建LAMP環境
準備虛擬主機的DocumentRoot
# mkdir -pv /web/vhosts # chcon -t httpd_sys_content_t /web/vhosts # mkdir /web/vhosts/{pma,wp,dz}
準備虛擬主機
安裝程式包和備份配置檔案
# yum -y install apr apr-util httpd # cp -v /etc/httpd/conf/httpd.conf{,.bak}
在主配置檔案中,註釋中心主機
配置檔案: /etc/httpd/conf/httpd.conf #DocumentRoot "/var/www/html"
在conf.d/*.conf新增虛擬主機
# vim /etc/httpd/conf.d/virtualhost.conf #phpMyadmin <VirtualHost *:80> DocumentRoot /web/vhosts/pma ServerName pma.mykernel.cn CustomLog logs/pma_access.log combined ErrorLog logs/pma_error.log <Directory "/web/vhosts/pma"> Options FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost> #wordpress <VirtualHost *:80> DocumentRoot /web/vhosts/wp ServerName wp.mykernel.cn CustomLog logs/wp_access.log combined ErrorLog logs/wp_error.log <Directory "/web/vhosts/wp"> Options FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost> #disscuzz <VirtualHost *:80> DocumentRoot /web/vhosts/dz ServerName dz.mykernel.cn CustomLog logs/dz_access.log combined ErrorLog logs/dz_error.log <Directory "/web/vhosts/dz"> Options FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost>
測試語法
# httpd -t
啟動web服務
# systemctl start httpd.service
測試是否能訪問
1.windows 在C:\Windows\System32\drivers\etc\hosts檔案中新增如下內容(用於解析域名) 192.168.3.186 pma.mykernel.cn 192.168.3.186 wp.mykernel.cn 192.168.3.186 dz.mykernel.cn 開啟Google瀏覽器,分別輸入: pma.mykernel.cn wp.mykernel.cn dz.mykernel.cn,都將顯示: Testing 123.. 2.linux 在/etc/hosts檔案中新增如下內容(用於解析域名) 192.168.3.186 pma.mykernel.cn 192.168.3.186 wp.mykernel.cn 192.168.3.186 dz.mykernel.cn 安裝可訪問檔案協議的客戶端工具 # yum -y install telnet curl elinks 測試訪問 # curl http://192.168.3.186 # elinks --dump http://192.168.3.186 # telnet 192.168.3.186 80 Escape character is '^]'. HEAD / HTTP/1.1 Host:192.168.3.186
安裝php作為httpd的模組而存在: libphp5.so(prefork) libphp5-zts.so(work, event)
# yum -y install php # rpm -ql php /etc/httpd/conf.d/php.conf //為libphp5.so提供的配置 /etc/httpd/conf.modules.d/10-php.conf //裝載此模組 /usr/lib64/httpd/modules/libphp5.so //提供給httpd的php模組,僅能用於prefork模型 # systemctl restart httpd //基於module需要重啟web讀取php配置
檢視當前mpm
# httpd -M
測試能否執行php程式
# for i in wp dz pma; do echo -e "<?php\nphpinfo();\n?>" > /web/vhosts/$i/index.php ; done
在windows瀏覽器中測試
安裝php-mysql和mariadb-server用於提供應用程式伺服器中執行中的程式需要用到後端mysql提供的資料時,php-mysql用於封裝和解析請求,mariadb-server用於儲存資料.
# yum -y install php-mysql mariadb-server
啟動mariadb(mysql分支的開源實現)
# systemctl start mariadb.service # ss -tunl //觀察3306埠 # systemctl reload httpd.service //過載web服務
測試連線MariaDB
# mysql
在各個虛擬主機中新增以下內容,並在windows主機中測試用php-mysql的函式庫連線mysql
<?php $link=mysql_connect('localhost','root',''); if($link) echo ok; else echo failure; mysql_close(); phpinfo(); ?>
一、佈署phpMyadmin(MariaDB webGUI)
安裝依賴:
# yum -y install php-mbstring # systemctl restart httpd.service
下載phpMyadmin
http://files.phpmyadmin.net/phpMyAdmin/4.0.10.20/phpMyAdmin-4.0.10.20-all-languages.zip
展開至DocumentRoot
# cd /web/vhosts/pma # unzip ~/phpMyAdmin-4.0.10.20-all-languages.zip # ln -sv phpMyAdmin-4.0.10.20-all-languages pma //便於版本升級
配置
# cp pma/config.sample.inc.php pma/config.inc.php # openssl rand -base64 32 ZAN6DZ6ov68hG0PIKIiXUukwWaoqPYvmzOQ1UnlqQcQ= # vim pma/config.inc.php //在YOU MUST FILL IN THIS FOR COOKIE AUTH! */ 前修改隨機數為生成的隨機數 $cfg['Servers'][$i]['AllowNoPassword'] = false; //表示不能空密碼登入phpMyadmin
給root使用者新增密碼
# mysql MariaDB [(none)]> set password for 'root'@'127.0.0.1'=PASSWORD('123'); MariaDB [(none)]> set password for 'root'@'localhost'=PASSWORD('123'); MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> quit # mysql -uroot -p123
在windows主機上測試連線phpMyadmin
http://pma.mykernel.cn/pma
配置https
建立ca <192.168.3.193>
# openssl version # dir=/etc/pki/CA # touch $dir/index.txt # echo "01" > $dir/serial # (umask 077;openssl genrsa -out $dir/private/cakey.pem 4096) # openssl req -new -x509 -key $dir/private/cakey.pem -out $dir/cacert.pem -days 7300 (SC, ChengDu, ChengDu, MageEdu Ltd, Ops, ca.mykernel.cn, [email protected])
申請請求 <192.168.3.186>
# install -d /etc/httpd/ssl # cd /etc/httpd/ssl # (umask 077;openssl genrsa -out httpd.key 4096) # openssl req -new -key httpd.key -out httpd.csr -days 7300 (SC, ChengDu, ChengDu, MageEdu Ltd, Ops, pma.mykernel.cn, [email protected])
提交請求 <192.168.3.186>
# scp httpd.csr [email protected]:/tmp
簽證 <192.168.3.193>
# openssl ca -in /tmp/httpd.csr -out $dir/certs/pma.mykernel.cn.crt -days 365
獲取證書 <192.168.3.193>
# scp $dir/certs/pma.mykernel.cn.crt [email protected]:/etc/httpd/ssl
安裝mod_ssl (SSL/TLS module for the Apache HTTP Server) <192.168.3.186>
# yum -y install mod_ssl
配置使用ssl <192.168.3.186>
# rpm -qc mod_ssl /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.modules.d/00-ssl.conf # cp -v /etc/httpd/conf.d/ssl.conf{,.bak} # vim /etc/httpd/conf.d/ssl.conf <VirtualHost *:443> DocumentRoot "/web/vhosts/pma/" ServerName pma.mykernel.cn SSLEngine on SSLCertificateFile /etc/httpd/ssl/pma.mykernel.cn.crt SSLCertificateKeyFile /etc/httpd/ssl/httpd.key <Directory "/web/vhosts/pma"> Options None AllowOverride FollowSymLinks Require all granted </Directory> # systemctl restart httpd.service //需要重新監聽更多的埠 # ss -tnl
二、佈署wordpress
下載wordpress
http://cn.wordpress.org/wordpress-4.8.1-zh_CN.zip
展開至DocumentRoot
# cd /web/vhosts/pma # unzip ~/wordpress-4.8.1-zh_CN.zip # ln -sv wordpress wp
配置
# cp wp/wp-config-sample.php wp/wp-config.php /** WordPress資料庫的名稱 */ define('DB_NAME', 'wpdb'); /** MySQL資料庫使用者名稱 */ define('DB_USER', 'wpuser'); /** MySQL資料庫密碼 */ define('DB_PASSWORD', '[email protected]');
新增一個管理wordpress資料庫"wpdb"的使用者"wpuser"
# mysql -uroot -p123 MariaDB [(none)]> CREATE DATABASE wpdb; MariaDB [(none)]> GRANT ALL ON wpdb.* TO 'wpuser'@'localhost' IDENTIFIED BY '[email protected]'; MariaDB [(none)]> GRANT ALL ON wpdb.* TO 'wpuser'@'127.0.0.1' IDENTIFIED BY '[email protected]'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> quit # mysql -uwpuser [email protected]
在windows主機上測試連線wordpress
http://wp.mykernel.cn/wp
三、佈署disscuzz
下載disscuzz
http://download.comsenz.com/DiscuzX/2.5/Discuz_X2.5_SC_UTF8.zip
展開至DocumentRoot
# cd /web/vhosts/dz # unzip ~/Discuz_X2.5_SC_UTF8.zip
配置
# setenforce 0 # cd upload # setfacl -R -m u:apache:rwx config data uc_client uc_server
新增一個管理disscuzz資料庫"dzdb"的使用者"dzuser"
# mysql -uroot -p123 MariaDB [(none)]> CREATE DATABASE dzdb; MariaDB [(none)]> GRANT ALL ON dzdb.* TO 'dzuser'@'localhost' IDENTIFIED BY '[email protected]'; MariaDB [(none)]> GRANT ALL ON dzdb.* TO 'dzuser'@'127.0.0.1' IDENTIFIED BY '[email protected]'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> quit # mysql -udzuser [email protected]
在windows主機上測試連線disscuzz
http://dz.mykernel.cn/upload
感激
QQ: 2580259468
- 2021年軟體測試的六大趨勢,必看!
- 重磅:Python/Java/C 2020年之爭!誰是你心中的NO.1?
- 新零售的未來 智慧移動機器人將發揮哪些作用?
- pytest-assume外掛(全網最詳細解釋):多重斷言執行
- UML之互動圖(序列圖與協作圖)
- 【一看】看圖說話之瓶頸
- MSSQL系列之十四 無限極分類的解決辦法
- 通過編寫“猜數字”遊戲學習 Lua
- Linux-基礎命令1
- rf IDEAS為LG電子提供WAVE ID(R)安全訪問技術
- 網工學習必備筆記——VLAN路由-三層交換
- Zabbix經驗分享-缺包常見問題處理
- 我用Pipenv來管理專案環境,大寫的爽
- Kotlin 百度離線人臉採集SDK
- CenOS 7 rpm包安裝lamp
- 取餘運算應用(2)-在glsl中
- 淺談 Ads Auction(1) - 知乎
- 感謝一直以來的陪伴,我們抽個獎吧!
- 速度數百倍之差,有人斷言KNN面臨淘汰,更快更強的ANN將取而代之 - 知乎
- 高併發賬戶記錄查詢