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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章