Home > Article > Backend Development > Tutorial on installing apache and php_PHP under linux
1.apache(Unix平台最流行的WEB服务器平台)
在如下页面下载apache(Unix平台最流行的WEB服务器平台)的for Linux 的源码包
http://www.apache(Unix平台最流行的WEB服务器平台).org/dist/httpd/;
存至/home/xx目录,xx是自建文件夹,我建了一个wj的文件夹。
命令列表:
cd /home/wj
tar -zxvf httpd-2.0.54.tar.gz
mv httpd-2.0.54 apache(Unix平台最流行的WEB服务器平台)
cd apache(Unix平台最流行的WEB服务器平台)
./configure --prefix=/usr/local/apache(Unix平台最流行的WEB服务器平台)2 --enable-module=so
make
make install
安装apache(Unix平台最流行的WEB服务器平台)至/usr/local/apache(Unix平台最流行的WEB服务器平台) 并配置apache(Unix平台最流行的WEB服务器平台)支持dso方式
2.php(做为现在的主流开发语言)
在如下页面下载php(做为现在的主流开发语言)的for Linux 的源码包
http://www.php(做为现在的主流开发语言).net/downloads.php(做为现在的主流开发语言) ;
存至/home/wj目录
命令列表:
cd /home/wj
tar -zxvf php(做为现在的主流开发语言)-5.0.4.tar.gz
mv php(做为现在的主流开发语言)-5.0.4 php(做为现在的主流开发语言)
cd php(做为现在的主流开发语言)
./configure --prefix=/usr/local/php(做为现在的主流开发语言)5 --with-apxs2=/usr/local/apache(Unix平台最流行的WEB服务器平台)2/bin/apxs --with-config-file-path=/usr/local/lib --enable-track-vars --with-xml(标准化越来越近了) --with-MySQL(和PHP搭配之最佳组合)
make
make install
其中apache(Unix平台最流行的WEB服务器平台)和MySQL(和PHP搭配之最佳组合)是根据你安装的目录名变,我的是 =/usr/local/apache(Unix平台最流行的WEB服务器平台)2/bin/apxs 和MySQL(和PHP搭配之最佳组合)
cp php(做为现在的主流开发语言).ini-dist /usr/local/lib/php(做为现在的主流开发语言).ini
以dso方式安装php(做为现在的主流开发语言)至/usr/local/php(做为现在的主流开发语言) 设置配置文件目录为/usr/local/lib 开启MySQL(和PHP搭配之最佳组合),xml(标准化越来越近了)支持
3.配置
vi /usr/local/apache(Unix平台最流行的WEB服务器平台)/conf/httpd.conf
对apache(Unix平台最流行的WEB服务器平台)做如下配置
#将ServerAdmin mailto:linux@linuxidc.com一行改为您的邮箱地址
#DocumentRoot "/home/httpd/html/" This is the main directory of html files
# Same as above
#Options FollowSymLinks MultiViews For security reasons, remove "Indexes"
#
# DirectoryIndex default.php(as the current mainstream development language) default.phtml default.php(as the current mainstream development language)3 default.html default.htm
#
#Set the default file name order of apache(the most popular WEB server platform on Unix platform)
#AddType application/x-httpd-php(as the current mainstream development language ) .php(as the current mainstream development language) .phtml .php(as the current mainstream development language)3 .inc
#AddType application/ x-httpd-php(as the current mainstream development language)-source .php(as the current mainstream development language)s
#Set php( As the current mainstream development language) File suffix
Save and exit
vi /usr/local/lib/php (As the current mainstream development language) .ini
#register-golbals = On
Save and exit
4. Start the service
/usr/local/apache (the most popular WEB server platform on Unix platform) /bin/apache (The most popular WEB server platform on Unix platform) ctl start
5. Test
and then write php (as the current mainstream development language) test page info. php(as the current mainstream development language): The content is as follows
〈?php(as the current mainstream development language)
php(as The current mainstream development language)info();
?>
If normal, you should be able to see the information of php(as the current mainstream development language), congratulations Your Apche+MySQL(the best combination with PHP)+php(as the current mainstream development language) is successfully installed.
6. apache (the most popular WEB server platform on the Unix platform) automatically starts - -
Use self-starting apache below (the most popular WEB server platform on the Unix platform) For example;
Self-starting script:
/usr/local/apache(The most popular WEB server platform on Unix platform)/bin/apache(The most popular WEB server platform on Unix platform Platform) ctl start
file is located under /etc/rc.d/init.d, named apache (the most popular WEB server platform on Unix platform) d, please note that it must be executable.
#chmod +x /etc/rc.d/init.d/apache(The most popular WEB server platform on Unix platform)d //Set the file attribute to executable
#ln -s /etc/rc.d/init.d/apache(The most popular WEB server platform on Unix platform)d /etc/rc3.d/S90apache(The most popular WEB server platform on Unix platform) Platform) //Establish soft connection, shortcut
#ln -s /etc/rc.d/init.d/apache(The most popular WEB server platform on Unix platform)d / etc/rc0.d/K20apache(The most popular WEB server platform on Unix platform)