未分类
版本信息:
- apache2.4
- php7.2
- mysql5.6
将所需要的软件放到 / root/software / 文件夹下
安装 Apache 及所需依赖
安装 zlib
- cd /root/software
- tar xf zlib-1.2.8.tar.gz
- cd zlib-1.2.8
- ./configure
- make
- make install
- cd ..
安装 apr
- tar xf apr-1.5.2.tar.gz
- cd apr-1.5.2
- ./configure --prefix=/usr/local/apr
- make
- make install
- cd ..
安装 apr-iconv
- tar xf 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
- cd ..
安装 apr-util
- tar xf 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/apr-iconv
- make
- make install
- cd ..
安装 pcre
- tar xf pcre-8.39.tar.gz
- cd pcre-8.39
- ./configure --prefix=/usr/local/pcre
- make
- make install
- cd ..
***** 出现报错 *****
报错
configure: error: You need a C++ compiler for C++ support
解决:
- yum install -y gcc gcc-c++
- *********************
安装 pcre-devel
yum -y install pcre-devel
安装 httpd
- tar xf httpd-2.4.17.tar.gz
- cd httpd-2.4.17
- ./configure --prefix=/usr/local/lamp/apache2 --enable-modules=all --enable-so --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
- make
- make install
- cd ..
配置 httpd 管理理脚本
- chmod u+x httpd
- cp httpd /etc/init.d/httpd
设定 ServerName
echo "ServerName 127.0.0.1:80">> /usr/local/lamp/apache2/conf/httpd.conf
开启服务
service httpd start
添加到开机启动服务
- chkconfig --add httpd
- chkconfig --level 345 httpd on
安装 php 及所需依赖
安装 libxml2
- ln -sf /usr/local/lib/libz.so.1.2.8 /usr/lib64/libz.so
- tar xf libxml2-2.7.2.tar.gz
- cd libxml2-2.7.2
- ./configure
- make
- make install
- cd ..
安装 jpeg
- tar xf jpegsrc.v9b.gz
- cd jpeg-9b/
- ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
- make
- make install
- cd ..
安装 png
- tar xf libpng-1.4.3.tar.gz
- cd libpng-1.4.3
- ./configure --prefix=/usr/local/png --enable-shared --enable-static
- make
- make install
- cd ..
安装 freetype
- tar xf freetype-2.7.tar.gz
- cd freetype-2.7
- ./configure --prefix=/usr/local/freetype --enable-shared
- make
- make install
- cd ..
安装 gd
- tar xf libgd-2.2.3.tar.gz
- cd libgd-2.2.3
- ./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg/ --with-png=/usr/local/png --with-zlib --with-freetype=/usr/local/freetype --disable-werror
- make
- make install
- cd ..
安装 bison
yum -y install bison
安装 libmcrypt
- tar xf libmcrypt-2.5.8.tar.gz
- cd libmcrypt-2.5.8
- ./configure --disable-posix-threads
- make
- make install
- cd ..
将 libmcrypt 所在路径保存到环境变量中, 以便 mcrypt 安装的时候搜索所需的软件包
export LD_LIBRARY_PATH=/usr/local/lib
安装 mhash
- tar xf mhash-0.9.9.9.tar.gz
- cd mhash-0.9.9.9
- ./configure
- make
- make install
- cd ..
安装 mcrypt
- tar xf mcrypt-2.6.8.tar.gz
- cd mcrypt-2.6.8
- ./configure --with-libmcrypt-prefix=/usr/local
- make
- make install
- cd ..
安装 autoconf
- tar xf autoconf-2.69.tar.gz
- cd autoconf-2.69
- ./configure
- make
- make install
- cd ..
安装 libiconv
- tar xf libiconv-1.14.tar.gz
- cd libiconv-1.14
- ./configure --prefix=/usr/local/libiconv
- make
- make install
- cd ..
安装 libXpm
yum -y install libXpm-devel
安装 php
- tar xf php-7.1.8.tar.bz2
- cd php-7.1.8
- ./configure --prefix=/usr/local/lamp/php --with-apxs2=/usr/local/lamp/apache2/bin/apxs --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-freetype-dir=/usr/local/freetype --with-gd=/usr/local/gd/ --with-zlib --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/png --enable-mbstring=all --enable-mbregex --enable-shared --disable-fileinfo --with-iconv=/usr/local/libiconv --with-libxml-dir=/usr/local --with-xpm-dir=/usr/lib --enable-fpm
- make
- make install
- cp php.ini-development /usr/local/lamp/php/lib/php.ini
- cd ..
配置时区
echo "date.timezone = PRC">> /usr/local/lamp/php/lib/php.ini
让 Apache 支持 php
echo "AddHandler application/x-httpd-php .php">> /usr/local/lamp/apache2/conf/httpd.conf
重启 Apache
service httpd restart
安装 MySQL 及所需依赖
安装 ncurses-devel
yum -y install ncurses-devel
安装 cmake
因为新版的 MySQL 都不在具有. configure 是通过 cmake 进行打包的
yum -y install cmake
安装 mysql
- tar xvf mysql-5.6.25.tar.gz
- cd mysql-5.6.25
- cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lamp/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/lamp/mysql/data -DMYSQL_USER=mysql
- make
- make install
不要着急哦.... 这应该是最漫长的等待了......
添加用户
用户无需登录系统, 所以指定用户登陆后使用的 shell 是 nologin, 禁止登录,-r 表示系统账号, 系统账号 uid 较小
useradd -s /sbin/nologin -r mysql
修改目录权限, 将 data 文件夹所有者改为 mysql
data 文件夹用来存放数据, 必须保证 mysql 用户可以写操作, 由于整个安装过程都是 root 用户执行, 所以其它文件夹都是输入 root 用户
chown mysql.mysql /usr/local/lamp/mysql/data -R
复制配置文件
cp support-files/my-default.cnf /etc/my.cnf
创建 mysql 测试数据库和系统数据库
- cd /usr/local/lamp/mysql
- scripts/mysql_install_db --user=mysql --datadir=/usr/local/lamp/mysql/data
测试
启动 mysql
/usr/local/lamp/mysql/bin/mysqld_safe &
登录 mysql
- /usr/local/lamp/mysql/bin/mysql -uroot
- mysql> show databases;
修改密码, 增加安全性
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
创建允许远程登录的用户
- mysql> CREATE USER 'itsource'@'%' IDENTIFIED BY '123456';
- mysql> select password('123456');
- mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD 'xxxxxx';
添加 mysql 到系统服务
复制启动文件
cp /usr/local/lamp/mysql/support-files/mysql.server /etc/init.d/mysqld
添加可执行权限
chmod a+x /etc/init.d/mysqld
做了上面的步骤就可以使用 service mysqld 来控制 mysql 服务器了
比如: service mysqld start 可以启动 mysql 服务器
添加到开机启动服务
- chkconfig --add mysqld
- chkconfig --level 345 mysqld on
来源: http://www.bubuko.com/infodetail-2741783.html