LAAP Linux+Apache+Mysql(AliSQL)+PHP安装教程 – 作者:zcczcc

一、安装Apache

1.关闭 Selinux

vim /etc/selinux/config
SELINUX=disabled,将 enabled 改为 disabled

2.安装必需组件

yum -y install libxml2-devel
yum -y install openssl-devel
yum -y install expat-devel
yum -y install gcc gcc-c++
yum -y install autoconf
yum -y install ncurses-devel
yum -y install unzip
yum -y install curl-devel
yum -y install libpng-devel
yum -y install freetype-devel
yum -y install libxslt-devel

3.安装 apr 和 apr-util

cd /usr/local/src
tar -zxvf apr-1.6.5.tar.gz
cd apr-1.6.5/
./configure --prefix=/data/service/apr && make && make install
tar -zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1/
./configure --prefix=/data/service/apr-util --with-apr=/data/service/apr && make 
&& make install

4.安装zlib

tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11/
 ./configure --prefix=/data/service/zlib && make && make install

5.安装pcre

tar -zxvf pcre-8.39.tar.gz
 cd pcre-8.39/
 ./configure --prefix=/data/service/pcre && make && make install

6.更新openssl

tar -zxvf openssl-1.1.1b.tar.gz
 cd openssl-1.1.1b /
 ./config --prefix=/data/service/openssl && make && make install
 mv /usr/bin/openssl /usr/bin/openssl.old
 ln -s /data/service/openssl/bin/openssl /usr/bin/openssl
 ln -s /data/service/openssl/include/openssl /usr/include/openssl
 ln -s /data/service/openssl/lib/libssl.so /usr/local/lib64/libssl.so

7.安装Apache (httpd)

tar -zxvf httpd-2.4.39.tar.gz
cd httpd-2.4.39/
./configure --prefix=/data/server/apache --enable-so --enable-rewrite --enable-ssl --withssl=/usr/bin/openssl --enable-cgi --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-mpm=event --with-pcre=/data/service/pcre --withz=/data/service/zlib --with-apr=/data/service/apr --with-apr-util=/data/service/apr-util --enable-expires --enable-deflate && make && make install
vim /data/server/apache/conf/httpd.conf

修改 ServerName localhost:80

cp /data/server/apache/bin/apachectl /etc/rc.d/init.d/httpd
sed -i '1a # chkconfig: 35 85 21' /etc/rc.d/init.d/httpd
sed -i '2a # description: apache 2.4.39' /etc/rc.d/init.d/httpd
service httpd restart

8.开启80端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

二、安装Mysql(AliSQL)

1.安装配置Java环境

2.安装 cmake

tar -zxvf cmake-2.8.10.2.tar.gz
cd cmake-2.8.10.2
./bootstrap ; make ; make install

3.安装bison

tar -zxvf bison-2.7.tar.gz
cd bison-2.7
./configure
make -j 8 && make install

4.安装Mysql(AliSQL)数据库

(1)卸载系统自带的Mariadb

rpm -qa|grep mariadb
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64

(2)创建mysql用户组

groupadd mysql

(3)创建一个用户名为mysql的用户并加入mysql用户组

useradd -r -g mysql mysql

(4)将下载的压缩包放到/usr/local/src目录下并解压

unzip AliSQL-master.zip

(5)创建目录

mkdir -p /data/server/mysql
mkdir -p /data/server/AliSQL-data

(6)编译安装Mysql(AliSQL)

cd AliSQL-master/
cmake -DCMAKE_INSTALL_PREFIX=/data/server/mysql -DMYSQL_UNIX_ADDR=/data/server/mysql/mysql.sock -DDEFAULT_CHARSET=utf8   -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/server/AliSQL-data -DMYSQL_TCP_PORT=3306
make
make install

(7)修改Mysql(AliSQL)目录所有者和组

cd /data/server/mysql/ 
chown -R mysql:mysql 
cd /data/server/AliSQL-data
chown -R mysql:mysql .

(8)初始化 Mysql(AliSQL)数据库

cd /data/server/mysql/
scripts/mysql_install_db --user=mysql --datadir=/data/server/AliSQL-data

(9)复制 Mysql(AliSQL) 服务启动配置文件

cp /data/server/mysql/support-files/my-default.cnf /etc/my.cnf
 cp support-files/mysql.server /etc/init.d/mysqld
 vim /etc/profile
 加入 PATH=/data/server/mysql/bin:/data/server/mysql/lib:$PATH
 source /etc/profile

(10)启动 Mysql(AliSQL) 服务并加入开机自启动

service mysqld start
 chkconfig --level 35 mysqld on

(11)配置数据库

./bin/mysqladmin -u root password '1234abcd'
mysql -u root -p 

(12)关闭防火墙

systemctl stop firewalld

三、 安装 PHP

(1) 解压 PHP 安装包

cd /usr/local/src
tar -zxvf php-7.1.29.tar.gz

(2) 以 Apache 的模块安装

cd php-7.1.29/
./configure --prefix=/data/server/php7 --withapxs2=/data/server/apache/bin/apxs --with-curl --with-freetype-dir --with-gd 
--with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --withlibxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql - -with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --withzlib --enable-fpm --enable-bcmath --enable-libxml --enable-inlineoptimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --
enable-opcache --enable-pcntl --enable-shmop --enable-soap --enablesockets --enable-sysvsem --enable-xml --enable-zip
make && make install

(3) 配置 php.ini 文件

cp /usr/local/src/php-7.1.29/php.ini-development /data/server/php7/etc/php.ini
mysqli.default_socket =/data/server/mysql/mysql.sock 
date.timezone = Asia/Shanghai 
expose_php = Off 
short_open_tag = ON 
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
post_max_size = 32M

(4) 关联 PHP 与 Apache 服务

① vim /data/server/apache/conf/httpd.conf
② 在 LoadModule 处添加 LoadModule php7_module modules/libphp7.so
③ 在 DirectoryIndex 后面添加:index.php
④ 末尾添加<FilesMatch \.php$>
 SetHandler application/x-httpd-php
</FilesMatch>

(5) 修改环境变量

vim /etc/profile

在末尾添加:

PATH=$PATH:/data/server/php7/bin 
export PATH

完成!

来源:freebuf.com 2021-01-13 10:23:35 by: zcczcc

© 版权声明
THE END
喜欢就支持一下吧
点赞0
分享
评论 抢沙发

请登录后发表评论