设为首页 收藏本站
查看: 1274|回复: 0

centos7 编译安装lamp

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-12-19 12:55:13 | 显示全部楼层 |阅读模式
系统:centos7
软件版本:php-7.1.0 +mysql-boost-5.7.16 + httpd-2.4.23
一、linux 系统限制配置
1、关闭系统防火墙  
1
2
systemctl stop firewalld.service 关闭防火墙
systemctl disable firewalld.service  禁用防火墙



2、关闭SElinux
1
2
sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce 0 selinux 立即生效



二、系统安装约定
软件源代码包存放位置:/usr/local/src
源码包编译安装位置:/usr/local/软件名字
三、现在源码安装包
1、下载mysql-boost-5.7.16
1
wget -P /usr/local/src http://cdn.mysql.com/Downloads/M ... boost-5.7.16.tar.gz



2、下载php-7.1.0
1
wget -P /usr/local/src http://cn2.php.net/distributions/php-7.1.0.tar.gz



3、下载httpd-2.4.23
1
wget -P /usr/local/src http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.23.tar.gz



4、下载 libmemcached-1.0.18
1
wget -P /usr/local/src https://launchpadlibrarian.net/1 ... ached-1.0.18.tar.gz



5、下载apr-util-1.5.4
1
wget -P /usr/local/src http://apache.fayea.com//apr/apr-util-1.5.4.tar.gz



6、下载apr-1.5.2
1
wget -P /usr/local/src http://apache.fayea.com//apr/apr-1.5.2.tar.gz



7、下载/pcre-8.39
1
wget -P /usr/local/src https://nchc.dl.sourceforge.net/ ... 39/pcre-8.39.tar.gz



8、下载apr-iconv-1.2.1
1
wget -P /usr/local/src http://apache.fayea.com//apr/apr-iconv-1.2.1.tar.gz



9、下载php-memcached
1
2
3
yum -y install git
cd /usr/local/src
git clone -b php7 https://github.com/php-memcached-dev/php-memcached.git



四、安装编译器及依赖
1
2
3
4
5
6
7
yum -y install epel-release
yum -y install patch gcc gcc-c++  readline-devel zlib-devel libffi-devel \
openssl openssl-devel make autoconf automake libtool bison libxml2 \
libxml2-devel libxslt-devel libyaml-devel  python  python-docutils \
cmake imake expat-devel libaio libaio-devel bzr ncurses-devel wget \
libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel  \
pcre-devel curl-devel libmcrypt libmcrypt-devel uuid-devel



五、安装编译MySQL-5.16
1、生成MySQL编译脚本
1
vim mysql_install.sh



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
#mysql安装脚本
DBDIR='/data/mysql' #mysql 数据路径
MYSQLDIR='/usr/local/mysql' # mysql 安装路径
PASSWD='123456' # MySQL root登陆密码
[ -d $DBDIR ] || mkdir $DBDIR -p
id mysql &> /dev/null
if [ $? -ne 0 ];then
useradd mysql -s /sbin/nologin -M
fi
chown -R mysql:mysql $DBDIR
cd /usr/local/src
tar -xvf mysql-boost-5.7.16.tar.gz
cd mysql-5.7.16
cmake . -DCMAKE_INSTALL_PREFIX=$MYSQLDIR \
-DMYSQL_DATADIR=$DBDIR \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_LIBWRAP=0 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_BOOST=/usr/local/src/mysql-5.7.16/boost/boost_1_59_0 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
if [ $? != 0 ];then
echo "cmake error!"
exit 1
fi
make && make install
if [ $? -ne 0 ];then
echo "install mysql is failed!" && /bin/false
fi
sleep 2
chown -R mysql:mysql $MYSQLDIR
chown -R root:root $MYSQLDIR
cp $MYSQLDIR/support-files/my-default.cnf /etc/my.cnf
echo export PATH=$PATH:$MYSQLDIR/bin:$MYSQLDIR/lib >>/etc/profile
source /etc/profile
cat >>  /etc/my.cnf << EOF
character_set_server = utf8
basedir = $MYSQLDIR
datadir = $DBDIR
port = 3306
server_id = 1
socket = /tmp/mysql.sock
explicit_defaults_for_timestamp=true
EOF
sed -i 's/sql_mode=.*/sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER/g' /etc/my.cnf
     source /etc/profile
     sleep 5
     cd $MYSQLDIR
     cp support-files/mysql.server /etc/init.d/mysqld
     chmod 700 /etc/init.d/mysqld
     mysql_ssl_rsa_setup
     rm -rf /data/mysql
     mysqld --initialize --user=mysql
     if [ $? -ne 0 ];then
echo "install mysql is failed!" && /bin/false
fi
#/etc/init.d/mysqld stop
     mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
     sleep 5
     echo "update user set authentication_string=Password('$PASSWD') where user='root'; flush privileges;" | mysql mysql

     echo "set password=Password('$PASSWD'); flush privileges;" | mysql -u root -p$PASSWD --connect-expired-password
     sleep 5
     echo "GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY '$PASSWD'; FLUSH PRIVILEGES; " | mysql -u root -p$PASSWD
     /etc/init.d/mysqld restart
     if [ $? -ne 0 ];then
echo "install mysql is failed!" && /bin/false
fi
IDSO=`cat /etc/ld.so.conf| grep /usr/local/lib64 | wc -l `
if [ $IDSO -eq 0 ];then
echo "/usr/local/lib64" >> /etc/ld.so.conf
ldconfig
fi
chkconfig mysqld on



2、给mysql_install.sh  可执行权限
1
chmod +x mysql_install.sh



3、编译安装MySQL
1
./mysql_install.sh



六、编译安装httpd-2.4.23 及依赖
1、安装apr-1.5.2
1
2
3
4
5
6
7
8
9
cd /usr/local/src
解压apr-1.5.2.tar.gz
tar -zxvf apr-1.5.2.tar.gz
cd apr-1.5.2
修改configure 不修改编译会报错
sed -i 's/$RM "$cfgfile"/#$RM "$cfgfile"/g' ./configure
编译 apr-1.5.2
./configure --prefix=/usr/local/apr
make && make install



2、安装apr-iconv-1.2.1
1
2
3
4
5
6
7
8
cd /usr/local/src
解压 apr-iconv-1.2.1.tar.gz
tar -zxvf apr-iconv-1.2.1.tar.gz
编译
cd apr-iconv-1.2.1
./configure --prefix=/usr/local/apr-iconv \
            --with-apr=/usr/local/apr
make && make install



3、安装apr-util-1.5.4
1
2
3
4
5
6
7
8
9
cd /usr/local/src
解压apr-util-1.5.4.tar.gz
tar -zxvf apr-util-1.5.4.tar.gz
编译
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util \
            --with-apr=/usr/local/apr \
        --with-apr-iconv=/usr/local/apr-iconv/bin/apriconv
make && make install



4、安装pcre-8.39
1
2
3
4
5
6
7
cd /usr/local/src
解压pcre-8.39.tar.gz
tar -xvf pcre-8.39.tar.gz
cd /usr/local/src/pcre-8.39
编译
./configure  --prefix=/usr/local/pcre
make && make install



5、安装httpd-2.4.23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
创建 apache
useradd  apache -s /sbin/nologin -M
cd /usr/local/src
解压httpd-2.4.23.tar.gz
tar -zxvf httpd-2.4.23.tar.gz
编译
cd httpd-2.4.23
./configure --with-apr=/usr/local/apr \
            --with-apr-util=/usr/local/apr-util \
            --with-pcre=/usr/local/pcre \
            --prefix=/usr/local/apache  \
            --sysconfdir=/etc/httpd \
            --enable-so  \
            --enable-ssl \
            --enable-cgi \
            --enable-rewrite \
            --with-zlib  \
            --with-pcre  \
            --with-mpm=prefork \
            --enable-modules=most \
            --enable-mpms-shared=all
make && make install
创建配置文件夹
mkdir -p /usr/local/apache/conf.d
给web页面存放目录apache用户读写权限
chown -R apache:apache /usr/local/apache/htdocs/



七、安装php
1、安装php-7.1.0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
cd /usr/local/src
解压php-7.1.0.tar.gz
tar -xzvf php-7.1.0.tar.gz
编译
cd ./php-7.1.0
./configure \
--prefix=/usr/local/php7 \
--exec-prefix=/usr/local/php7 \
--with-config-file-path=/usr/local/php7/etc \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--with-zlib-dir \
--with-mhash \
--with-mcrypt \
--with-openssl-dir \
--with-jpeg-dir \
--with-apxs2=/usr/local/apache/bin/apxs \ #apache安装路径
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
# --enable-gd-jis-conv \ #php画图中文会出现乱码
make && make install



2、安装libmemcached-1.0.18
1
2
3
4
5
6
7
cd /usr/local/src
解压libmemcached-1.0.18.tar.gz
tar -zxvf libmemcached-1.0.18.tar.gz
编译
cd ./libmemcached-1.0.18
./configure --prefix=/usr/local/libmemcached
make && make install



3、安装php-memcached
1
2
3
4
5
6
7
8
9
10
cd /usr/local/src/php-memcached
生成编译配置
/usr/local/php7/bin/phpize
编译
./configure --with-libmemcached-dir=/usr/local/libmemcached \
--with-php-config=/usr/local/php7/bin/php-config \
--disable-memcached-sasl
make && make install
编译完成记录生成的路径
Installing shared extensions:     /usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/



八、配置PHP及HTTPD

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
cd /usr/local/src/php-7.1.0
cp php.ini-production /usr/local/php7/etc/php.ini
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/
配置PHP时区
cat >> /usr/local/php7/etc/php.ini<< EOF
soap.wsdl_cache_enabled=1
max_input_time = 600
max_execution_time = 300
date.timezone = Asia/Shanghai
post_max_size = 32M
memory_limit = 128M
mbstring.func_overload = 1
extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/memcached.so
EOF
配置httpd 端口
sed -i 's/#ServerName www.example.com:80/ServerName localhost:80/g' /etc/httpd/httpd.conf
配置http支持php
cat >> /etc/httpd/httpd.conf <<EOF
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
EOF
sed -i 's/DirectoryIndex.*/DirectoryIndex index.php  index.html/g' /etc/httpd/httpd.conf
sed -i "s/User daemon/User apache/g"  /etc/httpd/httpd.conf
sed -i "s/Group daemon/Group apache/g"  /etc/httpd/httpd.conf
拷贝http启动脚本
cp -rf /usr/local/apache/bin/apachectl /etc/init.d/httpd
chmod +x /etc/init.d/httpd
让启动脚本可以添加为系统开机启动
sed -i "2 a#chkconfig: 2345 10 90" /etc/init.d/httpd
sed -i "3 a#description: Activates/Deactivates Apache Web Server" /etc/init.d/httpd
设置开机启动
chkconfig httpd on
生成php测试页
cat >/usr/local/apache/htdocs/index.php <<EOF
<?php
phpinfo();
?>
EOF
启动httpd
service httpd start



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-316473-1-1.html 上篇帖子: lamp默认虚拟主机和301跳转 下篇帖子: LAMP中的php编译安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表