Home > Database > Mysql Tutorial > body text

How to install Apache+MySQL+PHP on CentOS6.4

王林
Release: 2023-06-03 10:09:38
forward
1437 people have browsed it

Install mysql

Use the yum command to download the mysql software. The installation requires root permissions. The su command can obtain permissions.

[root@centos6 administrator]# yum install mysql-server
How to install Apache+MySQL+PHP on CentOS6.4

Start the command with the system:
chkconfig –levels 235 mysqld on
Enter below:
/etc/init.d/mysqld start
Command to start the database
How to install Apache+MySQL+PHP on CentOS6.4
How to install Apache+MySQL+PHP on CentOS6.4
Then we set the mysql password
Enter:
mysql_secure_installaution
When enter current password for root appears, we press Enter.
How to install Apache+MySQL+PHP on CentOS6.4
The following appears and press Enter again: set root password? [y/n]
How to install Apache+MySQL+PHP on CentOS6.4
He will appear new password: asking you to enter a new password:
How to install Apache+MySQL+PHP on CentOS6.4
After setting the password, it will appear 4 times for confirmation, just press Enter.
How to install Apache+MySQL+PHP on CentOS6.4

Install apache component
centos has already packaged apache software, which can be installed directly.
Enter the command:

yum install httpdHow to install Apache+MySQL+PHP on CentOS6.4
If "is this ok" appears, enter y and press Enter
How to install Apache+MySQL+PHP on CentOS6.4
The next step is to set it to boot. The command is as follows:
chkconfig –levels 235 httpd on
How to install Apache+MySQL+PHP on CentOS6.4
After completing the above, the command to start apache is as follows:
/etc/init.d/httpd start
How to install Apache+MySQL+PHP on CentOS6.4
At this time, you can already access your server. You can enter the address and port in the browser to check. The apache 2 test page powered by centos will appear, indicating that you are successful. Congratulations! As shown in the picture below, my server has done port mapping so it is port 44444.
How to install Apache+MySQL+PHP on CentOS6.4
Note: The default root directory of apache in centos is /var/www/html, and the configuration file /etc/httpd/conf/httpd.conf. Other configuration is stored in the /etc/httpd/conf.d/ directory. Note that the firewall is turned off or set to allow.

Install php
Enter the following command to install php:

yum install php
How to install Apache+MySQL+PHP on CentOS6.4
Next we restart the apache service:
/etc/ init.d/httpd restart
How to install Apache+MySQL+PHP on CentOS6.4

Next see if php can work
We switch to the root directory of apache/var/www/html/The command is as follows: (ls is to view Commands for files and folders in the directory)

cd /var/www/html
How to install Apache+MySQL+PHP on CentOS6.4
Use vim editor to write a php test file
The command is:
vim info.php
This command creates a file ending in php, then press the "i" key on the keyboard to enter the editing state and write the following content:

<?php phpinfo();

How to install Apache+MySQL+PHP on CentOS6.4

How to install Apache+MySQL+PHP on CentOS6.4
How to install Apache+MySQL+PHP on CentOS6.4
Finally: save and exit wq, use the "ls" command to view the web page file you just wrote. The file named info.php is the file you wrote.
How to install Apache+MySQL+PHP on CentOS6.4
Finally enter in the browser: address file name, for example, my address is: The test diagram is as follows:
How to install Apache+MySQL+PHP on CentOS6.4

php module is associated with mysql
Because php and mysql must be associated together to work properly. Our search module command is as follows:

yum search php
This is the module you searched for as shown below:
How to install Apache+MySQL+PHP on CentOS6.4
How to install Apache+MySQL+PHP on CentOS6.4
The existing module has been found , the next step is to install the relevant modules to take effect. The commands are as follows:
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
How to install Apache+MySQL+PHP on CentOS6.4How to install Apache+MySQL+PHP on CentOS6.4
The module was installed successfully
Now you need to restart the apache service to take effect:
/etc/init.d/httpd restart
How to install Apache+MySQL+PHP on CentOS6.4
Replace the "info.php" you just created Refresh the page, scroll down to find the relevant mysql module, and see if relevant information is detected. As shown below:
How to install Apache+MySQL+PHP on CentOS6.4
The installation of lamp service has been completed.

The above is the detailed content of How to install Apache+MySQL+PHP on CentOS6.4. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!