10 tips for PHP scripts (1), 10 tips for reading PHP scripts (1), installing PHP as ApacheDSOPHP is often used together with the ApacheWeb Server for Linux/Unix platforms. When installing PHP in Apache, you have three installation modes available: static module, dynamic module (DSO), and CGI. I suggest you install PHP as Apach and Apache DSO as PHP.
PHP often works with Apache Web servers on Linux/Unix platforms. When installing PHP in Apache, you have three installation modes available: static module, dynamic module (DSO), and CGI.
I suggest you install PHP as Apached DSO, which is easy to maintain and upgrade. For example, assume that you have installed only the database support function of PHP. After a few days, you decided to add the encryption function for PHP. You just need to enter the make clean command, add new configuration options, and then execute the make and make install commands. In this way, the new PHP module will be installed to the proper position on Apache. you only need to restart Apache and everything will be OK. of course, you do not need to re-compile Apache throughout the process.
The simple steps for installing a new version of Apache and installing PHP as Apache DSO are as follows:
1. download the latest Apache server software source code from the Apache Software Foundation site.
2. put the code file in a suitable directory such as/usr/local/or/opt.
3. decompress the code file using the Gunzip command, and then you can get the corresponding *. tar file.
4. type the following decommission command to put the preceding tar file in the directory named apache _ [version:
Tar-xvf apache_{version}.tar
5. enter the/usr/local/apache _ [version] Directory (or the directory you specified in the above step ).
6. type the following configuration command and use the path you set (for example,/usr/local/apache [version]). be careful not to follow the Slash !) Replace the [path] parameter, and enable the mod_so parameter to allow Apache to use DSO.
./Configure -- prefix = [path] -- enable-module = so
7. return to the command prompt line, type the make command, and return to the command prompt state again after the command execution is complete.
8. type make install.
At this time, the compiler can create the final directory and return it to the command prompt state of the system.
Next, install PHP:
1. visit the PHP homepage to download the source code of the latest version.
2. put the downloaded file in a directory such as/usr/local/or/opt.
3. decompress the code file using the Gunzip command, and then you can get the corresponding *. tar file.
4. type the following unpack command to put the above tar file in the directory named php-[version:
Tar-xvf php-[version]
5. go to the/usr/local/php-[version] Directory (or the directory you specified ).
Now you can compile the php dso. In fact, you only need a necessary configuration option -- with-apxs (a file in the Apache bin directory) -- however, to make the system configuration more comprehensive, we have also added support for the MySQL database.
./Configure -- with-mysql =/[path to mysql] -- with-apxs =/[path to apxs]
6. return to the command prompt line, type the make command, and return to the command prompt state after the command execution is complete.
7. type the make install command.
At this time, the compiler will create the final DSO, put it under the Directory of the Apache module, and modify the httpd of Apache for you. in the conf configuration file, the system returns to the command prompt status and waits for you to enter a new command. Then, you can open the httpd. conf configuration file of Apache and make some modifications:
1. find a line with ServerAdmin and add your own email address, as shown below:
ServerAdmin you@yourdomain.com
2. locate a row starting with ServerName and change the following parameter to the actual value, for example:
ServerName localhost
3. find the following section:
# And for PHP 4.x, use:
#
# AddType application/x-httpd-php. php
# AddType application/x-httpd-php-source. phps
Modify these configuration lines to cancel some comments added before AddType in PHP 4.0, and add some file extensions for PHP, the modified rows may look like the following:
# And for PHP 4.x, use:
#
AddType application/x-httpd-php. php. phtml
AddType application/x-httpd-php-source. phps
Save the preceding configuration file and return to the parent directory. run the following command to start Apache:
./Bin/apachectl start
If no problem occurs during startup, you can test the installation of Apache and PHP by creating a file named phpinfo. php, which contains the following code lines:
Save the file and place it in the Apache document root directory (htdocs). Then, start your Web browser and type http: // localhost/phpinfo in the address bar of the browser. php, the browser will display the various variables and variable values of the PHP and Apache systems in a large space.
If you want to reset PHP, you need to execute the make clean command, then execute the./configure command with the new configuration options, and then execute make and make install. In this way, a new module will appear in the Apache module directory. you only need to restart Apache to load the new module. Many headaches have been solved now.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.