LAMP源码包环境安装

软件版本:

	httpd-2.2.17
	mysql-5.2.22
	php-7.2.12

下载链接:百度网盘 -------- 提取码:lnh0

一、 安装Apache

首先关闭防火墙:

  • centos7:systemctl stop firewalld
  • centos7:setenforce 0
  • centos6:service iptables stop
  • centos6:setenforce 0

卸载已安装过的依赖文件,避免冲突:
rpm -e httpd httpd-manual webalizer subversion mod_python mod_ssl mod_perl system-config-httpd php php-cli php-ldap php-common php-mysql mysql-server mysql dovecot –ndeps

	#将下载的安装包都放到opt目录下
	cd /opt
    tar zxf httpd-2.2.17.tar.gz
    cd httpd-2.2.17
    #进行编译
    ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi --with-included-apr
    #编译完成后进行安装
    make && make install
    cd ..
    #配置软连接
    ln -s /usr/local/httpd/bin/* /usr/local/bin/
    cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
    #配置启动文件
    sed -i -e '1a\#chkconfig:345 66 88'  /etc/init.d/httpd
	sed -i -e '2a\#description:http apache' /etc/init.d/httpd
	#给予执行权限,设置开机启动
    chmod +x /etc/init.d/httpd
    chkconfig --add httpd
    chkconfig --list httpd
    sed -i '98s/.*/ServerName localhost:80/' /usr/local/httpd/conf/httpd.conf
    service httpd start
    
	echo '/usr/local/lib' >> /etc/ld.so.conf
	/sbin/ldconfig -v
	killall -9 httpd
	/usr/local/httpd/bin/apachectl start
二、 安装Mysql

Mysql需要cmake来进行编译:
yum -y install cmake
rpm -e mysql-server mysq

	#创建mysql用户组
    groupadd mysql
    useradd -M  -s /sbin/nologin -g mysql mysql
    #进行解压安装
	cd /opt
	tar xf mysql-5.2.22.tar.gz
	cd mysql-5.2.22
	cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all
	make && make install 

Mysql编译报错
1、remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel
解决方法:yum –y install ncurses-devel
重新编译安装

	cd ..
	chown -R mysql:mysql /usr/local/mysql
	rm -rf /etc/my.cnf
	cd /opt/mysql-5.2.22
	cp support-files/my-medium.cnf /etc/my.cnf
	#数据库初始化
	cd /usr/local/mysql
	scripts/mysql_install_db  --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ 
	ln -s /usr/local/mysql/bin/* /usr/local/bin/
	cd /opt/mysql*/support-files
	cp mysql.server /etc/init.d/mysqld
	#配置启动权限+开机启动
	chmod +x /etc/init.d/mysqld
	chkconfig --add mysqld
	killall -9 mysqld &>/dev/null
	service mysqld start
三、安装PHP
#安装所需依赖
	cd /opt
	tar xf libmcrypt-2.*.tar.gz
	cd libmcrypt-*/
	./configure 
	make && make install 
	cd ..
	ln -s /usr/local/lib/libmcrypt.* /usr/lib/ &>/dev/null
	
	cd /opt
	tar xf mhash-*.tar.gz
	cd mhash-*/
	./configure &>/dev/null
	make && make install
	ln -s /usr/local/lib/libmhash* /usr/lib/
	
	cd /opt
	tar xf mcrypt-*.tar.gz
	cd mcrypt-2.*
	ln -s /usr/local/bin/libmcrypt_config /usr/bin/libmcrypt-config 
	export LD_LIBRARY_PATH=/usr/local/lib: LD_LIBRARY_PATH &>/dev/null
	./configure
	make && make install

	cd ..
	yum -y install *ltdl*
	yum -y install libtool libtool-ltdl-devel
	cd /opt
	yum –y install openssl openssl-devel libxml2-devel curl-devel libjpeg-devel libpng libpng-devel  freetype-devel
	tar xf php-7.2.12.tar.gz
	cd php-7.2.12
	./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/httpd/bin/apxs --with-pdo-mysql=/usr/local/mysql --with-openssl --enable-sockets --enable-sysvshm --with- -mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml --with-mhash --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-curl --with-gd --with-gettext --enable-bcmath --enable-opcache
	make && make install 
	cd ..
	cd php-7.2.12
	cp php.ini-development /usr/local/php5/php.ini
	
	#修改php配置
	sed -i '773s/.*/default_charset = "utf-8"/' /usr/local/php5/php.ini
	sed -i '871s/.*/file_uploads = On/' /usr/local/php5/php.ini
	sed -i '880s/.*/upload_max_filesize = 2M/' /usr/local/php5/php.ini
	sed -i '883s/.*/max_file_uploads = 20/' /usr/local/php5/php.ini
	sed -i '728s/.*/post_max_size = 8M/' /usr/local/php5/php.ini
	sed -i '226s/.*/short_open_tag = On/' /usr/local/php5/php.ini
	sed -i '54s/.*/AddType application\/x-httpd-php .php .phtml/' /usr/local/httpd/conf/httpd.conf
	sed -i '169s/.*/DirectoryIndex index.php index.html/' /usr/local/httpd/conf/httpd.conf

	/usr/local/httpd/bin/apachectl restart
#PHP编译报错:
1、configure: error: libxml2 not found. Please check your libxml2 installation
	解决方法: yum install libxml2-devel
2、checking for cURL 7.10.5 or greater... configure: error: cURL version 7.10.5 or later is required to compile php with cURL support
解决方法: yum -y install curl-devel
3、If configure fails try --with-webp-dir=<DIR>configure: error: jpeglib.h not found.
解决方法: yum -y install libjpeg-devel
4、configure: error: png.h not found.
解决方法:yum install libpng libpng-devel
5、configure: error: freetype-config not found.
解决方法: yum install freetype-devel –y
6、configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.
解决方法: yum -y install libicu-devel
7、configure: error: Cannot find ldap.h
解决方法: yum install openldap openldap-devel –y
8、configure: error: Cannot find ldap libraries in /usr/lib
解决方法: cp -frp /usr/lib64/libldap* /usr/lib/
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值