您好,登錄后才能下訂單哦!
apache 2.4.18
先安裝apr,apr-util,和pcre
# tar xvf apr-1.5.2.tar.gz
# cd apr-1.5.2
# ./configure --prefix=/usr/local/apr && make && make install
2、安裝apr-util
# tar xvf apr-util-1.5.4.tar.bz2
# cd apr-util-1.5.4
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install
3、安裝pcre
# tar xvf pcre-8.37.tar.bz2
# cd pcre-8.37
# ./configure --prefix=/usr/local/pcre && make && make install
4.安裝httpd
./configure \ --prefix=/usr/local/apache \ --enable-so \ --enable-ssl \ --enable-cgi \ --with-rewrite \ --with-zlib \ --with-pcre=/usr/local/pcre \ --with-apr=/usr/local/apr \ --with-apr-util=/usr/local/apr-util \ --enable-mpms-shared=all \ --with-mpm=prefork \ --enable-proxy \ --enable-proxy-http \ --enable-proxy-ajp \ --enable-proxy-balancer \ --enable-lbmethod-heartbeat \ --enable-heartbeat \ --enable-slotmem-shm \ --enable-slotmem-plain \ --enable-watchdog
上面比較重要的就是指定 幾個路徑,apr,apr-util,pcre
另外一個是,--with-mpm=prefork 以及--enable-so
5、添加PATH環境變量
# cat /etc/profile.d/apache.sh
# export PATH=$PATH:/usr/local/apache/bin
# . /etc/profile.d/apache.sh
6、編輯配置httpd.conf配置文件
# vim /usr/local/apache/conf/httpd.conf
#取消注釋,否則啟動會報下面的錯誤
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
error:
tailf /usr/local/apache/logs/error_log
[Thu Feb 04 10:36:40.825258 2016] [proxy_balancer:emerg] [pid 61695:tid 139808143390464] AH01177: Failed to lookup provider 'shm' for 'slotmem': is mod_slotmem_shm loaded??
[Thu Feb 04 10:36:40.825457 2016] [:emerg] [pid 61695:tid 139808143390464] AH00020: Configuration Failed, exiting
7、編寫啟動腳本,方便開機自啟動
#!/bin/bash # # httpd Startup script for the Apache HTTP Server # # chkconfig: - 85 15 # description: Apache is a World Wide Web server. It is used to serve \ # HTML files and CGI. # processname: httpd # config: /etc/httpd/conf/httpd.conf # config: /etc/sysconfig/httpd # pidfile: /var/run/httpd.pid # Source function library. . /etc/rc.d/init.d/functions if [ -f /etc/sysconfig/httpd ]; then . /etc/sysconfig/httpd fi # Start httpd in the C locale by default. HTTPD_LANG=${HTTPD_LANG-"C"} # This will prevent initlog from swallowing up a pass-phrase prompt if # mod_ssl needs a pass-phrase from the user. INITLOG_ARGS="" # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server # with the thread-based "worker" MPM; BE WARNED that some modules may not # work correctly with a thread-based MPM; notably PHP will refuse to start. # Path to the apachectl script, server binary, and short-form for messages. apachectl=/usr/local/apache/bin/apachectl httpd=${HTTPD-/usr/local/apache/bin/httpd} prog=httpd pidfile=${PIDFILE-/var/run/httpd.pid} lockfile=${LOCKFILE-/var/lock/subsys/httpd} RETVAL=0 start() { echo -n $"Starting $prog: " LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL } stop() { echo -n $"Stopping $prog: " killproc -p ${pidfile} -d 10 $httpd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} } reload() { echo -n $"Reloading $prog: " if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then RETVAL=$? echo $"not reloading due to configuration syntax error" failure $"not reloading $httpd due to configuration syntax error" else killproc -p ${pidfile} $httpd -HUP RETVAL=$? fi echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status -p ${pidfile} $httpd RETVAL=$? ;; restart) stop start ;; condrestart) if [ -f ${pidfile} ] ; then stop start fi ;; reload) reload ;; graceful|help|configtest|fullstatus) $apachectl $@ RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}" exit 1 esac exit $RETVAL
重要的是指定這幾個文件的路徑就OK了,一定要是你安裝的路徑:
apachectl=/usr/local/apache/bin/apachectl httpd=${HTTPD-/usr/local/apache/bin/httpd} prog=httpd pidfile=${PIDFILE-/var/run/httpd.pid}
8.httpd.pid文件
因為自啟動腳本中httpd的pid配置在/var/run/httpd.pid下面,所以還需要修改httpd.conf的配置文件
vim /usr/local/apache/conf/httpd.conf
PidFile "/var/run/httpd.pid"
加完以后,在/var/run/httpd.pid建立一個這個文件,設置好讀寫權限。
然后重啟pc,因為偶爾會有不重啟,無法用service httpd stop關閉httpd進程。
重啟一下就OK了。
httpd到這里結束了
記得檢查httpd.conf里是否有這行:
LoadModule php7_module modules/libphp7.so
=====================================================================
PHP 7的安裝:
安裝openssl組件,否則會報 ssl too old故障
yum -y openssl-devel
2.安裝其他必須組件
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel
3.編譯
./configure \ --prefix=/usr/local/php7 \ --with-config-file-path=/usr/local/php7/etc \ --with-config-file-scan-dir=/usr/local/php7/etc/php.d \ --with-apxs2=/usr/local/apache/bin/apxs \ --with-mcrypt=/usr/include \ --enable-mysqlnd \ --with-mysqli \ --with-pdo-mysql \ --enable-fpm \ --with-gd \ --with-iconv \ --with-zlib \ --enable-xml \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --enable-mbregex \ --enable-exif \ --enable-mbstring \ --enable-ftp \ --enable-gd-native-ttf \ --with-openssl \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-zip \ --enable-soap \ --without-pear \ --with-gettext \ --enable-session \ --with-curl \ --with-jpeg-dir \ --with-freetype-dir \ --enable-opcache \ --disable-fileinfo
比較重要的有這幾個:
(1):必須加,記得檢查/usr/local/apache/bin/有apxs這個文件
--with-apxs2=/usr/local/apache/bin/apxs \
(2):這幾個根據程序員具體需求加上
--enable-exif \ --enable-mbstring \ --with-gd \
然后就是
make && make install了
4.配置文件
進入php源碼的解壓包:
cp php.ini-production /usr/local/php7/etc/php.ini #在源文件目錄下 cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm #在源文件目錄下 cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
5.添加系統變量:
echo -e '\nexport PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH\n' >> /etc/profile && source /etc/profile
設置PHP日志目錄和php-fpm進程文件(php-fpm.sock)目錄:
mkdir -p /var/log/php-fpm/ && mkdir -p /var/run/php-fpm && cd /var/run/ && chown -R nginx:nginx php-fpm
mkdir -p /var/lib/php/session
chown -R nginx:nginx /var/lib/php
6.設置開機啟動
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
7.啟動服務
service php-fpm start
netstat -tlunp看80和9000端口是否開開了。
=================================
整合PHP7和apache
在/usr/local/apache/conf/httpd.conf末尾加上兩行:
AddType application/x-httpd-php .php
PHPIniDir "/usr/local/php7/"
在此處后加上index.php索引文件:
重啟一下apache就OK了。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。