所需安裝包:httpd, php, mysql-server, php-mysqlphp
]# yum install -y httpd php mysql-server php-mysql ]# service httpd start ]# service mysqld start
FastCGI方式實現所需程序包:httpd, php-fpm, php-mysql, mariadb-server Modules方式實現所需程序包:httpd, php, php-mysql, mariadb-server ]# yum install -y httpd php php-mysql mariadb-server ]# systemctl start httpd.service ]# systemctl start mariadb.service 注意:CentOS 7默認httpd使用event模型,php默認編譯成模塊使用,其事件機制和模塊會報錯,要修改MPM
[root@localhostconf]# mkdir -pv /www/{wordpress,discuz,phpMyAdmin}
在"DocumentRoot "/var/www/html""前加#註釋掉該行配置
定義www.a.com爲我的博客訪問地址;www.b.com 爲discuz論壇的訪問地址;www.c.com爲phpMyAdmin訪問地址 ]# vim /etc/httpd/conf.d/virtual.conf 實例(注意10.1.253.15爲本機IP地址) NameVirtualHost 10.1.253.15:80 <VirtualHost 10.1.253.15:80> <Directory "/www/wordpress"> Options FollowSymLinks Allowoverride None </Directory> ServerName www.wordpress.com DocumentRoot "/www/wordpress" </VirtualHost> <VirtualHost10.1.253.15:80> <Directory "/www/discuz"> Options FollowSymLinks Allowoverride None </Directory> ServerName www.discuz.com DocumentRoot "/www/discuz" </VirtualHost> <VirtualHost10.1.253.15:80> <Directory "/www/phpMyAdmin"> Options FollowSymLinks Allowoverride None </Directory> ServerName www.phpMyAdmin.com DocumentRoot "/www/phpMyAdmin" </VirtualHost>
[root@localhostconf]# httpd -t [root@localhostconf]# service httpd reload
10.1.253.15 www.a.com www.b.com www.c.com
<?php phpinfo(); ?>
[root@localhostwordpress]# service mysqld start [root@localhostwordpress]# ss -tln
MySQL的命令行客戶端程序:mysql mysql>GRANT ALL PRIVILEGES ON db_name.tbl_name TO username@host IDENTIFIED BY 'password'; mysql> FLUSH PRIVILEGES; 實例解析: mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.1.%.%' IDENTIFIED BY 'ali'; mysql> FLUSH PRIVILEGES; 受權10.1網段全部主機以root用戶,密碼爲ali,可鏈接全部數據庫 注意:生產環境中不能用root用戶、不能鏈接全部數據庫的表、且來源主機要限定
centos6 skip_name_resolve innodb_file_per_table=ON centos7 skip_name_resolve = ON 或者skip_name_resolve = 1 防止主機名稱反向解析 innodb_file_per_table = ON
<?php $conn = mysql_connect('數據庫主機','用戶名','密碼'); if($conn) echo 'OK'; else echo 'Failure'; ?>
[root@localhostwordpress]# unzip wordpress-4.3.1-zh_CN.zip
#mysql mysql> CREATE DATABASE wpdb; mysql>GRANT ALL PRIVILEGES ON wpdb.* TO wpuser@'10.1.%.%' IDENTIFIED BY 'wppass'; mysql> FLUSH PRIVILEGES;
#cd wordpress #cp wp-config-sample.php wp-config.php 配置文件 # setenforce 0 關閉SElinux # iptables -F 關閉防火牆
注意,第一次訪問的時間可能較長,由於會初始化數據,建立相關數據庫html
[root@localhost ~]# cd /www/discuz [root@localhostdiscuz]# unzip Discuz_X3.2_SC_UTF8.zip [root@localhostdiscuz]# cp -r utility/convert/ /www/discuz/convert [root@localhostdiscuz]# chmod -R 777 convert/ 打開瀏覽器訪問http://www.b.com/convert/進行配置
[root@localhostpma]# yum install -y php-mbstring
[root@localhost ~]# cd /www/phpMyAdmin [root@localhostphpMyAdmin]# unzip phpMyAdmin-4.0.5-all-languages.zip [root@localhostphpMyAdmin]# ln -sv phpMyAdmin-4.0.5-all-languages pma
[root@localhostphpMyAdmin]# cd pma [root@localhostpma]# cp config.sample.inc.php config.inc.php
[root@localhostpma]# openssl rand -base64 20 svjtbqMcDXLzyJNbz3LD6lPlKXI=
在$cfg['blowfish_secret']= ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */位置放入生成的隨機數
[root@localhostpma]# service httpd restart
注意:phpMyAdmin不容許空用戶登陸,因此要受權本地用戶非空密碼mysql
使用mysqlsecureinstallation命令進行安全設定linux
轉自:http://www.178linux.com/52483sql