您的位置:首页 > 运维架构 > Apache

【RedHat】手动编译安装部署Apache2.4、PHP7.1、MySql5.7开发环境

2017-01-09 12:21 786 查看
在redhat6.5上部署LAMP开发相关环境,放弃使用yum等一键部署工具,都在官网下载最新安装包手动进行编译安装,道路很是曲折,按照Mysql5.7、Apache2.4、PHP7.1的顺序一步步帮你爬过坑。

1.先安装Mysql5.7

主要参考博客:http://blog.csdn.net/gao715108023/article/details/11560731

下载Mysql

wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17.tar.gz
1.卸载系统默认的MySQL:参考

# rpm -qa | grep mysql  

# rpm -e mysql-server-5.0.77-4.el5_6.6  

2。创建用户

[root@localhost bin]groupadd mysql  

[root@localhost bin]useradd –g mysql mysql  

[root@localhost bin]passwd mysql  

3.安装cmake

先上cmake官网下载

# tar zxvf cmake-2.8.4.tar.gz  

# cd cmake-2.8.4  

./configure  

# make && make install 

# tar zxvf mysql-5.7.17.tar.gz 

cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql57 -DSYSCONFDIR=/opt/mysql57/data -DMYSQL_DATADIR=/opt/mysql57/data -DMYSQL_UNIX_ADDR=/opt/mysql55/data/mysqld.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1  -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_TCP_PORT=33061 -DWITH_EXTRA_CHARSETS=all -DWITH_DEBUG=0 -DENABLE_DEBUG_SYNC=0 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_READLINE=1 -DZLIB_INCLUDE_DIR=/usr -DWITH_READLINE=1  

#make && make install

5.运行mysql_install_db生成授权表

[root@localhost opt]# chown -R mysql:mysql mysql57  

[root@localhost opt]# su – mysql  

[mysql@localhost ~]$ cd /opt/mysql57  

[mysql@localhost mysql55]$ cp scripts/mysql_install_db .  

[mysql@localhost mysql55]$ ./mysql_install_db  

[mysql@localhost mysql55]$ cp support-files/my-huge.cnf /opt/mysql55/data/my.cnf  

7.配置自动服务

[root@localhost mysql55]# cp  -r support-files/mysql.server /etc/init.d/mysql  

[root@localhost mysql55]# cd /etc/rc.d/init.d  

[root@localhost init.d]# chmod +x mysql  

[root@localhost init.d]# /sbin/chkconfig --del mysql  

[root@localhost init.d]# /sbin/chkconfig  --add mysql  

[root@localhost init.d]# service mysql start  

遇到的一些问题:

根据博客:http://blog.itpub.net/29733787/viewspace-1590891/

mysql_install_db

#
d99a
cd /db/mysql/mysql_57# bin/mysql_install_db --basedir=. --datadir=data --user=mysql

# bin/mysqld --initialize

初始化密码

mysql5.7会生成一个初始化密码,而在之前的版本首次登陆不需要登录。

# cat /root/.mysql_secret # Password set for user 'root@localhost' at 2015-04-22 22:13:23

?G5W&tz1z.cN

修改默认密码

# bin/mysqladmin -h localhost -u root password '123@qwe' -p'?G5W&tz1z.cN'

mysql5.7的mysql.user表结构被修改password 字段已经在授权表中去除

重启mysql

service mysql restart --skip-grant-tables

mysql -uroot -p

mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = '%';

mysql> flush privileges;

mySql5.7操作时报错:You must SET PASSWORD before executing this statement解决

mysql> SET PASSWORD = PASSWORD('123456');这句话重新设置一次密码!

开启远程访问:

最粗暴的方法:

关闭防火墙:

service iptables stop

修改防火墙:放通端口和网口,配置如下:

# vi  /etc/sysconfig/iptables

增加行:
-A INPUT -i
eth0 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport
3306 -j ACCEPT

# service iptables restart

手动安装APACHE

1.下载:APACHE httpd-2.4.25.tar.gz

下载 apr-1.4.2.tar.gz
apr-util-1.3.10.tar.gz pcre-8.10.zip 相关包已下载保存

11.安装apr-1.4.2.tar.gz

#tar zxvf
apr-1.4.2.tar.gz

#cd apr-1.4.2

#./configure –prefix=/usr/local/apr

#make && make install

1.2.安装
apr-util-1.3.10.tar.gz

#tar zxvf
apr-util-1.3.10.tar.gz

#cd apr-util-1.3.10

#./configure --prefix=/usr/local/apr-util –with-apr=/usr/local/apr

#make && make install

1.3.安装pcre-8.10.zip

#tar zxvf pcre-8.10.zip

#cd pcre-8.10

#./configure --prefix=/usr/local/pcre

#make && make install

1.4.安装apache

# cd apache.2.4.25

# ./configure --prefix=/opt/apache --enable-rewrite --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre

# make && make install

# /opt/httpd/bin/httpd -k start

APACHE OK!

安装php7.1.0

# tar -jxvf php-5.3.6.tar.bz2# cd php-5.3.6

# ./configure --prefix=/opt/php -with-apxs2=/opt/httpd/bin/apxs --with-curl -with-jpeg-dir=/usr/local/lib --enable-pdo --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd

# make && make install

# cp php.ini-development /opt/php/lib/php.ini

# ln -s /opt/php/bin/php /usr/bin/php

# vi /opt/php/lib/php.ini

把include_path前面的分号删除,改成include_path = "/opt/php/lib/php"

# sudo vi /opt/httpd/conf/httpd.conf

在最下面加入一行

AddHandler application/x-httpd-php .php

# sudo /opt/httpd/bin/httpd -k restart

把apache加入系统service,开机自启动

# sudo cp /opt/httpd/bin/apachectl /etc/init.d/httpdsudo vi /etc/init.d/httpd

在文件开头加入下面几行:

# !/bin/sh

# chkconfig: 2345 85 15

# description: Apache is a World Wide Web server.

sudo chmod +x /etc/init.d/httpd

sudo /sbin/chkconfig --add httpd

sudo /sbin/chkconfig --list httpd

sudo ln -s /sbin/chkconfig /usr/bin/chkconfig

sudo ln -s /sbin/service /usr/bin/service

重启服务,配置完成!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php apache mysql lamp red hat