linux 编译安装apache+mysql+php
yum -y install expat-devel gcc-c++ pcre-devel libxml2-devel zlib-devel openssl-devel
openssl升级安装:
[root@cloud ~]# wget -c https://www.openssl.org/source/openssl-1.0.2o.tar.gz
[root@cloud ~]#tar -zxf openssl-1.0.2o.tar.gz
[root@cloud ~]#cd openssl-1.0.2o.tar.gz
[root@cloud ~]#./config -fPIC --prefix=/usr/local/openssl-1.0.2/ enable-shared --- 添加-fPIC 否则编译apache报错
[root@cloud ~]#make
[root@cloud ~]#make install
[root@cloud ~]#mv /usr/bin/openssl /usr/bin/openssl.old
[root@cloud ~]#mv /usr/include/openssl/ /usr/include/openssl.old
[root@cloud ~]#ln -s /usr/local/openssl-1.0.2/bin/openssl /usr/bin/openssl
[root@cloud ~]#ln -s /usr/local/openssl-1.0.2/include/openssl /usr/include/openssl
echo "/usr/local/openssl-1.0.2/lib/" >> /etc/ld.so.conf
#ldconfig -v |grep openssl
# openssl version
# openssl version -a
添加.so文件到环境变量,否则apache2启动报错:
#vi .bash_profile
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/openssl-1.0.2/lib/
安装apr包
注意: APR 1.6.2版本有变更,进行了加密设置,进行编译时需要使用如下命令(否则在安装Apache是无法调用该库文件):
[root@dl-001 httpd-2.4.29]# CC="gcc -m64" ./configure --prefix=/usr/local/apr
cd apr-1.5.1
./configure --prefix=/usr/local/apr
make && make install
安装Apr-util包
[root@dl-001 src]# cd apr-util-1.6.1
[root@dl-001 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@dl-001 apr-util-1.6.1]# echo $?
0
编译和安装:
[root@dl-001 apr-util-1.6.1]# make && make install
pcre-8.36.tar.bz2
cd pcre-8.36
./configure
make && make install
安装Apache
# 同样要清理之前的缓存十分重要
[root@dl-001 src]# cd /usr/local/src/httpd-2.4.28
[root@dl-001 httpd-2.4.29]# make clean
[root@dl-001 httpd-2.4.29]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-ssl --with-ssl=/usr/local/openssl-1.0.2 --enable-so --enable-rewrite --enable-mods-shared=most
[root@dl-001 httpd-2.4.29]# make
# 这时make没报错了
[root@dl-001 httpd-2.4.29]# make install
[root@dl-001 httpd-2.4.29]#cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd2
查看Apache所加载的模块:
[root@dl-001 apache2.4]# /usr/local/apache2.4/bin/httpd -M
或者
[root@dl-001 apache2.4]# /usr/local/apache2.4/bin/apachectl -M
启动:
[root@dl-001 apache2.4]# /usr/local/apache2.4/bin/apachectl start
******************************************
linux下面安装Mysql5.6.21
安装Mysql,需要先安装好 cmake
yum -y install cmake make
一、编安装MySQL前的准备工作
安装编译源码所需的工具和库
yum install gcc gcc-c++ ncurses-devel perl
安装cmake,从http://www.cmake.org下载源码并编译安装
2. tar -xzvf cmake-2.8.10.2.tar.gz
3. cd cmake-2.8.10.2
4. ./bootstrap ; make ; make install
5. cd ~
二、设置MySQL用户和组
新增mysql用户组
groupadd mysql
新增mysql用户
useradd -r -g mysql mysql
三、新建MySQL所需要的目录
新建mysql安装目录
mkdir -p /usr/local/mysql
新建mysql数据库数据文件目录
mkdir -p /data/mysqldb
四、下载MySQL源码包并解压
解压mysql-5.6.16.tar.gz
tar -zxv -f mysql-5.6.16.tar.gz
cd mysql-5.6.16
配置
rm CMakeCache.txt
编译源码
make
安装
make install
六、修改mysql目录所有者和组
修改mysql安装目录
1
2
1. cd /usr/local/mysql
2. chown -R mysql:mysql .
修改mysql数据库文件目录
1
2
3
cd /data/mysqldb
chown -R mysql:mysql .
七、初始化mysql数据库
1
2
1. cd /usr/local/mysql
2. scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb
八、复制mysql服务启动配置文件
1
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
注:如果/etc/my.cnf文件存在,则覆盖。
九、复制mysql服务启动脚本及加入PATH路径
1
2
3
4
5
6
1. cp support-files/mysql.server /etc/init.d/mysqld
2.
3. vim /etc/profile
4. export MYSQL_HOME="/usr/local/mysql"
export PATH="$PATH:$MYSQL_HOME/bin"
5. source /etc/profile
十、启动mysql服务并加入开机自启动(可选这个步骤,以后可以自己启动的)
1
2
service mysqld start
chkconfig --level 35 mysqld on
十一、检查mysql服务是否启动
1
2
1. netstat -tulnp | grep 3306
2. mysql -u root -p
密码为空,如果能登陆上,则安装成功。
十二、修改MySQL用户root的密码
1
1. mysqladmin -u root password '123456'
注:也可运行安全设置脚本,修改MySQL用户root的密码,同时可禁止root远程连接,移除test数据库和匿名用户。
1
1. /usr/local/mysql/bin/mysql_secure_installation
十三、可能会出现的错误
4
1. 问题:
2. Starting MySQL..The server quit without updating PID file ([FAILED]/mysql/Server03.mylinux.com.pid).
3. 解决:
4. 修改/etc/my.cnf 中datadir,指向正确的mysql数据库文件目录
2. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
3. 解决:
4. 新建一个链接或在mysql中加入-S参数,直接指出mysql.sock位置。
5. ln -s /usr/local/mysql/data/mysql.sock /tmp/mysql.sock
6.
7. /usr/local/mysql/bin/mysql -u root -S /usr/local/mysql/data/mysql.sock
1. MySQL问题解决:-bash:mysql:command not found
2. 因为mysql命令的路径在/usr/local/mysql/bin下面,所以你直接使用mysql命令时,
3. 系统在/usr/bin下面查此命令,所以找不到了
4. 解决办法是:
5. ln -s /usr/local/mysql/bin/mysql /usr/bin 做个链接即可
6.
以下命令为mysql 启动及自启动配置
cp /usr/loacl/mysql/support-files/mysql.server /etc/init.d/mysqld
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &
chkconfig --add mysqld
chkconfig --level 345 mysqld on
service mysqld start
一般只要把my.cnf设置好这里就不会报错
********************************
安装php56
yum install libxml2-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel mysql bzip2-devel -y
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli --enable-pdo --with-pdo-mysql --with-mysql-sock --enable-xml --with-libxml-dir --enable-sockets --with-curl --with-gd --enable-gd-native-ttf --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-mcrypt --with-openssl --with-mhash --enable-zip --enable-mbstring --enable-mbregex --with-iconv --enable-static --with-zlib --enable-shmop --enable-soap --enable-sockets --enable-wddx --with-xmlrpc --enable-fpm --with-zlib-dir --with-bz2 --with-curl --enable-exif --enable-ftp --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-freetype-dir=/usr/lib/
apache配置文件httpd.conf相关修改以支持PHP
vim /usr/local/apache/conf/httpd.conf
1. 添加php支持。
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
2. 添加默认索引页面index.php,再找到“DirectoryIndex”,在index.html后面加上“ index.php”
DirectoryIndex index.html index.php
3. 不显示目录结构,找到“Options Indexes FollowSymLinks”,修改为
Options FollowSymLinks
4. 开启Apache支持伪静态,找到“AllowOverride None”,修改为
AllowOverride All
保存httpd.conf配置,然后再执行以下两行命令
chown -R nobody. /usr/local/apache/htdocs/
chmod -R 777 /usr/local/apache/htdocs/
service httpd restart
hop5.repo
[hop5]
name=www.hop5.in Centos Repository
baseurl=http://www.hop5.in/yum/el6/
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-HOP5