(1) Apache installation and configuration ideas: idea cdhttpd-2.2.17.configure -- prefixusrlocalapachemakeinstallservicehttpdsta
(1) Apache installation and configuration ideas: first in the official network to download the apachesource code, the system download license for httpd-2.2.17.tar.gz, the following steps for the terminal configuration command tar zxvf httpd-2.2.17.tar.gz cd httpd-2.2.17. /configure -- prefix =/usr/local/apache make install service httpd sta
(1) installation and configuration of Apache
Idea: first download the apachesource code on the official network, and download httpd-2.2.17.tar.gz in this system. The following steps are the configuration commands on the terminal.
Tar zxvf httpd-2.2.17.tar.gz
Cd httpd-2.2.17
./Configure -- prefix =/usr/local/apache
Make
Make install
Service httpd start
If:
Starting httpd: cocould not reliably determine the server's fully qualified domain name, using 222.31.76.227 for ServerName [OK] |
The installation is successful!
If you want apache to start automatically, run the following command to add the self-starting command in/etc/rc. d/rc. local:
Echo "service httpd start">/etc/rc. d/rc. local
Test Apache
Create an index.html file under the/var/www/html directory
After saving, enter the http://XXX.XXX.XXX.XXX (Web server's IP) on the browser to view the results
Note: iptables must be disabled or port 80 must be added to iptables.
(2) install and configure Mysql-client
Idea: Configure. The following steps are the configuration commands on the terminal (which can be directly pasted)
Tar zxvf mysql-5.5.10-linux2.6-x86_64.tar.gz
Cd/usr/local
Ln-s/home/software/mysql-5.5.10-linux2.6-x86_64 for mysql
Cd mysql/
Vi INSTALL-BINARY
The installation steps are as follows:
To install and use a MySQL binary distribution, the basic command Sequence looks like this: Shell> groupadd mysql Shell> useradd-r-g mysql Shell> cd/usr/local Shell> tar zxvf/path/to/mysql-VERSION-OS.tar.gz Shell> ln-s full-path-to-mysql-VERSION-OS mysql Shell> cd mysql Shell> chown-R mysql. Shell> chgrp-R mysql. Shell> scripts/mysql_install_db -- user = mysql Shell> chown-R root. Shell> chown-R mysql data # Next command is optional Shells> cp support-files/my-medium.cnf/etc/my. cnf Shell> bin/mysqld_safe -- user = mysql & # Next command is optional Shell> cp support-files/mysql. server/etc/init. d/mysql. server // boot automatically (several steps are required later) |
If MYSQL has been installed when the operating system is installed, the first six steps (highlighted) have been completed.
(Note that the data directory stores one database after another. Therefore, you must set the permission to mysql. Otherwise, the configuration will fail if mysql itself does not enter the database)
Chown-R mysql. mysql.
Scripts/mysql_install_db -- user = mysql-- Datadir =/usr/local/mysql/data/
Chown-R root.
Chown-R mysql data
Cp support-files/my-medium.cnf/etc/my. cnf
Bin/mysqld_safe -- user = mysql&
Service mysqld start
If:
Starting MySQL... [OK]
Mysql is enabled successfully!
Use mysql_install_db -- user = mysql to create a new MySQL authorization table. The user is
Run the mysqld server using mysqld_safe -- user = mysql & user_name or user_id. ("User" in this article refers to the Logon account of the system, rather than the MySQL user in the authorization table)
Enable MYSQL to start automatically
Cp support-files/mysql. server/etc/init. d/mysqld
Chmod 700/etc/init. d/mysqld
Chkconfig -- add mysqld
If you encounter the following problems:
An error occurred while starting MYSQL. The prompt is:
Starting mysqld daemon with databases from/usr/local/mysql/data
STOPPING server from pid file/usr/local/mysql/data/xmcncn. pid
061103 15:25:32 mysqld ended
Solution:
Vi/etc/my. cnf
Check if [mysqld] exists.
Port = 3306
Just add it.
Touch/tmp/mysql. sock
Killall-9 mysqld
/Usr/local/mysql/bin/mysqld_safe-user = mysql &
Started successfully
(3) php installation and configuration
First, you may need to install the following packages before installing php:
Download the PHP source code from the official network. The current system downloads the PHP source code as php-5.3.6.tar. The following steps are the configuration commands on the terminal (which can be directly pasted)
Cd/home/software/
Tar-xvf php-5.3.6.tar
Cd php-5.3.6
. /Configure -- prefix =/usr/local/php -- with-apxs2 =/usr/local/apache/bin/apxs -- with-mysql =/usr/local/mysql -- with-openssl- dir =/usr/lib/openssl -- with-openssl
If the License is displayed as follows after configuration, it indicates that the package is successful. If not, the above package may be missing.
... Checking whether-lc shocould be explicitly linked in... no Checking dynamic linker characteristics... GNU/Linux ld. so Checking how to hardcode library paths into programs... immediate Checking whether stripping libraries is possible... yes ... Creating libtool Appending configuration tag "CXX" to libtool Generating files Updating cache./config. cache Creating./config. status ... Creating main/internal_functions.c Creating main/internal_functions_cli.c + Shards + | License: | | This software is subject to the PHP License, available in this | | Distribution in the file LICENSE. By continuing this installation | | Process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | The installation process at this point. | + Shards + Thank you for using PHP. |
Make
Make test // do not do
Make install
Cp php. ini-development/etc/php. ini
Vi/usr/local/apache/conf/httpd. conf
Add one sentence:
AddType application/x-httpd-php. php |
Cd/var/www/html
Vi index. php
The new php test code is as follows:
To restart apache, modify/etc/selinux/config and change SELINUX = enforcing to SELINUX = disabled:
Vi/etc/selinux/config
# This file controls the state of SELinux on the system. # SELINUX = can take one of these three values: # Enforcing-SELinux security policy is enforced. # Permissive-SELinux prints warnings instead of enforcing. # Disabled-SELinux is fully disabled. SELINUX = disabled # SELINUXTYPE = type of policy in use. Possible values are: # Targeted-Only targeted network daemons are protected. # Strict-Full SELinux protection. SELINUXTYPE = targeted |
Service httpd restart
The following statement indicates that the restart is successful:
Stopping httpd: [OK] Starting httpd: cocould not reliably determine the server's fully qualified domain name, using 222.31.76.227 for ServerName [OK] |
Enter http://xxx.xxx.xxx.xxx/index.php in the browser. If phpinfoinfo is displayed, the PHP configuration is successful.
If the phpinfo information is displayed but the database cannot be connected (no MYSQL information is available), the module package connecting php to mysql is not installed successfully, you can try to download the rpm package for installing php-mysql (php-mysql-5.1.6-27.el5.x86_64.rpm), install it first you need to install php-pdo rpm package (php-pdo-5.1.6-27.el5.x86_64.rpm), pdo is dedicated to connecting php and mysql.
If the basic information of phpinfo can be properly displayed during subsequent web configuration and installation, but a module function is missing, you can download the corresponding rpm package and install it separately.
Create a test. php file under/var/www/html to test the remote database connection:
Web2 Echo "Hello World! "; $ Db = mysql_connect ("Remote Server IP", "username", "password") or die ("mysql connected failed! "); Mysql_select_db ("Database Name", $ db ); $ SQL = "select * from users "; $ Result = mysql_fetch_row (mysql_query ($ SQL )); Print_r ($ result ); ?> |