源码编译安装 LAMP

文章目录

    • 环境
    • 源码安装 mariadb10.2.25
    • 创建数据库,授权
    • 源码安装配置 httpd
    • 源码编译安装 php-7.4.2
    • 配置 php
    • 启动服务
    • 网站代码挂载到网站根目录
    • 浏览器访问

环境

mariadb php-fpm、httpd
192.168.43.7 192.168.43.17

源码安装 mariadb10.2.25

[192.168.43.7]#

wget -c -P /usr/local/src -O mysql.tar.gz http://ftp.hosteurope.de/mirror/archive.mariadb.org//mariadb-10.2.25/source/mariadb-10.2.25.tar.gz
tar xvf mysql.tar.gz
useradd -r -s /sbin/nologin -d /data/mysql mysql
mkdir /data/mysql
chown mysql.mysql /data/mysql
cd /usr/local/src/mysql
yum install bison bison-devel zlib-devel libcurl-devel libarchive-devel boost-devel gcc gcc-c++ cmake ncurses-devel gnutls-devel libxml2-devel openssl-devel libevent-devel libaio-devel -y
cmake . -DCMAKE_INSTALL_PREFIX=/app/mysql -DMYSQL_DATADIR=/data/mysql/ -DSYSCONFDIR=/etc/mysql -DMYSQL_USER=mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITHOUT_MROONGA_STORAGE_ENGINE=1 -DWITH_DEBUG=0 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DENABLED_LOCAL_INFILE=1 -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make -j `lscpu|grep -w "^CPU(s):"|awk '{print $2}'` && make install
cd /app/mysql/
scripts/mysql_install_db --datadir=/data/mysql --user=mysql
mkdir /etc/mysql
cp support-files/my-huge.cnf /etc/mysql/my.cnf
sed -i '/\[mysqld\]/a\datadir = /data/mysql' /etc/mysql/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
echo 'PATH=/app/mysql/bin/:$PATH' > /etc/profile.d/mysql.sh
. /etc/profile.d/mysql.sh
service mysqld start

创建数据库,授权

[192.168.43.7]#

mysql -e "create database discuz;grant all on discuz.* to discuz@'192.168.43.%' identified by 'discuz';flush privileges;"

源码安装配置 httpd

源码编译安装httpd-2.4.41
https://blog.csdn.net/studywinwin/article/details/104126004

配置文件
[192.168.43.17]#

useradd -r -s /sbin/noligin apache
mkdir /app/httpd24/conf.d/
echo "IncludeOptional conf.d/*.conf" >> /app/httpd24/conf/httpd.conf
cat < /app/httpd24/conf.d/httpd_php.conf
User apache
Group apache
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

    DirectoryIndex index.php index.html

AddType application/x-httpd-php .php
AddType application/x-httpd-source .phps
proxyrequests off
ProxyPassMatch "^/(.*\.php(/.*)?)$" "unix:/var/run/php5-fpm.sock|fcgi://localhost/app/httpd24/htdocs/"
EOF

源码编译安装 php-7.4.2

[192.168.43.17]#

yum --enablerepo=epel install libxml2-devel bzip2-devel libmcrypt-devel sqlite-devel oniguruma oniguruma-devel -y
tar Jxvf php-7.4.2.tar.xz
cd php-7.4.2/
./configure --prefix=/app/php --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets --enable-fpm --enable-maintainer-zts --disable-fileinfo
make -j `lscpu|grep '^CPU(s):'|awk '{print $2}'`
make install

配置 php

[192.168.43.17]#

cp php.ini-production /etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add /etc/init.d/php-fpm
chkconfig php-fpm on
cd /app/php/etc/
cp php-fpm.conf.default php-fpm.conf
cp php-fpm.d/www.conf.default php-fpm.d/www.conf

[192.168.43.17]#

vim php-fpm.d/www.conf
user = apache
group = apache
listen = /var/run/php5-fpm.sock
listen.owner = apache
listen.group = apache
listen.mode = 0660

启动服务

[192.168.43.17]#

systemctl start httpd24
service php-fpm start

网站代码挂载到网站根目录

[192.168.43.17]#

unzip Discuz_X3.2_SC_UTF8.zip
mv upload/ /app/httpd24/htdocs/forum
setfacl -Rm u:apache:rwx /app/httpd24/htdocs/forum

浏览器访问

http://192.168.43.17/forum
在这里插入图片描述
在php服务器中开启显示错误代码查看
[192.168.43.17]#

vim /etc/php.ini
display_errors = on

service php-fpm restart

http://192.168.43.17/forum
在这里插入图片描述
修改以下配置文件
[192.168.43.17]#

vim +12 /app/httpd24/htdocs/forum/install/index.php
12 // @set_magic_quotes_runtime(0);

http://192.168.43.17/forum
安装完出现了如下错误
源码编译安装 LAMP_第1张图片

你可能感兴趣的:(LAMP)