实验环境 1
2
3
4
[iyunv@LAMP ~]# cat /etc/redhat-release
CentOS release 6.6 (Final)
[iyunv@LAMP ~]# uname -rn
LAMP 2.6.32-504.el6.x86_64
使用软件
1
2
3
4
5
6
7
8
9
apr-1.5.0.tar.bz2
apr-util-1.5.3.tar.bz2
httpd-2.4.10.tar.bz2
mariadb-5.5.43-linux-x86_64.tar.gz
php-5.4.40.tar.bz2
phpMyAdmin-4.0.5-all-languages.zip
wordpress-3.3.1-zh_CN.zip
xcache-3.2.0.tar.bz2
Discuz_7.2_FULL_SC_UTF8.zip
编译安装httpd 2.4以上的版本的httpd依赖于apr,而且apr的版本不能低于1.4,但是系统自带的apr版本不够所以需要安装高版本的apr,还依赖与pcre-devel openssl-devel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
yum -y groupinstall "Development tools""Desktop Platform Development"
yum -y install pcre-devel openssl-devel
tar xf apr-1.5.0.tar.bz2
cd apr-1.5.0
./configure --prefix=/usr/local/apr
make && make install
cd ..
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
cd ..
编译安装httpd
1
2
3
4
5
6
7
tar xf httpd-2.4.10.tar.bz2
cd httpd-2.4.10
./configure --prefix=/usr/local/apache--sysconfdir=/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
make && make install
编译参数说明:
--prefix=/usr/local/apache #安装路径
--sysconfdir=/etc/httpd24 #配置文件路径
--enable-so #启用动态模块加载
--enable-ssl #启用ssl功能
--enable-cgi #启用cgi脚本程序支持
--enable-rewrite #启用网页地址重启功能
--with-zlib #支持zlib压缩功能
--with-pcre #支持pcre
--with-apr=/usr/local/apr #设置apr路径
--with-apr-util=/usr/local/apr-util #设置apr-util路径
--enable-modules=most #尽可能多的启用模块
--enable-mpms-shared=all #把所有的mpm功能都做成共享模块
--with-mpm=event #设置mpm模块为event
优化执行路径,让系统可以查找到httpd的命令
1
2
3
4
5
6
[iyunv@LAMP httpd-2.4.10]# vim/etc/profile.d/httpd.sh
export PATH=/usr/local/apache/bin:$PATH
[iyunv@LAMP httpd-2.4.10]# . /etc/profile.d/httpd.sh
[iyunv@LAMP httpd-2.4.10]# which httpd
/usr/local/apache/bin/httpd
[iyunv@LAMP httpd-2.4.10]# hash –r #清除以前系统上记录的httpd搜索记录
设置启动脚本
1
2
3
4
5
6
7
8
9
[iyunv@LAMP apache]# cp bin/apachectl/etc/init.d/httpd24
[iyunv@LAMP apache]# vim /etc/init.d/httpd24
#!/bin/sh
# chkconfig: 35 85 15 #设置服务识别参数,3、5级别启动,启动顺序85,关闭顺序15
# description: Apache #服务描述信息
[iyunv@LAMP apache]# chkconfig --add httpd24
[iyunv@LAMP apache]# chkconfig --level 35 httpd24 on
[iyunv@LAMP apache]# chkconfig --list httpd24
httpd24 0:off 1:off 2:off 3:on 4:off 5:on 6:off
启动服务并且访问验证
1
2
3
[iyunv@LAMP apache]# service httpd24 start
[iyunv@LAMP apache]# netstat -lnt | grep 80
tcp 0 0 :::80 :::* LISTEN
安装mariadb 新建MariaDB用户,并且设置用户为数据目录/mydata/data/的属主和属组
1
2
3
[iyunv@LAMP Sources]# groupadd -r mysql
[iyunv@LAMP Sources]# useradd -g mysql -r -s/sbin/nologin -M mysql
[iyunv@LAMP Sources]# chown -R mysql:mysql/mydata/data/
安装MariaDB并初始化
1
2
3
4
5
6
tar xf mariadb-5.5.43-linux-x86_64.tar.gz -C/usr/local/
cd /usr/local/
ln -sv mariadb-5.5.43-linux-x86_64/ mysql
cd mysql/
chown -R mysql:mysql .
scripts/mysql_install_db --user=mysql --datadir=/mydata/data/ #指定进程用户,和数据目录
为MariaDB提供主配置文件
1
2
3
4
5
[iyunv@LAMP mysql]# cp support-files/my-large.cnf/etc/my.cnf
[iyunv@LAMP mysql]# vim /etc/my.cnf
thread_concurrency = 2 #CPU数量乘以2
datadir = /mydata/data #指定数据文件目录
innodb_file_per_table = 1 #设置每表一个表文件
为MariaDB提供启动脚本
1
2
3
4
5
6
[iyunv@LAMP mysql]# cp support-files/mysql.server/etc/rc.d/init.d/mysqld
[iyunv@LAMP mysql]# chmod +x /etc/rc.d/init.d/mysqld
[iyunv@LAMP mysql]# chkconfig --add mysqld
[iyunv@LAMP mysql]# chkconfig mysqld on
[iyunv@LAMP mysql]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
修改PATH环境变量,让系统直接使用MariaDB相关命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[iyunv@LAMP mysql]# vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
[iyunv@LAMP mysql]# . /etc/profile.d/mysql.sh
启动测试
[iyunv@LAMP mysql]# service mysqld start
Starting MySQL... [ OK ]
[iyunv@LAMP mysql]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.43-MariaDB-log MariaDB Server
Copyright (c) 2000, 2015, Oracle, MariaDBCorporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clearthe current input statement.
MariaDB [(none)]>
编译安装php 解决依赖关系
1
yum -y install bzip2-devel libmcrypt-devel
编译安装php
1
2
3
4
5
6
7
8
tar xf php-5.4.40.tar.bz2
cd php-5.4.40
./configure --prefix=/usr/local/php--with-mysql=/usr/local/mysql/
--with-mysqli=/usr/local/mysql/bin/mysql_config--with-apxs2=/usr/local/apache/bin/apxs
--enable-mbstring --with-freetype-dir--with-png-dir --with-zlib --with-libxml-dir=/usr/
--enable-xml--enable-sockets --with-mcrypt --with-config-file-path=/etc/php/php.ini
--with-config-file-scan-dir=/etc/php.d
make && make install
编译参数说明:
--prefix=/usr/local/php #php安装位置
--with-mysql=/usr/local/mysql/ #指明mysql安装路径
--with-mysqli=/usr/local/mysql/bin/mysql_config #mysql的访问接口
--with-apxs2=/usr/local/apache/bin/apxs #apache的apx位置
--enable-mbstring #支持多字节文本
--with-freetype-dir #搜索当前系统支持的字体
--with-png-dir #支持png格式的图片
--with-jpeg-dir #支持jpeg格式的图片
--with-zlib #支持zlib压缩
--with-libxml-dir=/usr/ #libxml路径
--enable-xml #支持xml文档的处理
--enable-sockets #启用socket功能
--with-mcrypt #启用mcrypt功能
--with-bz2 #支持with-bz2功能
--with-config-file-path=/etc/php/php.ini #php主配置文件
--with-config-file-scan-dir=/etc/php.d #辅助配置文件
为php提供配置文件
1
2
[iyunv@LAMP php-5.4.40]# mkdir /etc/php
[iyunv@LAMP php-5.4.40]# cp php.ini-production/etc/php/php.ini
编辑apache支持php
1
2
3
4
[iyunv@LAMP php-5.4.40]# vim /etc/httpd24/httpd.conf
AddTypeapplication/x-httpd-php .php
AddTypeapplication/x-httpd-php-source .phps
DirectoryIndex index.php index.html
重启httpd或让其重新载入配置文件即可测试php是否已经可以正常使用
Apache连接php测试 1
2
3
4
[iyunv@LAMP php-5.4.40]# vim/usr/local/apache/htdocs/index.php
<?php
phpinfo();
?>
php连接MariaDB测试 1
2
3
4
5
6
7
8
[iyunv@LAMP php-5.4.40]# vim/usr/local/apache/htdocs/index.php
<?php
$conn=mysql_connect('localhost','root','');
if ($conn)
echo"连接数据库成功";
else
echo"连接数据库失败"
?>
设置虚拟主机 编辑主配置文件,注释中心主机,启用虚拟主机选项
1
2
#DocumentRoot "/usr/local/apache/htdocs"
Include /etc/httpd/extra/httpd-vhosts.conf
创建相关页面
1
2
3
4
5
6
7
8
9
[iyunv@LAMP ~]# mkdir -p/www/{bbs,phpMyadmin,wordpress}
[iyunv@LAMP ~]# tree /www/
/www/
├── bbs
├── phpMyadmin
└── wordpress
[iyunv@LAMP ~]# echo bbs > /www/bbs/index.html
[iyunv@LAMP ~]# echo wordpress >/www/wordpress/index.html
[iyunv@LAMP ~]# echo myadmin >/www/phpMyadmin/index.html
编辑虚拟主机配置文件设置虚拟主机
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<VirtualHost *:80>
ServerName bbs.discuz.com
DocumentRoot "/www/bbs"
<Directory "/www/bbs">
Options none
AllowOverride none
Require all granted
</Directory>
ErrorLog"/var/log/httpd/bbs-error-log"
CustomLog"/var/log/httpd/bbs-access-log" common
</VirtualHost>
<VirtualHost *:80>
ServerName mysql.phpMyadmin.com
DocumentRoot "/www/phpMyadmin"
<Directory"/www/phpMyadmin">
Options none
AllowOverride none
Require all granted
</Directory>
ErrorLog"/var/log/httpd/phpMyadmin-error-log"
CustomLog"/var/log/httpd/phpMyadmin-access-log" common
</VirtualHost>
<VirtualHost *:80>
ServerName blog.wordpress.com
DocumentRoot "/www/wordpress"
<Directory "/www/wordpress">
Options none
AllowOverride none
Require all granted
</Directory>
ErrorLog"/var/log/httpd/wordpress-error-log"
CustomLog"/var/log/httpd/wordpress-access-log" common
</VirtualHost>
验证:客户端修改hosts文件,然后分别访问虚拟主机测试
部署phpMyadmin 1
2
3
4
unzip phpMyAdmin-4.0.5-all-languages.zip
mv phpMyAdmin-4.0.5-all-languages/*/www/phpMyadmin/
cd /www/phpMyadmin/
cp config.sample.inc.php config.inc.php
访问页面出现如下内容表示部署成功
此处不允许空密码登录,而默认安装的MariaDB是管理员是空密码,所以需要手动为MariaDB管理员设置密码
1
2
MariaDB [mysql]> UPdate user SETPassword=PASSWORD('redhat') WHERE user='root';
MariaDB [mysql]> FLUSH PRIVILEGES;
访问成功,结果如下所示
论坛部署Discuz 连接数据库,创建bbs的库和用户
1
2
MariaDB [(none)]> create database bbsdb;
MariaDB [(none)]> GRANT all ON bbsdb.* TO'runbbs'@'localhost' IDENTIFIED BY 'adm123';
解压程序代码
1
[iyunv@LAMP Sources]# unzipDiscuz_7.2_FULL_SC_UTF8.zip -d Discuz
解压完成之后出现下面三个目录表示解压成功
1
2
3
4
5
[iyunv@LAMP Sources]# ls -lh Discuz
total 12K
drwxr-xr-x 2root root 4.0K Oct 31 2012 readme
drwxr-xr-x 12 root root 4.0K Oct 31 2012 upload
drwxr-xr-x 4root root 4.0K Oct 31 2012 utility
将upload目录上传到web目录下,并且设置httpd的服务用户对指定目录有写权限,否则会报错。
1
2
3
4
[iyunv@LAMP Sources]# mv Discuz/upload/* /www/bbs/
[iyunv@LAMP Sources]# cd /www/bbs/
[iyunv@LAMP bbs]# chown -R daemon templates/attachments/ forumdata/
[iyunv@LAMP bbs]# chown -R daemonuc_client/data/cache/ config.inc.php
访问web安装即可
添加数据库相关信息
只需要更改提供进行设置即可,设置完成出现下面的界面表示安装成功
安装后的处理,为了放置出现再次安装的情况,需要移除安装文件install
1
2
[iyunv@LAMP bbs]# mv install/ install.lock
[iyunv@LAMP bbs]# chmod 600 install.lock/
部署博客 1
2
3
4
5
6
7
8
9
10
11
12
13
[iyunv@LAMP Sources]# unzipwordpress-3.3.1-zh_CN.zip
[iyunv@LAMP Sources]# mv wordpress/* /www/wordpress/
[iyunv@LAMP Sources]# cd /www/wordpress/
[iyunv@LAMP wordpress]# cp wp-config-sample.phpwp-config.php
[iyunv@LAMP wordpress]# vim wp-config.php
/** WordPress 数据库的名称 */
define('DB_NAME', 'wordpress');
/** MySQL 数据库用户名 */
define('DB_USER', 'wordpress');
/** MySQL 数据库密码 */
define('DB_PASSWORD', 'myblog');
数据库创建博客的数据库和博客连接数据库的用户
1
2
MariaDB [(none)]> create database wordpress;
MariaDB [(none)]> GRANT all ON wordpress.* TO'wordpress'@'localhost' IDENTIFIED BY 'myblog';
设置完成之后打开浏览器输入http://blog.wordpress.com/wp-admin/install.php即开始安装
安装完成之后会转到登录页面,询问是否登录到后台管理博客
输入博客的域名访问博客前台
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com