当前位置: 首页 > 后端技术 > PHP

CentOS7下安装配置LAMP详细教程

时间:2023-03-29 20:39:26 PHP

1、关闭CentOS7防火墙和SELinux1。关闭CentOS7防火墙systemctlstopfirewalld.service#Stopfirewallsystemctldisablefirewalld.service#Forbidfirewalltoboot2.关闭SElinux安全系统vim/etc/selinux/config将SELINUX=enforcing改为SELINUX=disabled重启CentOS2.yuminstallgcc和gcc-c++编译工具yuminstallgccyuminstallgcc-c++3.安装基础软件包1.yuminstallpython-develyum-yinstallpython-devel2.安装XML库libxml2cd/libxml2-2.9.1./configure--prefix=/usr/local/libxml2make&&makeinstall3。安装libmcrypt加密扩展库cd/libmcrypt-2.5.8./configure--prefix=/usr/local/libmcrypt/make&&makeinstall4.安装mhash扩展库cd/mhash-0.9.9.9./configuremake&&makeinstall5.安装mhash扩展库cd/ftp/mcrypt-2.6.8LD_LIBRARY_PATH=/usr/local/libmcrypt/lib:/usr/local/lib./configure--with-libmcrypt-prefix=/usr/local/libmcryptmake&&makeinstall6.安装zlib压缩库cd/zlib-1.2.8./configuremake&&makeinstall7。安装图像处理库libpngcd/libpng-1.5.26./configure--prefix=/usr/local/libpng/make&&makeinstall8。安装图像处理功能库libjpegmkdir/usr/local/jpeg9mkdir/usr/local/jpeg9/binmkdir/usr/local/jpeg9/libmkdir/usr/local/jpeg9/includemkdir-p/usr/local/jpeg6/man/man1cd/jpeg-9./配置--prefix=/usr/local/jpeg6/--enable-shared--enable-staticmake&&makeinstall9.安装freetypecd/freetype-2.6.3./configure--prefix=/usr/local/freetype/make&&makeinstall10。安装GD库cd/libgd-2.1.1vimgd_png.c(修改#include"png.h"为#include"/usr/local/libpng/include/png.h")./configure--prefix=/usr/local/gd2/--with-jpeg=/usr/local/jpeg9/--with-freetype=/usr/local/freetype/--with-png=/usr/local/libpng/make&&makeinstall11.Installcurl库cdcurl-7.48.0./configure--prefix=/usr/local/curlmake&&makeinstall4.安装apache1。在http://httpd.apache.org/downl...2.在http://apr.apache.org/downloa...3。在http://pcre.org/...tar-zxvfapr-1.5.2.tar.gztar-zxvfapr-util-1.5.4.tar.gztar-zxvfhttpd-2.4.18.tar下载pcre-8.38.gzcp-rapr-1.5.2httpd-2.4.18/srclib/aprcp-rapr-util-1.5.4httpd-2.4.18/srclib/apr-utiltar-zxvfpcre-8.38.tar.gzcdpcre-8.38./configuremake&&makeinstall4.安装apaachecd/httpd-2.4.18./configure--prefix=/usr/local/apache2/\--sysconfdir=/usr/local/apache2/etc/\--with-included-apr\--enable-so\--enable-deflate=shared\--enable-expires=shared\--enable-rewrite=sharedmake&&makeinstall5.编译安装mysql1.yuminstallcmake和ncurseslibraryyum-yinstallncurses-develyum-yinstallcmakebison2。创建mysql系统用户groupaddmysqluseradd-r-gmysqlmysql3。在http://www.boost.org/downloadboost...tar-zvxfboost_1_59_0.tar.gzmkdir/usr/local/boostcp-rf./boost_1_59_0/usr/local/boost4.cmake编译安装mysqlcmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\-DMYSQL_UNIX_ADDR=/tmp/mysql.sock\-DDEFAULT_CHARSET=utf8\-DDEFAULT_COLLATION=utf8_general_ci\-DWITH_BOOST=/usr/local/boost\-DWITH_MYISAM_STORAGE_ENGINE=1\-DWITH_INNOBASE_STORAGE_ENGINE=1\-DWITH_MEMORY_S1\-DWITH_READLINE=1\-DENABLED_LOCAL_INFILE=1\-DMYSQL_DATADIR=/var/mysql/data\-DMYSQL_USER=mysql\-DMYSQL_TCP_PORT=3306make&&makeinstall5.mysql目录权限配置和初始化cd/usr/local/mysqlmkdir-p/var/mysql/data./bin/mysqld--初始化\--user=mysql\--datadir=/var/mysql/data\--basedir=/usr/local/mysql\--socket=/tmp/mysql.sockcp/usr/local/mysql/support-files/my-default.cnf/etc/my.cnfvim/etc/my.cnfadd:port=3306basedir=/usr/local/mysqldatadir=/var/mysql/datasocket=/tmp/mysql.socklog-error=/var/log/mysql-error.log#启动mysql修改密码/usr/local/mysql/bin/mysqld_safe--user=mysql&/usr/local/mysql/bin/mysql--user=root--password=初始密码setpassword=password('123456');6.编译安装PHPyuminstallopensslopenssl-develyuminstalllibXpm-devel1.rpm-qllibXpm:查询libXpm的安装位置,在/usr/lib64/下找到2.重新编译php,加入--with-xpm-dir=/usr/lib64/cdphp-7.0.4./configure--prefix=/usr/local/php/\--with-in./configureconfig-file-path=/usr/local/php/etc/\--with-apxs2=/usr/local/apache2/bin/apxs\--with-libxml-dir=/usr/local/libxml2/\--with-jpeg-dir=/usr/local/jpeg9/\--with-png-dir=/usr/local/libpng/\--with-freetype-dir=/usr/local/freetype/\--with-gd=/usr/local/gd2/\--with-mcrypt=/usr/local/libmcrypt/\--enable-soap\--with-xpm-dir=/usr/lib64/\--with-curl=/usr/local/curl\--with-openssl\--enable-mbstring=all\--enable-sockets\--enable-mysqlnd\--with-mysqli=mysqlnd\--with-pdo-mysql=mysqlnd\--with-zlib\--enable-ftpmake&&makeinstallcpphp.ini-production/usr/local/php/etc/php.inivim/usr/local/apache2/etc/httpd.conf#修改apache配置文件AddTypeapplication/x-httpd-php.php.phtml.phps/usr/local/apache2/bin/apachectlstart