centos6.8搭建LAMP(能完整跑起来)

mysql-5.6.35

1.准备

$ yum install gcc-c++ bison ncurses-devel -y
$ cd /usr/local/src/
$ wget https://cmake.org/files/v3.7/cmake-3.7.1.tar.gz
$ wget http://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.35.tar.gz

$ tar zxf cmake-3.7.1.tar.gz
$ tar zxf mysql-5.6.35.tar.gz
$ cd cmake-3.7.1
$ ./bootstrap
$ gmake && gmake install
$ echo $?

2.配置、编译、安装

$ cd ../mysql-5.6.35
$ cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \ -DMYSQL_TCP_PORT=3306 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \

$ make && make install
$ echo $?

3.创建用户、组、相关目录

$ groupadd mysql
$ useradd -r -g mysql -s /sbin/nologin mysql

$ mkdir -p /data/mysql
$ chown -R mysql.mysql /usr/local/mysql
$ chown -R mysql.mysql /data/mysql

4.初始化数据库

$ chmod a+x scripts/mysql_install_db
$ ./scripts/mysql_install_db \
--basedir=/usr/local/mysql \ --datadir=/data/mysql \
--user=mysql

5.拷贝、修改配置文件

$ cp support-files/my-default.cnf /etc/my.cnf
$ vim /etc/my.cnf
    basedir = /usr/local/mysql
    datadir = /data/mysql
    socket = /tmp/mysql.sock

6.加入系统服务、设为开机启动

$ cp support-files/mysql.server /etc/init.d/mysqld
$ chmod 755 /etc/init.d/mysqld
$ chkconfig --add mysqld
$ chkconfig mysqld on
$ service mysqld start

7.命令路径加入系统环境变量

$ vim /etc/profile.d/path.sh
    #!/bin/bash
    export PATH=$PATH:/usr/local/mysql/bin
$ source /etc/profile.d/path.sh
$ service mysqld restart

Apache httpd-2.4.25

1.准备

$ cd /usr/local/src/
$ wget  https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.25.tar.gz
$ wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.5.2.tar.gz
$ wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.5.4.tar.gz

$ tar zxf apr-1.5.2.tar.gz
$ tar zxf apr-util-1.5.4.tar.gz
$ tar zxf httpd-2.4.25.tar.gz

$ yum install zlib zlib-devel pcre pcre-devel openssl openssl-devel -y
$ cd apr-1.5.2
$ ./configure --prefix=/usr/local/apr
$ make && make install
$ echo $?

$ cd ../apr-util-1.5.4
$ ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
$ make && make install
$ echo $?

2.配置、编译、安装

$ cd ../httpd-2.4.25
$ ./configure \
--prefix=/usr/local/apache2 \ --with-apr=/usr/local/apr \ --with-apr-util=/usr/local/apr-util \ --with-pcre \
--with-z \
--enable-so \
--enalbe-ssl \
--enable-deflate=shared \
--enable-expires=shared \
--enable-rewrite=shared \
--enable-static-support

$ make && make install

3.加入系统服务,设为开机启动

$ cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
$ chmod 755 /etc/init.d/httpd
$ vim /etc/init.d/httpd
    # chkconfig: - 85 15
    # description: Apache Web Server
$ chkconfig --add httpd
$ chkconfig httpd on
$ service httpd start
$ netstat -lnp | grep httpd

4.路径加入系统环境变量、设置ServerName

$ vim /etc/profile.d/path.sh
    #!/bin/bash
    export PATH=$PATH:/usr/local/mysql/bin*:/usr/local/apache2/bin
$ vim /usr/local/apache2/conf/httpd.conf                           
    ServerName localhost.xxx:80     
$ apachectl graceful

php-5.6.29

1.准备

$ yum install -y libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel libcurl libcurl-devel openssl openssl-devel
$ cd /usr/local/src/
$ wget http://ncu.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
$ wget http://am1.php.net/distributions/php-5.6.29.tar.bz2

$ tar zxf libmcrypt-2.5.8.tar.gz
$ tar jxf php-5.6.29.tar.bz2
$ cd libmcrypt-2.5.8
$ ./configure prefix=/usr/local/libmcrypt
$ make && make install

2.配置、编译、安装

$ cd ../php-5.6.29
$ ./configure \
--prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \
--with-apxs2=/usr/local/apache2/bin/apxs \ --with-mysql=/usr/local/mysql \ --with-mysql-sock=/tmp/mysql.sock \
--with-openssl \
--with-libxml-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib \
--with-mcrypt=/usr/local/libmcrypt \ --enable-soap \
--enable-gd-native-ttf \
--enable-mbstring \
--enable-exif \
--enable-sockets \
--disable-ipv6

$ make
$ make test
$ make install

3.拷贝配置文件

$ cp php.ini-production /usr/local/php/etc/php.ini

4.连接apache httpd

$ vim /usr/local/apache2/conf/httpd.conf
    <IfModule dir_module>
         DirectoryIndex index.html index.php index.htm
    </IfModule>
    AddType application/x-httpd-php .php

5.路径加入系统环境变量

$ vim /etc/profile.d/path.sh
    #!/bin/bash
    export PATH=$PATH:/usr/local/mysql/bin:/usr/local/apache2/bin:/usr/local/php/bin
$ source /etc/profile.d/path.sh
$ apachectl restart

6.测试php解析

$ curl localhost
($ iptables -F
$ service iptables save)

$ vim /usr/local/apache2/htdocs/info.php
    <?php
        phpinfo();
    ?>
$ apachectl graceful
$ curl localhost/info.php

⚠️注意:配置、编译、安装httpd-2.4.25时不能开启--enalbe-ssl 需要找原因,目前不影响运行

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券