内容简介:CentOS6.4搭配LAMP环境
首先最好一直在root用户下进行安装。
一、安装Mysql
1.安装编译环境
yum -y install gcc gcc-c++ make cmake ncurses-devel bison
*出现错误:
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=i386&repo=os error was
14: PYCURL ERROR 6 – "Couldn't resolve host 'mirrorlist.centos.org'"
Error: Cannot find a valid baseurl for repo: base
*解决方法:
vim /etc/resolv.conf把文件改成:
nameserver 8.8.8.8
nameserver 8.8.4.4
2.下载源码包
wget http://sourceforge.net/projects/Mysql.mirror/files/Mysql 5.6.19/Mysql-5.6.19.tar.gz(url中有空格,请复制此url后在浏览器访问,这样空格会被转意,wget才能正常连接)
3.解压
tar -zxvfMysql-5.6.19.tar.gz
4.进入目录
cdMysql-5.6.19
5.添加用户
useradd -s /sbin/nologinMysql
6. 编译配置
cmake -DMysql_USER=Mysql -DCMAKE_INSTALL_PREFIX=/usr/local/Mysql -DINSTALL_DATADIR=/data/Mysql/data -DMysql_UNIX_ADDR=/tmp/Mysqld.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_CI -DEXTRA_CHARSETS=all -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1
7. 编译安装
make && make install
8.复制my-default.cnf文件到etc目录下
cp /usr/local/Mysql/support-files/my-default.cnf /etc/
9.复制/support-files/Mysql.server到/etc/init.d下,重命名为Mysqld
cp /usr/local/Mysql/support-files/Mysql.server /etc/init.d
cd /etc/init.d
mvMysql.serverMysqld
10.创建data目录
mkdir -p /data/Mysql/data
11. 关闭防火墙
chkconfig iptables off
vim /etc/seLinux/config
将/etc/seLinux/config 中的 SELinux=enforCIng 改成SELinux=disabled
12.在/etc/my.cnf中添加/编辑
打开my.cnf:
vim /etc/my.cnf
修改如下:
[client]
socket=/tmp/Mysql.sock
[ Mysql d]
basedir=/usr/local/Mysql
datadir=/data/Mysql/data
socket=/tmp/Mysql.sock
13. 加入自启动
chkconfig –level 345Mysqld on
14.改变 Mysql 目录用户组和权限
cd /usr/local
chmod 775 -RMysql
15.改变data目录用户组和权限
cd /data/Mysql/
chmod 775 -R data
chown -RMysql.Mysql data
16.初始化数据
/usr/local/Mysql/scripts/Mysql_install_db –user=Mysql –defaults-file=/etc/my.cnf –basedir=/usr/local/Mysql –datadir=/data/Mysql/data
17.添加Mysql环境变量
vim /etc/profile
PATH_LIST=(
'/usr/local/Mysql/bin'
);
for _path in ${PATH_LIST[@]};do
PATH="$PATH:$_path"
done
export PATH
18.重启
init 6
19.启动Mysql
serviceMysqld start
20. 初始化账户
/usr/local/Mysql/bin/Mysqladmin -u root password 'a123456'
21. 连接数据库
/usr/local/Mysql/bin/Mysql -u root -pa123456
二、安装Apache
1. 安装编译环境
yum -y install gcc gcc-c++ autoconf automake makelibjpeg libjpeg-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-develglib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devele2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel opensslopenssl-devel openldap openldapdevel nss_ldap openldap-clients openldap-serverslibtool*Mysql-devel
2. 下载源码
wget http://sourceforge.net/projects/apachehttp.mirror/files/httpd-2.2.22.tar.gz
3. 解压并进入目录
tar -zxvf httpd-2.2.22.tar.gz
cd httpd-2.2.22
4. 编译配置
./configure –prefix=/usr/local/apache –enable-so –enable-proxy –enable-rewrite –with-mpm=worker
5. 编译安装
make && make install
6. vim /usr/local/apache/conf/httpd.conf
搜索"#ServerName",在下面添加"ServerName localhost:80"
7. 启动Apache
/usr/local/apache/bin/apachectl start
三、安装PHP
1. 安装zlib
wget http://sourceforge.net/projects/libpng/files/zlib/1.2.8/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure –prefix=/usr/local/zlib
make && make install
2. 安装libpng
wget http://download.sourceforge.net/libpng/libpng-1.6.2.tar.gz
tar -zxvf libpng-1.6.2.tar.gz
cd libpng-1.6.2
./configure –prefix=/usr/local/libpng
make && make install
建立头文件软链
ln -s /usr/local/libpng/include/pngconf.h /usr/include
ln -s /usr/local/libpng/include/png.h /usr/include
将/usr/local/libpng/bin配置到环境变量
vim /etc/profile:
在这里面添加引号那行
PATH_LIST=(
'/usr/local/libpng/bin'
);
重启
3. 安装libjpeg
wget http://www.ijg.org/files/jpegsrc.v9.tar.gz
tar -zxvf jpegsrc.v9.tar.gz
cd jpeg-9
./configure –prefix=/usr/local/jpeg –enable-shared
make && make install
4. 安装freetype
wget http://sourceforge.net/projects/freetype/files/freetype2/2.5.0/freetype-2.5.0.tar.gz
tar -zxvf freetype-2.5.0.tar.gz
cd freetype-2.5.0
./configure –prefix=/usr/local/freetype
make && make install
5. 安装gd2
wget https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz
tar -zxvf libgd-2.1.0.tar.gz
cd libgd-2.1.0
./configure –with-freetype=/usr/local/freetype –with-zlib=/usr/local/zlib –with-png=/usr/local/libpng –with-jpeg=/usr/local/jpeg –prefix=/usr/local/gd2
make && make install
6. 安装XPM
yum -y install *Xpm*
7. 安装libcurl-devel
yum -y install curl curl-devel
8. 安装 PHP 5.5.13
wget http://cn2.PHP.net/get/PHP-5.5.13.tar.gz/from/this/mirror
tar -zxvf /PHP-5.5.13.tar.gz
cdPHP-5.5.13
./configure –prefix=/usr/local/PHP –with-config-file-path=/usr/local/PHP/etc/ –with-gd=/usr/local/gd2 –with-apxs2=/usr/local/apache/bin/apxs –enable-mbregex –enable-bcmath –with-Mysql –with-zlib-dir=/usr/local/zlib –enable-mbstring=all –with-pdo-Mysql –with-freetype-dir=/usr/local/freetype –with-jpeg-dir=/usr/local/jpeg –with-png-dir=/usr/local/libpng –with-xpm-dir=/usr/lib –with-openssl –with-curl –enable-pcntl
make && make install
9. 复制配置文件
cpPHP.ini-development /usr/local/PHP/etc/PHP.ini
10. vim /usr/local/PHP/etc/PHP.ini在这里进行你需要的配置修改
11. 将/usr/local/PHP/bin配置到环境变量
vim /etc/profile:
在这里面添加引号那行
PATH_LIST=(
'/usr/local/PHP/bin'
);
12. vim /usr/local/apache/conf/httpd.conf
找到AddType application/x-gzip .gz .tgz,在下面添加
AddType application/x-httpd-PHP .PHP .pHTML .inc .PHP3
重启Apache
/usr/local/apache/bin/apachectl restart
四、安装memcached
1、安装libevent
wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz
tar -zxvf libevent-2.0.20-stable.tar.gz
cd libevent-2.0.20-stable
./configure -prefix=/usr/local/libevent
make && make install
2、安装memcached
wget http://www.memcached.org/files/memcached-1.4.20.tar.gz
tar -zxvf memcached-1.4.20.tar.gz
cd memcached-1.4.20
./configure -prefix=/usr/local/memcached –with-libevent=/usr/local/libevent
make && make install
添加环境标量 /usr/local/memcached/bin 到 /etc/profile
3、启动 memcached 守护进程
memcached -d -m 64 -u root -l 127.0.0.1 -p 12000 -c 128 -P /tmp/memcached.pid
4、查看memcached状态
telnet $host $port(如果系统中找不到telnet请看附录1)
stats
5、安装libmemcached
wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz
tar -zxvf libmemcached-1.0.16.tar.gz
cd libmemcached-1.0.16
./configure –prefix=/usr/local/libmemcached
make && make install
注:1.0.17无法完成扩展编译,应使用1.0.16版本
6、安装memcahcedPHP扩展
wget http://pecl.PHP.net/get/memcached-2.2.0.tgz
tar -zxvf memcached-2.2.0.tgz
cd memcached-2.2.0
PHPize
./configure –with-PHP-config=/usr/local/PHP/bin/PHP-config –with-libmemcached-dir=/usr/local/libmemcached –disable-memcached-sasl
make && make test && make install
vim /usr/local/PHP/etc/PHP.ini
extension_dir = “./” 修改为:extension_dir = “/usr/local/PHP/lib/PHP/extensions/no-debug-non-zts-xxxxx/”
增加extension=memcached.so
五、安装Redis
1. 安装Redis
wget http://download.Redis.io/releases/Redis-2.8.10.tar.gz
tar -zxvfRedis-2.8.10.tar.gz && cdRedis-2.8.10
make & make install
2. 将配置文件复制到/etc/目录下
cpRedis.conf /etc/
3. 修改 Redis 后台运行配置
vim /etc/Redis.conf
将daemonize no修改为daemonize yes
4. 启动Redis
/usr/local/bin/Redis-server /etc/Redis.conf
执行ps -ef | grepRedis|grep -v grep
显示类似下面的信息则说明启动成功
root 27243 1 0 16:46 ? 00:00:00 /usr/local/bin/Redis-server /etc/Redis.conf
5. 安装PHP Redis 扩展
wget https://github.com/nicolasff/PHPRedis/archive/master.zip
unzip master && cdPHPRedis-master
/usr/local/PHP/bin/PHPize
./configure –with-PHP-config=/usr/local/PHP/bin/PHP-config
make && make install
6. 添加Redis.so至PHP.ini
vim /usr/local/PHP/etc/PHP.ini
添加:
extension=Redis.so
7. 重启apache 查看PHPinfo()中的Redis模块
附录1:
telnet: command not found:
最近在使用telnet命令时,telnet: command not found,使用rpm -qa | grep telnet 查看,原来是没有安装telnet ,使用yum install telnet-server安装,却报This system is not registered with RHN.错误,原因是因为红帽中没有注册RHN。解决办法:更改yum的源,即更换/etc/yum.repos.d /rhel-debuginfo.repo 这个文件。进入/etc/yum.repos.d/目录,终端中输入wget http://docs.Linuxtone.org/soft/lemp/CentOS-Base.repo即可在此目录下得到CentOS- Base.repo文件,这是centos的源文件,只需将其重命名为rhel-debuginfo.repo即可。yum install telnet-server telnet,安装完成后,编辑 # vim /etc/xinetd.d/telnet
找到 disable = yes 一行,将其改为: disable = no。重启服务:service xinetd restart。telnet使用成功。
以上所述就是小编给大家介绍的《CentOS6.4搭配LAMP环境》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- Hyperledger Fabric环境搭建及环境测试(Mac环境)
- CV 环境很重要,各种环境搭建大全
- Openstack Queens 环境搭建(一)环境准备
- 分离Webpack开发环境与生产环境的配置
- Xcode配置测试环境和线上环境
- 重构之路:webpack区分生产环境和开发环境
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Linux内核设计与实现
拉芙 / 陈莉君、唐华、张波 / 机械工业出版社 / 2006-1 / 38.00元
《Linux内核设计与实现》基于Linux2.6内核系列详细介绍Linux内核系统,覆盖了从核心内核系统的应用到内核设计与实现等各方面的内容。主要内容包括:进程管理、系统调用、中断和中断处理程序、内核同步、时间管理、内存管理、地址空间、调试技术等。本书理论联系实践,既介绍理论也讨论具体应用,能够带领读者快速走进Linux内核世界,真正开发内核代码。 本书适合作为高等院校操作系统课程的教材......一起来看看 《Linux内核设计与实现》 这本书的介绍吧!