您的位置:首页 > 运维架构 > Linux

lamp快速搭建

2016-01-01 05:13 686 查看
首先先在Linux上安装相应的库文件

yum install -y zlib-devel pcre pcre-devel apr apr-devel libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel libcurl-devel libjpeg-devel libtool-ltdl-devel epel-release libmcrypt-devel

mysql
下载mysql然后解压
tar zxvf mysql-5.1.73-linux-x86_64-glibc23.tar.gz

把mysql文件移动重命名到/usr/local/里面
mv mysql-5.1.73-linux-x86_64-glibc23 /usr/local/mysql(mysql的程序文件)

创建mysql用户
useradd -s /sbin/nologin mysql

进去mysql里面
cd /usr/local/mysql

创建目录和修改权限
mkdir -p /data/mysql ; chown -R mysql:mysql /data/mysql

初始化数据库
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

复制配置文件
cp support-files/my-large.cnf /etc/my.cnf

复制启动文件
cp support-files/mysql.server /etc/init.d/mysqld

修改启动文件权限
chmod 755 /etc/init.d/mysqld

然后修改启动脚本的参数
vim /etc/init.d/mysqld “datadir=/data/mysql”

加载系统服务里面去
chkconfig --add mysqld

设置开机启动
chkconfig mysqld on

启动mysql
service mysqld start

配置文件里有log-bin=mysql-bin 这是mysql里面二进制的bin-log
如果打开的话他会在你更新数据查询数据读取数据的时候会记录相应的日志

安装Apache

下载解压
httpd-2.2.24.tar.bz2
tar jxvf httpd-2.2.24.tar.bz2

进入
cd httpd-2.2.24

编译参数
./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre

是Apache这个软件要依赖的一个包可以支持httpd 他能跨平台去运作不管是linux还是Windows或者是unix都可以去运行 那么他需要一个底层的包去支持它就是apr
--with-included-apr

是正则相关的库
--with-pcre

make && make install

启动
/usr/local/bin/apachectl start

可以查看模块
-M

可以把静态的模块列出来
-l

查看配置文件有没有错误
-t

重新加载用
graceful

Apache的工作模式
prefork worker event
prefork相当与子进程 主进程可以ps看一下
主进程下面派生了很多的子进程

worker
他有主进程也有子进程
每一个子进程下面还有线程 线程跟进程他们两者最主要的区别在于
线程是进程下面的派生出来的一些更小单位的一种方式 在线程下 我们一个进程的内存会共享给所有的线程去使用 这也就意味着进程下面的某一个线程 出现了故障 导致崩溃 那么这个进程线面的所有线程都会收到牵连 好处是他们可以共享一段内存 在高并发情况下http访问量特别特别打的时候 worker 这种线程的形式很占优势 占用很少的内存
但是prefork他是进程的形式 子进程 每一个子进程占有一个单用的内存 其中某个进程发生了故障 不会影响其他进程 但是在高并发的情况下占用的内存很明显要比worker形式大很多

event 是worker的升级版
也是线程的形式 它在性能上 比如长连接的时候event 会比worker好一些

编译的时候
--with-mpm=worker
2.2默认是prefork
2.4默认是event

php
下载安装
cd /usr/local/src

解压
tar zxvf php-5.3.27.tar.gz cd php-5.3.27

编译
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

make && make install

帮助我们自动安装扩展模块 安装动态模块的时候要用到
--with-apxs2=/usr/local/apache2/bin/apxs

查看模块 -m

查看相关的配置 -i

复制配置文件
cp php.ini-production /usr/local/php/etc/php.ini

AddType application/x-httpd-php .php

<Directory />
Options FollowSymLinks
deny form all改成
Allow from all

DirectoryIndex index.html index.htm index.php

ServerName localhost:80
启动Apache服务
/usr/local/apache2/bin/apachectl start

安装Discuz
mkdir /data/www
cd /data/www
unzip Discuz_X3.2_SC_GBK.zip
mv upload/* .

#Include conf/extra/httpd-vhosts.conf
vim /usr/local/apache2/conf/extra/httpd-vhosts.conf

<VirtualHost *:80>
DocumentRoot "/data/www"
ServerName www.test.com
#ServerAlias www.dummy-host.example.com
#ErrorLog "logs/dummy-host.example.com-error_log"
# CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>

/usr/local/apache2/bin/apachectl -t

/usr/local/apache2/bin/apachectl restart

/usr/local/mysql/bin/mysql -uroot
create database discuz;
grant all on discuz.* to 'aaa'@'localhost' identified by '123456';

cd /data/www
chown -R daemon:daemon data uc_server/data uc_client/data config
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux mysql local