liubulong 发表于 2019-11-22 20:41:06

CentOS7编译安装LAMP

CentOS7编译安装LAMPmairadb:通用二进制格式,mariadb-5.5.56httpd:编译安装,httpd-2.4.25php5:编译安装,php-5.6.30

tar xvf mariadb-5.5-46-linux-x86_64.tar.gz -C /usr/local
cd /usr/local
ls -sv mariadb-5.5.46-linux-x86_64 mysql
cd mysql
chown -R root.mysql ./*
mkdir /mydata/data -p
chown -R mysql.mysql /mydata/data
mkdir /etc/mysql
cp support-files/my-large.cnf /etc/mysql/my.cnf

vim /etc/mysql/my.cnf
加三行
datadir =/mydata/data
innodb_file_per_table = ON
skip_name_resolve = ON

vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin/:$PATH

cd /usr/local/mysql;scripts/mysql_install_db --user=mysql --datadir=/mydata/data
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
service mysqld start

编译安装httpd-2.4
yum install gcc pcre-devel openssl-devel expat-devel
./configure --prefix=/app/httpd24 \
--enable-so \
--enable-ssl \
--enable-cgi \
--enable-rewrite \
--with-zlib \
--with-pcre \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=prefork \
--with-included-apr
make -j 4 && make install

编译安装php-7.3.0
相关包:
yum -y install libxml2-devel bzip2-devel libmcrypt-devel (epel)
./configure --prefix=/app/php --enable-mysqlnd --with-mysqli=mysqlnd --with-openssl --with-pdo-mysql=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/app/httpd24/bin/apxs --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-maintainer-zts --disable-fileinfo
注意:php-7.0以上版本使用--enable-mysqlnd --with-mysqli=mysqlnd ,原--with-mysql不再支持

为php提供配置文件
cp php.ini-production /etc/php.ini

编辑apache配置文件httpd.conf,以使apache支持php
vim /etc/httpd24/conf/httpd.conf
1加二行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

2 定位至DirectoryIndex index.html
修改为DirectoryIndex index.php index.html
apachectl restart

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 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
service php-fpm start

配置httpd支持php
vim /app/httpd24/conf/httpd.conf
取消下面两行的注释
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
修改下面行
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
加下面四行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/app/httpd24/htdocs/$1






liubulong 发表于 2019-11-22 20:41:20

666666666666666
页: [1]
查看完整版本: CentOS7编译安装LAMP