@flyok666
2018-07-01 16:58
字数 4762
阅读 333
安装apache+PHP+Mysql
未分类
版本信息:
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
+
原文地址:https://www.cnblogs.com/suli0827/p/9534313.html
时间: 2024-09-26 20:11:25