This article describes how to install PHP for Apache on Linux (Fedora 12).
Step 1: Install PHP run the following command as root:
# yum install php
Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package php.i686 0:5.3.2-1.fc12 set to be updated --> Processing Dependency: php-cli = 5.3.2-1.fc12 for package: php-5.3.2-1.fc12.i686 --> Processing Dependency: php-common = 5.3.2-1.fc12 for package: php-5.3.2-1.fc12.i686 --> Running transaction check ---> Package php-cli.i686 0:5.3.2-1.fc12 set to be updated ---> Package php-common.i686 0:5.3.2-1.fc12 set to be updated --> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================ Package Arch Version Repository Size ============================================================================================================================ Installing: php i686 5.3.2-1.fc12 updates 1.1 M Installing for dependencies: php-cli i686 5.3.2-1.fc12 updates 2.2 M php-common i686 5.3.2-1.fc12 updates 515 k
Transaction Summary ============================================================================================================================ Install 3 Package(s) Upgrade 0 Package(s)
Total download size: 3.8 M Is this ok [y/N]: y
Step 2: create a php page go to the "html" directory (default is /var/www/html): # cd /var/www/html/
and open a new file called "test.php" # vi test.php
write the following PHP code into that file and save & close the file with ":wq" <?php
Print "Hello, World! from php";
?>
Step 3: restart apache # service httpd restart Now open a browser window and go to "http://localhost/test.php" or "http://127.0.0.1/test.php" or whatever your URL is. SELinuxIf You have SELinux enabled you have to make sure the security context of your new file is "httpd_sys_content_t". run "ls -laZ" to check the security context: # ls -laZ /var/www/html/test.php -rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t test.php
If it is NOT httpd_sys_content_t you can restore the context with restorecon: # restorecon /var/www/html/test.php
|