yum apache mysql php 配置_linux centos下 通过 yum 配置 apache,php,mysql

linux centos下 通过 yum 配置 apache,php,mysql

通过yum安装可以很快完成服务器配置。

那么如何快速配置,并能够安装最稳定的版本同样重要。

wget -q -O - http://www.atomicorp.com/installers/atomic | sh

cd /etc/yum.repos.d/

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

rm  /etc/yum.repos.d/CentOS-Ku6.repo -rf

yum makecache

yum install update

yum install lrzsz

yum install -y httpd php php-common php-devel php-gd php-mcrypt php-mbstring php-pear php-bcmath php-mhash php-mysql php-xml gcc

如果提示错误:GPG key retrieval failed: [Errno 14] Could not open/read file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

删除:rm /etc/yum.repos.d/epel.repo -rf

service httpd start

chkconfig httpd on

通过命令行操作mysql

yum install mysql-devel

默认的httpd.conf

StartServers       8

MinSpareServers    5

MaxSpareServers   20

ServerLimit      256

MaxClients       256

MaxRequestsPerChild  4000

修改后:

StartServers       8

MinSpareServers    5

MaxSpareServers   20

ServerLimit      10000

MaxClients       10000

MaxRequestsPerChild  4000

安装memcached 服务器所需的扩展库

网站地址:http://libevent.org/

下载最新版:wget https://github.com/downloads/lib ... .0.21-stable.tar.gz

tar zxvf libevent-2.0.21-stable.tar.gz

cd libevent-2.0.21-stable

./configure --prefix=/usr

make

make install

测试libevent是否安装成功:

# ls -al /usr/lib | grep libevent

安装:memcached

官网:http://memcached.org/

wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz

tar zxvf memcached-1.4.15.tar.gz

cd memcached-1.4.15

./configure --with-libevent=/usr

make

make install

测试是否成功安装memcached:

# ls -al /usr/local/bin/mem*

memcached的基本设置:

1.启动Memcache的服务器端:

/usr/local/bin/memcached -d -m 100 -u root -l 127.0.0.1 -p 11211 -c 1024 -P /tmp/memcached1.pid

/usr/local/bin/memcached -d -m 5000 -u root -l 127.0.0.1 -p 11212 -c 1024 -P /tmp/memcached2.pid

/usr/local/bin/memcached -d -m 300 -u root -l 127.0.0.1 -p 11213 -c 1024 -P /tmp/memcached3.pid

/usr/local/bin/memcached -d -m 1000 -u root -l 127.0.0.1 -p 11214 -c 1024 -P /tmp/memcached4.pid

-d选项是启动一个守护进程,

-m是分配给Memcache使用的内存数量,单位是MB,这里是10MB,

-u是运行Memcache的用户,这里是root,

-l是监听的服务器IP地址,如果有多个地址的话,这里指定了服务器的IP地址192.168.0.200,

-p是设置Memcache监听的端口,这里设置了12000,最好是1024以上的端口,

-c选项是最大运行的并发连接数,默认是1024,这里设置了256,按照你服务器的负载量来设定,

-P是设置保存Memcache的pid文件,这里是保存在 /tmp/memcached.pid,

最后:放置memcache 服务器进程到自启动中

vi /etc/rc.d/rc.local

增加上面命令即可

2.如果要结束Memcache进程,执行:

kill `cat /tmp/memcached1.pid`

kill `cat /tmp/memcached2.pid`

kill `cat /tmp/memcached3.pid`

kill `cat /tmp/memcached4.pid`

如法结束进程时,通过

ps aux|grep memcached 查找进程

kill 进程id

也可以启动多个守护进程,不过端口不能重复。

echo "flush_all" | nc 127.0.0.1 11212  清空所有缓存数据

echo stats | nc 127.0.0.1 11211        查看memcached运行状态

简单方法安装:yum install php-pecl-memcache

手动安装:

安装php memcache 扩展库:

官网:http://pecl.php.net/package/memcache

wget http://pecl.php.net/get/memcache-3.0.8.tgz

tar zxvf memcache-3.0.8.tgz

cd memcache-3.0.8

通过:whereis php 找到phpize是在/usr/bin/php目录安装

返回上级目录,可以找到 /usr/bin/phpize

[root@ptr65 memcache-3.0.8]# /usr/bin/phpize

然后编译安装

./configure --with-php-config=/usr/bin/php-config

make

正常显示结果中包含:

Libraries have been installed in:

/data/soft/memcache-3.0.8/modules

错误:

checking for re2c... no

configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.

checking for gawk... gawk

checking whether to enable memcache support... yes, shared

checking whether to enable memcache session handler support... yes

checking for the location of ZLIB... no

checking for the location of zlib... configure: error: memcache support requires ZLIB. Use --with-zlib-dir=

执行:yum install zlib zlib-devel zlib-static

make install

Installing shared extensions:     /usr/lib64/php/modules/

[root@ptr65 modules]# whereis php

php: /usr/bin/php /etc/php.d /etc/php.ini /usr/lib64/php /usr/include/php /usr/share/php /usr/share/man/man1/php.1.gz

找到:/usr/lib64/php

进入:/usr/lib64/php/modules 可以看到已经安装好的模块。

mv /data/soft/memcache-3.0.8/modules/memcache.so /usr/lib64/php/modules

cd /etc/php.d

vi memcache.ini

; Enable memcache extension module

extension=memcache.so

service httpd restart

上传/data/soft/memcache-3.0.8/下面的 memcache.php 和 example.php 即可测试

配置:httpd.conf

mkdir /data/wwwroot/www.wuzhicms.com/www -p

mkdir /data/logs/ -p

vi /etc/httpd/conf/httpd.conf

ServerAdmin root@ku6.com

DocumentRoot /data/wwwroot/www.wuzhicms.com/www

ServerName www.wuzhicms.com

Options  FollowSymLinks

AllowOverride Options FileInfo

Order allow,deny

Allow from all

php_admin_value open_basedir /data/wwwroot/www.wuzhicms.com/:/var/tmp/

DirectoryIndex index.html index.php index.htm

ErrorLog "| /usr/sbin/rotatelogs /data/logs/%m_%d_www.wuzhicms.com-error_log 86400 480"

CustomLog "| /usr/sbin/rotatelogs /data/logs/%m_%d_www.wuzhicms.com-access_log 86400 480" common

apache  配置虚拟主机后,出现禁止访问的情况。

查看是否开启了 SELinux

检查SElinux是否在用

# getenforce

yum install -y mysql-server gcc

mkdir /data/mysqldata -p

上传 my.cnf

启动mysql

service mysqld start

设置初始密码

/usr/bin/mysqladmin -u root password 'sfsdsdfsdsf'

mysql服务开机启动

chkconfig --add mysqld

chkconfig mysqld on

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值