安装mysql
1: 安装好cmake+
ncurses+
2:更新必要的库 yum install –y openssl openssl-devel ncurses ncurses-devel gcc gcc-c++
3:添加mysql用户及组
groupadd mysql
useradd -g mysql mysql
4:cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql
5:make && make install
6:权限设置:
更改权限,将程序的二进制的所有权改为root用户,数据目录的所有权改为允许mysqld程序的mysql用户。
cd /usr/local/mysql
chown -R root . //将文件的所有属性改为root用户
chown -R mysql /data/mysql //将数据目录的所有属性改为mysql用户,老版本的是var目录
chgrp -R mysql . //将组属性改为mysql组
修改my.cnf的mysqld的datadir到/data/mysql
scripts/mysql_install_db --usr=mysql
启动mysql服务
/usr/local/mysql/bin/mysqld_safe --user=mysql
ps -le | grep mysqld //查看mysql进程是否启动
netstat -tnl|grep 3306 //查看3306是否开启,listen状态说明mysql服务启动成功
使用mysqladmin验证服务器在运行中。
cd /usr/local/mysql
bin/mysqladmin version //查看运行的mysql版本
bin/mysqladmin variables //查看所有mysql参数
设置访问权限
cd /usr/local/mysql
bin/mysql -u root //启动mysql客户端控制台,连接mysql服务器
SET PASSWORD FOR 'root'@'localhost'=PASSWORD('123456');
设置mysql数据库为开机自动启动
cd /usr/local/src/mysql-5.5.27 //进入mysql安装包
cp support-files/mysql.server /etc/rc.d/init.d/mysqld //复制文件
chown root.root /etc/rc.d/init.d/mysqld //修改权限
chmod 755 /etc/rc.d/init.d/mysqld
使用chkconfig 命令设置在不同系统运行级别下的自启动策略
chkconfig --add mysqld //添加mysqld服务,让chkconfig指令得以管理它
chkconfig --level 3 mysql on //在字符模式启动时自动开启mysqld服务
chkconfig --level 5 mysql on //在图形模式启动时自动开启mysqld服务
[root@ht mysql]# vim /etc/profile.d/mysql.sh
添加exportPATH=$PATH:/usr/local/mysql/bin
[root@ht mysql]# source /etc/profile #重新读取环境变量
iptable 修改3306 为本地可访问
编译http :编译apr,apr-util,pcre库
./configure --prefix=/usr/local/apache --enable-mods-shared=all --enable-proxy--enable-proxy-connect --enable-proxy-ftp --enable-proxy-http --enable-proxy-ajp --enable-proxy-balancer --enable-rewrite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --with-mpm=prefork --enable-ssl --with-ssl=/usr/local/ssl --enable-so
[root@ht /]# make
[root@ht /]# make install
[root@ht /]# groupadd www
[root@ht /]# useradd -g www www
[root@ht /]#
vi /usr/local/apache/conf/httpd.conf #编辑配置文件
[root@ht /]#
/usr/local/apache/bin/apachectl -k start #启动
[root@ht /]#
vi /etc/profile #修改apapche的启动
#添加
export PATH=$PATH:/usr/local/apache/bin
[root@ht /]#
cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd #添加apache到service
[root@ht /]# source /etc/profile #重新读取环境变量
[root@ht /]#
#iptable 修改80 开放
[root@ht /]# chown www.www -R /var/www/html
[root@ht /]#
chmod 700 -R /var/www/html
[root@ht /]#
vi /etc/rc.d/init.d/httpd #添加下面两行,在
(#!/bin/sh下面)
#chkconfig: 2345 10 90
#description: Activates/Deactivates Apache Web Server
#其中:2345是设为要启动的运行级别,10是启动优先级,90是杀死进程的优先级,谁优先谁先挂的意思。
[root@ht /]#
chkconfig --add httpd //添加httpd到服务项
[root@ht /]#
chkconfig httpd on //设置开机启动
httpd.conf
查找 Options Indexes FollowSymLinks,修改为 Options -Indexes。
禁止列出目录文件
编译PHP,添加memcache,redis,mhash,libz,支持
【安装必须的库】
yum -y install gcc gcc-c++ make automake autoconf kernel-devel ncurses-devel libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel pcre-devel libtool-libs freetype-devel gd zlib-devel file bison patch mlocate flex diffutils readline-devel glibc-devel glib2-devel bzip2-devel gettext-devel libcap-devel libmcrypt-devel
下载并解压下面的代码
tar xzf libmcrypt-2.5.8.tar.gz
tar xzf mhash-0.9.9.9.tar.gz
tar xzf mcrypt-2.6.8.tar.gz
[root@ht php-source]#./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-zlib-dir --with-bz2 --with-zlib --with-gd --enable-gd-native-ttf --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-openssl --with-mhash --enable-sockets --with-xmlrpc --enable-zip
#添加mysql支持
[root@ht php-source]#ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
[root@ht php-source]#
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
[root@ht php-source]#make
[root@ht php-source]#make install
编译安装memcache 和redis 客户端
# cd memcache-3.0.8
# /usr/local/php/bin/phpize
# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir
# make
# make install
#cd APC-3.1.9
# /usr/local/php/bin/phpize
#./configure -enable-api -enable-apc-mmap -with-php-config=/usr/local/php/bin/php-config
# make
# make install
#cd phpredis
# /usr/local/php/bin/phpize
#./configure –with-php-config=/usr/local/php/bin/php-config
# make
# make install
php.ini添加
extension= /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/apc.so
extension= /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/redis.so
extension= /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/memcache.so
[apc]
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 128
apc.optimization = 1
apc.num_files_hint = 0
apc.ttl = 0
apc.gc_ttl = 3600
apc.cache_by_default = on