码迷,mamicode.com
首页 > 其他好文 > 详细

lamp的搭建blog

时间:2015-11-29 06:55:32      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:lamp   blog   mysql   

准备两台服务器,一台安装Apache,一台安装mysql

 

安装Apache

1、下载安装

yum install zlib-devel -y
wgethttp://mirror.bit.edu.cn/apache/httpd/httpd-2.2.31.tar.gz
tar xf httpd-2.2.31.tar.gz
cd httpd-2.2.31
./configure --prefix=/application/apache2.2.31 --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite
make
make install
ln -s /application/apache2.2.31//application/apache
ls -l /application/

2、启动服务

/application/apache/bin/apachectl start
netstat -lntup|grep httpd

3、配置基于域名的虚拟主机

cd /application/apache/conf/
vim httpd.conf 修改98,132,378,396行
98 ServerName 127.0.0.1:80
132 <Directory"/application/apache2.2.31/html">
378 Include conf/extra/httpd-mpm.conf
396 Include conf/extra/httpd-vhosts.conf
 
 
cd /application/apache/conf/extraextra/
vim httpd-vhosts.conf
 
<VirtualHost *:80>
   ServerAdmin oldboy@oldboyedu.com
   DocumentRoot "/application/apache2.2.31/html/www"
   ServerName www.etiantian.org
 
   ServerAlias etiantian.org
   ErrorLog "/app/logs/www-error_log"
   CustomLog "/app/logs/www-access_log" common
</VirtualHost>
 
<VirtualHost *:80>
   ServerAdmin oldboy@oldboyedu.com
   DocumentRoot "/application/apache2.2.31/html/bbs"
   ServerName bbs.etiantian.org
   ErrorLog "/app/logs/bbs-error_log"
   CustomLog "/app/logs/bbs-access_log" common
</VirtualHost>
 
<VirtualHost *:80>
   ServerAdmin oldboy@oldboyedu.com
   DocumentRoot "/application/apache2.2.31/html/blog"
   ServerName blog.etiantian.org
   ErrorLog "/app/logs/blog-error_log"
   CustomLog "/app/logs/blog-access_log" common
</VirtualHost>
 
 
cd /application/apache/conf/extra
mkdir -p/application/apache2.2.31/html/{www,bbs,blog}
echo www.etiantian.org>/application/apache2.2.31/html/www/index.html
echo bbs.etiantian.org>/application/apache2.2.31/html/bbs/index.html
echo blog.etiantian.org>/application/apache2.2.31/html/blog/index.html
mkdir /app/logs -p

检查语法

/application/apache/bin/apachectl -t
Syntax OK
/application/apache/bin/apachectl graceful

 

验证之前在/etc/hosts要有解析

验证:

curl www.etiantian.org                 

www.etiantian.org

curl bbs.etiantian.org

bbs.etiantian.org

curl blog.etiantian.org

blog.etiantian.org


本机不安装mysqlmysql服务器独立存在 

安装php 

1)安装依赖包

wget -O /etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-6.repo
yum install zlib-devel libxml2-devellibjpeg-devel libiconv-devel -y
yum install freetype-devel libpng-develgd-devel curl-devel libxslt-devel -y
 
rpm -qa freetype-devellibjpeg-turbo-devel  libcurl-devel  libpng-devel gd-devel libxslt-devel 
查看结果:
freetype-devel-2.3.11-15.el6_6.1.x86_64
gd-devel-2.0.35-11.el6.x86_64
libpng-devel-1.2.49-1.el6_2.x86_64
libcurl-devel-7.19.7-46.el6.x86_64
libxslt-devel-1.1.26-2.el6_3.1.x86_64
libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64

源码包里没有下面的包:

libiconv-devel

安装libiconv-devel

mkdir -p /home/oldboy/tools
cd /home/oldboy/tools
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure -prefix=/usr/local/libiconv
make    
make install
cd ../

安装libmcrypt

yum install libmcrypt-devel -y
rpm -qa libmcrypt-devel             
libmcrypt-devel-2.5.8-9.el6.x86_64

安装mhash

yum -y install mhash mhash-devel
rpm -qa mhash mhash-devel
mhash-0.9.9.9-3.el6.x86_64
mhash-devel-0.9.9.9-3.el6.x86_64

安装mcrypt加密扩展库

yum -y install mcrypt mcrypt-devel
rpm -qa mcrypt 
mcrypt-2.6.8-10.el6.x86_64

正式安装php

rz -y上传软件包

tar zxf php-5.3.27.tar.gz
cd php-5.3.27
./configure --prefix=/application/php5.3.27 --with-apxs2=/application/apache/bin/apxs --with-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-short-tags --enable-zend-multibyte --enable-static --with-xsl --enable-ftp 

make
make install
ln -s /application/php5.3.27//application/php

 

cd /application/apache/conf/

配置:

vim httpd.conf
311行下增加:
   AddType application/x-httpd-php .php .phtml
   AddType application/x-httpd-php-source .phps
168行下增加:
   DirectoryIndex index.php index.html
67行下增加
User www
Group www

建立用户:

useradd -s /sbin/nologin www

id www

/application/apache/bin/apachectl -t
Syntax OK
/application/apache/bin/apachectl graceful

 

站点目录

cd /application/apache/html/blog

建立两个测试文件

vim test1.php

<?php
phpinfo();
?>

第二个测试文件要等mysql安装好了,才能出结果

vim test2.php

<?php
   $link_id=mysql_connect(‘db01.etiantian.org‘,‘wordpress‘,‘123456‘) ormysql_error();
   if($link_id){
          echo "mysql successful by zhou!";
    }
    else{
          echo mysql_error();
    }
?>

vim /etc/hosts

172.16.1.51 db01.etiantian.org

检测:

ping db01.etiantian.org

检查语法

/application/apache/bin/apachectl -t

启动服务

/application/apache/bin/apachectl start

重新加载

/application/apache/bin/apachectl graceful

 

 

二、安装MySQL数据库

 

使用mysql-5.5.32二进制包安装

1、添加用户

useradd mysql -s /sbin/nologin -M

2、解包处理

tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz
mv mysql-5.5.32-linux2.6-x86_64 /application/mysql-5.5.32

创建软链接

ln -s /application/mysql-5.5.32/ /application/mysql

3、初始化数据库

/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql

初始化的结果是生成文件

ll /application/mysql/data/
total 12
drwx------ 2 mysql root  4096 Nov 11 02:59 mysql
drwx------ 2 mysql mysql 4096 Nov 11 02:59performance_schema
drwxr-xr-x 2 mysql root  4096 Nov 11 02:53 test

初始化后要授权:

chown -R mysql.mysql /application/mysql/

4、启动数据库 

\cp /application/mysql/support-files/my-small.cnf  /etc/my.cnf
sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe
\cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /etc/init.d/mysqld

启动mysql服务

/etc/init.d/mysqld  start
Starting MySQL SUCCESS!

MySQL的路径

PATH路径

echo ‘PATH="/application/mysql/bin:$PATH"‘ >>/etc/profile
source /etc/profile


进入MySQL

mysql

 

5.管理数据库

设置新密码

mysqladmin -uroot password
New password:   此处输入密码
Confirm new password: 重复上面的密码

登录数据库

mysql -uroot -p
Enter password:

创建数据库
mysql> create database wordpress;
Query OK, 1 row affected (0.07 sec)
授权
mysql> grant all on wordpress.* to wordpress@‘localhost‘identified by ‘123456‘;
Query OK, 0 rows affected (0.07 sec)
刷新
mysql> flush privileges;
Query OK, 0 rows affected (0.05 sec)
 
mysql> show grants for wordpress@‘localhost‘;      
+------------------------------------------------------------------------------------------------------------------+
| Grants for wordpress@localhost                                                                                  |
+------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO ‘wordpress‘@‘localhost‘IDENTIFIED BY PASSWORD ‘*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9‘ |
| GRANT ALL PRIVILEGES ON `wordpress`.* TO ‘wordpress‘@‘localhost‘                                                |
+------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.06 sec)
 
mysql> select user,host from mysql.user whereuser=‘wordpress‘;
+-----------+-----------+
| user      |host      |
+-----------+-----------+
| wordpress | localhost |
+-----------+-----------+
1 row in set (0.00 sec)
 
 
mysql> select user,host from mysql.user;
+-----------+-----------+
| user      | host     |
+-----------+-----------+
| root      |127.0.0.1 |
| root      |localhost |
| wordpress | localhost |
| root      |web01     |
+-----------+-----------+
4 rows in set (0.00 sec)

切换到站点目录:

cd /application/apache/html/blog/
rz -y
tar xf wordpress-4.2.2-zh_CN.tar.gz
mv blog/* .
cd ../
chown -R www.www blog/

在本机hosts做解析后,浏览器访问以下地址,按要求下一步。

blog.etiantian.org/wp-admin/setup-config.php


本文出自 “zhou-Linux修炼之路” 博客,请务必保留此出处http://zhouzefang.blog.51cto.com/9475331/1717699

lamp的搭建blog

标签:lamp   blog   mysql   

原文地址:http://zhouzefang.blog.51cto.com/9475331/1717699

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!