2017-01-01
參考
https://secure.php.net/install
https://secure.php.net/manual/en/install.unix.apache2.php
yum -y install apr apr-util pcre apr-devel apr-util-devel pcre-devel gcc libxml2-devel libxml2
cd /usr/local/src
wget http://apache.stu.edu.tw//httpd/httpd-2.4.25.tar.gz
tar xvfz httpd-2.4.25.tar.gz
cd httpd-2.4.25
./configure --enable-so
make
make install
wget http://apache.stu.edu.tw//httpd/httpd-2.4.25.tar.gz
tar xvfz httpd-2.4.25.tar.gz
cd httpd-2.4.25
./configure --enable-so
make
make install
yum -y install gcc libxml2-devel libxml2
cd /usr/local/srcwget http://tw1.php.net/distributions/php-7.1.0.tar.gz
tar zxvf php-7.1.0.tar.gz
cd php-7.1.0/
# 沒安裝 MySQL,不用這個
#./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
# --with-apxs2 才會產生 libphp7.so,不然會找不到libphp7.so
#./configure --with-apxs2
# 如果無法自動找到 apx,就要指定
./configure --with-apxs2=/usr/local/apache2/bin/apxs
make# 如果無法自動找到 apx,就要指定
./configure --with-apxs2=/usr/local/apache2/bin/apxs
#make test
make install
cp -f /usr/local/src/php-7.1.0/php.ini-development /usr/local/lib/php.ini
#cp /usr/local/src/php-7.1.0/php.ini-production /usr/local/lib/php.ini
/usr/local/apache2/conf/httpd.conf 應該會被自動加上下面資訊
LoadModule php7_module modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
找不到libphp7.so 會出現下面訊息
Sorry, I cannot run apxs. Possible reasons follow:
1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
看參數
[root@localhost htdocs]# /usr/local/apache2/bin/apachectl -?
Usage: /usr/local/apache2/bin/httpd [-D name] [-d directory] [-f file]
[-C "directive"] [-c "directive"]
[-k start|restart|graceful|graceful-stop|stop]
[-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X]
Options:
-D name : define a name for use in <IfDefine name> directives
-d directory : specify an alternate initial ServerRoot
-f file : specify an alternate ServerConfigFile
-C "directive" : process directive before reading config files
-c "directive" : process directive after reading config files
-e level : show startup errors of level (see LogLevel)
-E file : log startup errors to file
-v : show version number
-V : show compile settings
-h : list available command line options (this page)
-l : list compiled in modules
-L : list available configuration directives
-t -D DUMP_VHOSTS : show parsed vhost settings
-t -D DUMP_RUN_CFG : show parsed run settings
-S : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG
-t -D DUMP_MODULES : show all loaded modules
-M : a synonym for -t -D DUMP_MODULES
-t -D DUMP_INCLUDES: show all included configuration files
-t : run syntax check for config files
-T : start without DocumentRoot(s) check
-X : debug mode (only one worker, do not detach)
[root@localhost htdocs]#
/usr/local/apache2/bin/apachectl start
下面訊息是說 httpd.conf 中的 ServerName 沒設定,是警告,所以仍可跑
[root@localhost php-7.1.0]# /usr/local/apache2/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
[root@localhost php-7.1.0]#
編輯一個網頁測試
vi /usr/local/apache2/htdocs/phpinfo.php
內容為
<?php
phpinfo();
?>
或
$ echo "<?php phpinfo();" > /var/www/html/info.php
如果不在本機測試,關閉防火牆以便測試
systemctl stop firewalld
PS : 如果不行,試試看
[root@localhost htdocs]# vi /usr/local/lib/php.ini
把
disable_functions =
改成
;disable_functions =
前面加上分號註解
(完)
不好意思…我已經下載了…httpd-2.4.25
回覆刪除但我還是搞不懂要如何去使用appche
我不知道該從何下手…
之前是還有一個msi的執行程式可以使用…
但現在我卻不知道…該怎麼動作…
可以請大大教我一下嗎…
你打的我沒辦法理解…
> 但我還是搞不懂要如何去使用appche
刪除Apache 是 Web Server,用瀏覽器去連
> 之前是還有一個msi的執行程式可以使用…
那是 for Windows 版
可以參考這篇
http://shaurong.blogspot.tw/2016/08/apache-httpd-web-server-windows-2012-r2.html
如果你想輕鬆的在 MS-Windows 上架設 Apache + MySQL + PHP ,有幾種選擇
刪除[研究] AppServ 8.4.0 + HTTPS (SSL) 安裝 (Windows 2012 R2)
http://shaurong.blogspot.tw/2016/08/appserv-840-https-ssl-windows-2012-r2.html
[研究] AppServ 2.5.9 架站軟體安裝 (Win7)
http://shaurong.blogspot.com/2013/10/appserv-259-win7.html
[研究] XAMPP 1.8.2-2 x86 架站軟體安裝 (Win7)
http://shaurong.blogspot.com/2013/10/xampp-182-2-x86-win7.html
[研究] WampServer 2.4 x64 架站軟體安裝 (Win7)
http://shaurong.blogspot.com/2013/10/wampserver-24-x64.html
[研究] Apache + PHP + MySQL 架網站環境安裝 (Win7)
http://shaurong.blogspot.com/2013/10/apache-php-mysql-on-win7.html
如果你是新手,想在 Linux 上架設,可看這篇
刪除[研究] LAMP(Linux, Apache, MariaDB, PHP)+OpenSSL(yum)快速安裝程式(CentOS 7.3)
http://shaurong.blogspot.com/2017/01/lamplinux-apache-mariadb_5.html
謝謝游雲遊子的解釋
回覆刪除我本意是想要手動去安裝最新版本的appche、php、mysql
目前appche最新版本是2.4.25 php 的版本則是7.X.X mysql 則是5.7
而mysql本身就有exe檔了,反而就安裝比較順利…
那對於php的話,是不是就是要等appche安裝後在安裝php即可?
[研究] Apache + PHP + MySQL 架網站環境安裝 (Win7)
刪除http://shaurong.blogspot.tw/2013/10/apache-php-mysql-on-win7.html
[研究] Apache HTTP Web Server 2.4.25 (HTTP + HTTPS/SSL) + PHP 7.1.2 + MySQL 5.7.17 安裝 (Windows Server 2016)
刪除http://shaurong.blogspot.tw/2017/03/apache-http-web-server-2425-php-712_3.html