安裝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 httpd on
//設置開機啓動
查找 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