设为首页 收藏本站
查看: 470|回复: 0

[经验分享] php+apache配置环境(英文)(摘)

[复制链接]

尚未签到

发表于 2018-11-28 09:19:34 | 显示全部楼层 |阅读模式
Installing Apache and PHP on Linux/Unix

1. Unzip and untar Apache and PHP:
%>gunzip httpd-2_X_XX.tar.gz
%>tar xvf httpd-2_X_XX.tar
%>gunzip php-XX.tar.gz
%>tar xvf php-XX.tar
2. Configure and build Apache. At a minimum, you’ll want to pass two options. The first
option, --enable-so, tells Apache to enable the ability to load shared modules. The
second, --with-mpm=worker, tells Apache to use a threaded multiprocessing module
known as worker. Based on your particular needs, you might also consider using the
multiprocessing module prefork. See the Apache documentation for more information
regarding this important matter.
%>cd httpd-2_X_XX
%>./configure --enable-so --with-mpm=worker [other options]
%>make
3. Install Apache:
%>make install
4. Configure, build, and install PHP (see the section “Customizing the Unix Build” or
“Customizing the Windows Build,” depending on your operating system, for information
regarding modifying installation defaults and incorporating third-party
extensions into PHP):
%>cd ../php-X_XX
%>./configure --with-apxs2=/usr/local/apache2/bin/apxs [other options]
%>make
%>make install
5. Copy the php.ini-dist file to its default location and rename it php.ini. The php.ini file
contains hundreds of directives that are responsible for tweaking PHP’s behavior. The
later section “Configuration” examines php.ini’s purpose and contents in detail. Note
that you can place this configuration file anywhere you please, but if you choose a nondefault
location, then you also need to configure PHP using the --with-config-filepath
option. Also note that there is another default configuration file at your disposal,
php.ini-recommended. This file sets various nonstandard settings and is intended to
better secure and optimize your installation, although this configuration may not be
fully compatible with some of the legacy applications. Consider using this file in lieu of
php.ini-dist.
%>cp php.ini-recommended /usr/local/lib/php.ini
6. Open the httpd.conf file and verify that the following lines exist. (The httpd.conf file is
located at APACHE_INSTALL_DIR/conf/httpd.conf.) If they don’t exist, go ahead and add them. Consider adding each alongside the other LoadModule and AddType entries,
respectively.
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
Believe it or not, that’s it! Restart the Apache server with the following command:
%>/usr/local/apache2/bin/apachectl restart
Now proceed to the section “Testing Your Installation.”

Installing Apache and PHP on Windows

1. Start the Apache installer by double-clicking the apache_X.X.XX-win32-x86-no_ssl.msi
icon.
2. The installation process begins with a welcome screen. Take a moment to read the
screen and then click Next.
3. The License Agreement is displayed next. Carefully read through the license. Assuming
that you agree with the license stipulations, click Next.
4. A screen containing various items pertinent to the Apache server is displayed next. Take a moment to read through this information and then click Next.
5. You will be prompted for various items pertinent to the server’s operation, including the Network Domain, Server Name, and Administrator’s Email Address. If you know this
information, fill it in now; otherwise, just use localhost for the first two items, and put
in any e-mail address for the last. You can always change this information later in the
httpd.conf file. You’ll also be prompted as to whether Apache should run as a service
for all users or only for the current user. If you want Apache to automatically start with
the operating system, which is recommended, then choose to install Apache as a service for all users. When you’re finished, click Next.
6. You are prompted for a Setup Type: Typical or Custom. Unless there is a specific reason
you don’t want the Apache documentation installed, choose Typical and click Next.
Otherwise, choose Custom, click Next, and, on the next screen, uncheck the Apache
Documentation option.
7. You’re prompted for the Destination folder. By default, this is C:\Program Files\Apache
Group. Consider changing this to C:\, which will create an installation directory
C:\Apache2\. Regardless of what you choose, keep in mind that the latter is used here
for the sake of convention. Click Next.
8. Click Install to complete the installation. That’s it for Apache. Next you’ll install PHP.
9. Unzip the PHP package, placing the contents into C:\php5\. You’re free to choose
any installation directory you please, but avoid choosing a path that contains spaces.
Regardless, the installation directory C:\php5\ will be used throughout this chapter for
consistency.
10. Make the php5ts.dll file available to Apache. This is most easily accomplished simply
by adding the PHP installation directory path to the Windows Path. To do so, navigate to
Start ➤ Settings ➤ Control Panel ➤ System, choose the Advanced tab, and click the
Environment Variables button. In the Environment Variables dialog box, scroll through
the System variables pane until you find Path. Double-click this line and, in the Edit
System Variable dialog box, append C:\php5 to the path
11. Navigate to C:\apache2\conf and open httpd.conf for editing.
12. Add the following three lines to the httpd.conf file. Consider adding them directly
below the block of LoadModule entries located in the bottom of the Global Environment
section.
LoadModule php5_module c:/php5/php5apache2.dll
AddType application/x-httpd-php .php
PHPIniDir "C:\php5"
13. Rename the php.ini-dist file php.ini and save it to the C:\php5 directory. The php.ini
file contains hundreds of directives that are responsible for tweaking PHP’s behavior. The later section “Configuration” examines php.ini’s purpose and contents in detail. Note that you can place this configuration file anywhere you please, but if you choose a nondefault location, then you also need to configure PHP using the --with-config-file-path option. Also note that there is another default configuration file at your disposal,
php.ini-recommended. This file sets various nonstandard settings, and is intended to
better secure and optimize your installation, although this configuration may not be
fully compatible with some of the legacy applications. Consider using this file in lieu
of php.ini-dist.
14. If you’re using Windows NT, 2000, or XP, navigate to Start ➤ Settings ➤ Control Panel ➤Administrative Tools ➤ Services.
15. Locate Apache in the list, and make sure that it is started. If it is not started, highlight the label and click Start the service, located to the left of the label. If it is started, highlight
the label and click Restart the service, so that the changes made to the httpd.conf file
take effect. Next, right-click Apache and choose Properties. Ensure that the startup type
is set to Automatic. If you’re still using Windows 95/98, you need to start Apache manually via the shortcut provided on the Start menu.
Testing Your Installation
The best way to verify your PHP installation is by attempting to execute a PHP script. Open a
text editor and add the following lines to a new file. Then save that file within Apache’s htdocs
directory as phpinfo.php:

Now open a browser and access this file by typing the appropriate URL:
http://localhost/phpinfo.php






运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-640553-1-1.html 上篇帖子: apache自带负载均衡的集群功能 下篇帖子: apache2+mysql5+php5安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表