- 安装Apache:
groupadd -g 222 apache
useradd -u 222 -g apache -s /sbin/nologin -d /var/www/ -M apache
mkdir -p /var/www
chown -R apache:apache /var/www/
cd
wget http://www.us.apache.org/dist/apr/apr-1.5.2.tar.gz
tar zxf apr-1.5.2.tar.gz -C /usr/local/src/
cd /usr/local/src/apr-1.5.2/
CFLAGS="-fPIC -O3" ./configure --prefix=/usr/local/apr
make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install
cd
wget http://www.us.apache.org/dist/apr/apr-util-1.5.4.tar.gz
tar zxf apr-util-1.5.4.tar.gz -C /usr/local/src/
cd /usr/local/src/apr-util-1.5.4/
CFLAGS="-fPIC -O3" ./configure --prefix=/usr/local/apr/ --with-apr=/usr/local/apr/ --with-mysql=/usr/local/mariadb/ --with-openssl=/usr/local/openssl/ --with-expat=/usr/local/ --with-iconv=/usr/local/
make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install
cd
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.16.tar.gz
tar zxf httpd-2.4.16.tar.gz -C /usr/local/src/
cd /usr/local/src/httpd-2.4.16/
CFLAGS="-fPIC -O3" ./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-mime-magic --enable-ssl --enable-session --enable-session-cookie --enable-proxy --enable-cache --enable-cache-disk --enable-cache-socache --enable-buffer --enable-dav --enable-cgi --with-z=/usr/local/lib --with-pcre=/usr/local/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr/ --with-ssl=/usr/local/openssl/ --with-mpm=prefork
make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install
#修改配置文件,开通防火墙端口,启动Apache
sed -i 's/User\ daemon/User\ apache/g' /usr/local/apache/conf/httpd.conf
sed -i 's/Group\ daemon/Group\ apache/g' /usr/local/apache/conf/httpd.conf
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
/usr/local/apache/bin/apachectl start
#添加服务
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
vim /etc/init.d/httpd
###
# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 90 90
# description:http server
###
chmod +x /etc/init.d/httpd
chkconfig --add httpd
chkconfig --level 35 httpd on - 安装CURL,Mcrypt加密库:
cd
wget http://curl.haxx.se/download/curl-7.42.1.tar.gz
tar zxf curl-7.42.1.tar.gz -C /usr/local/src/
cd /usr/local/src/curl-7.42.1/
mkdir -p /usr/local/curl
CFLAGS="-fPIC -O3" ./configure --prefix=/usr/local/curl --enable-optimize --enable-http --enable-ftp --enable-file --enable-rtsp --enable-tftp --enable-libgcc --enable-cookies --with-zlib=/usr/local/ --with-ssl=/usr/local/openssl/
make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install
cd
wget http://ncu.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
tar zxf libmcrypt-2.5.8.tar.gz -C /usr/local/src/
cd /usr/local/src/libmcrypt-2.5.8/
CFLAGS="-fPIC -O3" ./configure
make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install
cd
wget http://ncu.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
tar zxf mhash-0.9.9.9.tar.gz -C /usr/local/src/
cd /usr/local/src/mhash-0.9.9.9/
CFLAGS="-fPIC -O3" ./configure
make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install
cd
wget http://ncu.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
tar zxf mcrypt-2.6.8.tar.gz -C /usr/local/src/
cd /usr/local/src/mcrypt-2.6.8/
ldconfig
CFLAGS="-fPIC -O3" ./configure
make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install - 安装PHP:
yum install -y systemd-devel
#添加Apache的PHP MIME类型
cd
wget http://am1.php.net/distributions/php-5.6.12.tar.xz
tar Jxf php-5.6.12.tar.xz -C /usr/local/src/
cd /usr/local/src/php-5.6.12/
CFLAGS="-fPIC -O3" ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --enable-mod-charset --enable-fpm --with-fpm-user=apache --with-fpm-group=apache --with-fpm-systemd --enable-sigchild --enable-libgcc --with-libxml-dir=/usr/local/libxml2/ --with-openssl=/usr/local/openssl/ --with-pcre-regex=/usr/local/ --with-bz2=/usr/local/ --with-curl=/usr/local/curl/ --enable-xml --enable-exif --enable-ftp --with-gd=/usr/local/gd/ --with-vpx-dir=/usr/local/ --with-jpeg-dir=/usr/local/jpeg9/ --with-png-dir=/usr/local/ --with-zlib-dir=/usr/local/ --with-xpm-dir=/usr/local/ --with-freetype-dir=/usr/local/freetype/ --enable-gd-native-ttf --enable-gd-jis-conv --with-mhash=/usr/local/ --enable-intl --with-mcrypt=/usr/local/ --with-mysql=/usr/local/mariadb/ --with-mysql-sock=/var/lib/mariadb/mysql.sock --with-mysqli=/usr/local/mariadb/bin/mysql_config --enable-embedded-mysqli --with-pdo-mysql=/usr/local/mariadb/ --enable-mysqlnd --with-libedit=/usr/local/ --with-readline=/usr/local/ --enable-mbstring=all --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-libexpat-dir=/usr/local/ --with-iconv-dir=/usr/local/ --with-icu-dir=/usr/local/ --enable-zip --enable-bcmath --enable-inline-optimization --enable-opcache --enable-pcntl --enable-maintainer-zts --with-config-file-path=/usr/local/php5
make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install
cp php.ini-production /usr/local/php5/php.ini
echo 'zend_extension=/usr/local/php5/lib/php/extensions/no-debug-zts-20131226/opcache.so' >> /usr/local/php5/php.ini
vim /usr/local/apache/conf/httpd.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-phps .phps
#设置php-fpm为systemd服务
cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/
cd /usr/local/php5/
cp etc/php-fpm.conf.default etc/php-fpm.conf
sed -i 's/${prefix}/\/usr\/local\/php5/g' /usr/lib/systemd/system/php-fpm.service
sed -i 's/${exec_prefix}/\/usr\/local\/php5/g' /usr/lib/systemd/system/php-fpm.service
systemctl enable php-fpm
systemctl start php-fpm
至此,LAMP环境已全部完成,重启Apache后即可看到新的环境/usr/local/apache/bin/apachectl restart