apache安装
1、yum-y install gcc-c++ expat-devel zlib pcre-devel zlib-developenssl-devel
2、安装apr
wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.5.tar.gz
tar -zxvf apr-1.6.5.tar.gz
cd apr-1.6.5
./configure--prefix=/usr/local/apr-1.6.5
make && make install
3、安装apr-util
wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
cd ../
tar -zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util-1.6.1--with-apr=/usr/local/apr-1.6.5
make && make install
3、安装pcre
wget https://ftp.pcre.org/pub/pcre/pcre-8.00.tar.gz
cd ../
tar -zxvf pcre-8.0.0.tar.gz
cd pcre-8.0.0
./configure --prefix=/usr/local/pcre
make && make install
4、安装httpd
tar xf httpd-2.4.27.tar.gz
cd httpd-2.4.27
./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr-1.6.5\ --with-apr-util=/usr/local/apr-util-1.6.1 --with-pcre=/usr/local/pcre \
--enable-so --enable-deflate --enable-expires--enable-headers \
--enable-ssl --enable-rewrite --enable-mpms-shared=all \
--with-mpm=prefork --enable-mods-shared=most
make && make install
5、设置apache开机自动启动
首先拷贝apachectl到目录/etc/init.d/,执行命令sudo cp apachectl /etc/init.d/httpd
vim /etc/init.d/httpd 脚本首行添加以下两行
# chkconfig: 2345 71 71
# description: Apache2.4 is a world wide web server
注意:2345 是指改服务可以随系统的2345启动级别启动和停止,71 71 两个数字分别指启动顺序和停止顺序。
6、将httpd添加为开机启动
chkconfig --add httpd
这行命令的意思是在/etc/rc.d/rc*/ 添加/etc/init.d/httpd这个文件
chkconfig --list |grep httpd 查看是否将httpd添加为系统服务
chkconfig httpd on 开启开机启动httpd服务
mysql安装
1、tar xf mysql-5.6.40.tar.gz
2、cd mysql-5.6.40
3、yum -y install ncurses-devel perl perl-devel
4、cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system-DWITH_ZLIB=system -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock-DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all-DDEFAULT_CHARSET=utf8 -DWITH_LIBWRAP=0 -DDEFAULT_COLLATION=utf8_general_ci
5、cmake编译报错需要删除编译缓存,修复错误后再次重新编译
rm -f CMakeCache.txt
6、make && make install
注意事项:
重新编译时,需要清除旧的对象文件和缓存信息。
# make clean
# rm -f CMakeCache.txt
# rm -rf /etc/my.cnf
7、改变数据存储目录所有者为mysql
groupadd mysql
useradd -r -g mysql mysql
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql/usr/local/mysql/data
8、启动脚本初始化数据库
cd /usr/local/mysql
# scripts/mysql_install_db--user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
9、注册服务
cp support-files/mysql.server/etc/rc.d/init.d/mysqld
#使用默认配置文件
cp support-files/my-default.cnf/etc/my.cnf
#让chkconfig管理mysql服务
chkconfig --add mysqld
#开机启动
chkconfig mysqld on
10、编辑/etc/my.cnf配置,加入以下内容
innodb_file_per_table = 1
datadir = /usr/local/mysql/data
log-bin=/usr/local/mysql/data/binlogs/mysql-bin
注意:
经过实际测试innodb_file_per_table= ON这条参数需要innodb_file_per_table = 1 才能生效,具体可以通过
mysql> show variables like'%per_table%';来查询
mkdir /usr/local/mysql/data/binlogs/
chown -R mysql.mysql/usr/local/mysql/data/binlogs/
11.将mysql命令加入环境变量中
vim /etc/profile
exportPATH=/usr/local/mysql/bin:$PATH
使其生效
source /etc/profile
默认密码为空
更改密码
格式:mysqladmin -u用户名 -p旧密码 password 新密码
例子:mysqladmin -uroot-p123456 password 123
mysql grant 语法详解 MySQL 赋予用户权限命令的简单格式可概括为:
grant[select|insert|update|delete|create|alter|drop|references|index|all](slave|replication) on [database.table] to 'user'@'%' identified by 'password'
flush privileges;
php安装
1、安装libxml2
http://ftp.osuosl.org/pub/blfs/conglomeration/libxml2/下载最新的libxml2源码包
tar zxvf libxml2-2.7.2.tar.gz
cd libxml2-2.7.2.
./configure --prefix=/usr/local/libxml2 --without-zlib
make && make install
2、安装jpeg
http://www.ijg.org/files/ 下载最新的jpeg源码包
yum -y install libtool libtool-ltdl-devel
mkdir -p /usr/local/jpeg/bin
mkdir /usr/local/jpeg/lib
mkdir /usr/local/jpeg/include
mkdir /usr/local/jpeg/man
mkdir /usr/local/jpeg/man/man1
tar -zxvf jpegsrc.v6b.tar.gz
cd jpeg
cp /usr/share/libtool/config/config.sub .
cp /usr/share/libtool/config/config.guess .
./configure --prefix=/usr/local/jpeg --enable-shared--enable-static
make && make install
3、安装zlib
ftp://ftp.simplesystems.org/pub/png/src/zlib 下载最新的 zlib 源码包
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure && make && make install
4、安装libpng
ftp://ftp.simplesystems.org/pub/png/src/ 下载最新的libpng源码包
tar zxvf libpng-1.2.31.tar.gz
cd libpng-1.2.31
./configure #和zlib一样不要带参数,让它默认安装到相应目录
make && make install
5、安装freetype(字体库)
http://download-mirror.savannah.gnu.org/releases/freetype/下载最新的freetype源码包
wget http://download-mirror.savannah.gnu.org/releases/freetype/freetype-2.9.1.tar.gz
tar zxvf freetype-2.9.1.tar.gz
cd freetype-2.9.1
./configure --prefix=/usr/local/freetype --without-png
make && make install
6、安装php
yum -y install ssl curl curl-devel freetype-devellibXpm-devel
tar -zxvf php-5.6.36.tar.gz
cd php-5.6.36
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-apxs2=/usr/local/httpd/bin/apxs \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-freetype-dir=/usr/local/freetype \
--with-gd \
--with-curl \
--with-zip \
--with-zlib --with-libxml-dir=/usr/local/libxml2 \
--with-jpeg-dir=/usr/local/jpeg \
--with-png-dir \
--enable-mbstring=all \
--enable-mbregex \
--enable-shared \
--with-openssl \
--enable-soap \
--enable-fpm \
--enable-sockets \
--with-xpm-dir=/usr/lib64
make && make install
7、更改apache的配置文件,解析php文件
编辑配置文件/etc/httpd/httpd.conf,在LoadModule最后面添加以下内容
LoadModule php5_module modules/libphp5.so
##通常正确编译安装PHP后会自动增加,如果没有,需要手工添加。
接下来要检查apache目录下生成的php动态连接库文件,在目录/usr/local/apache/modules,找到是否存在libphp5.so文件。若不存在呢?则说明php安装不正确。
[root@centos6 ~]#vim /etc/httpd/httpd.conf
在/etc/httpd/conf/httpd.conf文件中添加如下内容:
AddType application/x-compress.Z
AddType application/x-gzip .gz .tgz
Addtype application/x-httpd-php .php .phtml
Addtype application/x-httpd-php-source .phps
将下面一行:
DirectoryIndex index.html修改为
DirectoryIndex index.php index.html index.htm
配置结束后重启Apache
[root@centos6 ~]#service httpd restart
观注快乐程序员公众号,每日分享一点小知识。爱编程,爱生活!