First, install MySQL
Start with the MySQL installation. Open HyperTerminal and enter:
[email protected] ~]# yum install MySQL Mysql-server
The installation is complete so that MySQL can start automatically with the system:
[Email protected] ~]# chkconfig--levels 235 mysqld on [[email protected] ~]#/etc/init.d/mysqld start
To set the password for the MySQL data root account:
[Email protected] ~]# mysql_secure_installation
Press ENTER directly when prompted as follows:
Enter Current password for root
Appear as follows to enter again:
Set root Password? [y/n]
The following prompts you to enter the password you need to set, enter after entering the confirmation:
New Password:
Then there will be four confirmations, namely:
Remove anonymous users? [y/n] Disallow Root login remotely? [y/n] Remove test database and access to it? [y/n] Reload privilege tables now? [y/n]
You can enter directly.
Second, install Apache components
Since CentOS has encapsulated Apache, run the installation directly:
[email protected] ~]# Yum install httpd
Also configure the system to allow Apache to boot with the system:
[Email protected] ~]# chkconfig--levels 235 httpd on
After configuration, start Apache:
[[email protected] ~]#/etc/init.d/httpd start
Now that you have access to your server, you can see the test page "Apache 2 test page powered by CentOS", without any surprises. Note that if the other machine accesses the service and cannot display this page, it can be accessed directly on this server, which is normally forbidden by the CentOS-brought firewall. You only need to enter the firewall, the "WWW" corresponding to the "80" port to open.
Note: The default root directory for Apache in CentOS is/var/www/html, configuration file/etc/httpd/conf/httpd.conf. Other configurations are stored in the/etc/httpd/conf.d/directory.
Third, install PHP
Enter the following command to install PHP:
[[email protected] ~]# Yum install PHP
The Apache service needs to be restarted:
[Email protected] ~]#/etc/init.d/httpd restart
Iv. Testing PHP Related information
This step can actually be omitted, but in order to test whether the installation is successful, you can create a new PHP page to test and create a new one using the VIM editor:
[Email protected] ~]# vi/var/www/html/info.php
Press "I" key to edit, enter:
<?php phpinfo ();?>
After editing, press "ESC" key to exit edit mode, then enter:
: Wq
Then enter, save and exit.
At this point you can access your site address, such as "http://192.168.1.2/info.php", to see if you can see the relevant PHP information.
V. Linking the PHP module with the MySQL module
You also need to associate PHP with MySQL in order to work properly. Search module:
[email protected] ~]# Yum search php
To install the relevant modules:
[email protected] ~]# Yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
The Apache module needs to be restarted to take effect:
[Email protected] ~]#/etc/init.d/httpd restart
Refresh the "info.php" page you just created, and pull down to find the relevant MySQL module to see if the relevant information is detected.
Issue 1: In order for other computers to access, the simple method is to turn off fire before, the use of the command/etc/rc.d/init.d/iptables stop is not recommended
The logical approach is to use the iptables rule, as follows
Closing all INPUT FORWARD OUTPUT is only available on certain ports. Here is the command implementation:
Iptables-p INPUT drop iptables-p FORWARD drop iptables-p OUTPUT Drop
Then use the command iptables-l-N to see if the settings, good-looking to all DROP such a setting, we are only temporary, restart the server or will restore the original not set the state and use the service Iptables save to save to see the information firew The rules of all rules firewall is actually saved in/etc/sysconfig/iptables can open file View Vi/etc/sysconfig/iptables
Reference Blog HTTP://HI.BAIDU.COM/BEIJIQIEYS/ITEM/5EE9BBCF94F0A712B67A24CF
Issue 2:yum The MySQL version installed is 5.1.7, the default Latin character, which needs to be modified to utf-8. VI/ETC/MY.CNF file, add Default-character-set=utf8, as follows
[Mysqld] Datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # disabling symbolic-links is recommended To prevent assorted security risks symbolic-links=0 Default-character-set=utf8 [Mysqld_safe] log-error=/var/log/ Mysqld.log pid-file=/var/run/mysqld/mysqld.pid [MySQL] Default-character-set=utf8
Issue 3: The project uses the MB_SUBSTR function and the SOAP protocol, PHP is not installed by default, yum install php-mbstring and yum install Php-soap, restart APACHE,/ETC/INIT.D/HTTPD Restart
Issue 4: Default Apache points to the/var/www/html directory, if I want to point to/var/www/html/project, modify httpd.conf
vi/etc/httpd/conf/httpd.conf command, find/var/www/html change to/var/www/html/project, restart Apache service,/etc/init.d/httpd restart
Issue 5: Project must have read and write permissions
Using the chmod-r * * command
Installation of apache+mysql+php under CentOS