CentOS6.0 was just released soon. now let's learn how to install Apache2 + PHP5 + MySQL web server on CentOS6.0. 1. important: in this tutorial, the host name is server1.example.com and the IP address is 192.168.0.100. These settings...
CentOS 6.0 was released soon. now let's learn how to install Apache2 + PHP5 + MySQL web server on CentOS 6.0.
1. important:
In this tutorial, the host name is server1.example.com and the IP address is 192.168.0.100. These settings are different from the specific installation settings, so you must replace them during your installation.
2. install MySQL 5.0
Open the terminal and enter:
Yum install mysql-server
Create a system startup link for MySQL (MySQL will automatically start when the system starts) and enter the following command on the terminal:
Chkconfig -- levels 235 mysqld on
/Etc/init. d/mysqld start
Set the password for the MySQL root account:
Mysql_secure_installation
Terminal Display, follow the prompts:
[Root @ server1 ~] # Mysql_secure_installation
NOTE: running all parts of this script is recommended for all MySQL
Servers in production use! Please read each step carefully!
In order to log into MySQL to secure it, we'll need the current
Password for the root user. If you 've just installed MySQL, and
You haven't set the root password yet, the password will be blank,
So you shoshould just press enter here.
Enter current password for root (enter for none ):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
Root user without the proper authorisation.
Set root password? [Y/n] <-enter
New password: <-set a user password
Re-enter new password: <-enter your password again
Password updated successfully!
Reloading privilege tables ..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
To log into MySQL without having to have a user account created
Them. This is intended only for testing, and to make the installation
Go a bit smoother. You shoshould remove them before moving into
Production environment.
Remove anonymous users? [Y/n] <-enter
... Success!
Normally, root shoshould only be allowed to connect from 'localhost'. This
Ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] <-enter
... Success!
By default, MySQL comes with a database named 'test' that anyone can
Access. This is also intended only for testing, and shocould be removed
Before moving into a production environment.
Remove test database and access to it? [Y/n] <-enter
-Dropping test database...
... Success!
-Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
Will take effect immediately.
Reload privilege tables now? [Y/n] <-enter
... Success!
Cleaning up...
All done! If you 've completed all of the above steps, your MySQL
Installation shoshould now be secure.
Thanks for using MySQL!
[Root @ server1 ~] #
3. installed Apache2
Yum install httpd
Configure the system to automatically start apache at startup
Chkconfig -- levels 235 httpd on
Restart apache:
/Etc/init. d/httpd start
In your browser, visit http: // 192.168.0.100. you should see the page of apache2:
In CentOS, the default Apache document root directory is/var/www/html, and the configuration file/etc/httpd/conf/httpd. conf. Other configurations are stored in the/etc/httpd/conf. d/directory.
4. Installing PHP5
We can install the PHP5 and Apache PHP5 modules with the following command:
Yum install php
After the installation is complete, you must restart Apache
/Etc/init. d/httpd restart
5. test PHP5/obtain the installation details of PHP5
The default document root directory/var/www/html for the Web site. Now we will create the PHP probe file (info. php) in this directory and call it in the browser. This file will show a lot of useful details, look at the installation of the php module we installed completed.
Vi/var/www/html/info. php
Open the file in the browser (for example, http: // 192.168.0.100/info. php ):
As you can see, PHP5 works normally. if you continue to scroll down, you will see all modules that have been enabled in PHP5. Without MySQL, this means that we do not have MySQL support modules in php5.
6. add MySQL support in PHP5
Yum search php
Select the modules you need and install them:
Yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc
Restart Apache2 now
/Etc/init. d/httpd restart
7. install phpMyAdmin to manage the database
PhpMyAdmin is a Web interface that allows you to manage your MySQL database.
First, we make sure that the RPMForge software library phpMyAdmin of our CentOS system is the official CentOS 6.0 Library:
Import the GPG Key of rpmforge:
Rpm -- import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
X86_64 system installation command:
Yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
I386 system installation command:
Yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
You can install phpMyAdmin as follows:
Yum install phpmyadmin
Now, we configure phpMyAdmin. Change Apache configuration to connect phpMyAdmin, not just from localhost (comment out allow ):
Vi/etc/httpd/conf. d/phpmyadmin. conf
#
# Web application to manage MySQL
#
#
# Order Deny, Allow
# Deny from all
# Allow from 127.0.0.1
#
Alias/phpmyadmin/usr/share/phpmyadmin
Alias/phpMyAdmin/usr/share/phpmyadmin
Alias/mysqladmin/usr/share/phpmyadmin
Next, we change the authentication cookie in phpMyAdmin, HTTP:
Vi/usr/share/phpmyadmin/config. inc. php
[...]
/* Authentication type */
$ Cfg ['servers'] [$ I] ['auth _ type'] = 'http ';
[...]
Restart Apache:
/Etc/init. d/httpd restart
Then, you can access phpMyAdmin http: // 192.168.0.100/phpmyadmin/to manage the database:
8. Related links
Apache: http://httpd.apache.org/
PHP: http://www.php.net/
MySQL: http://www.mysql.com/
CentOS: http://www.centos.org/
PhpMyAdmin: the http://www.phpmyadmin.net/