Home >Database >Mysql Tutorial >How to install Apache+MySQL+PHP on CentOS6.4
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
Start the command with the system:
chkconfig –levels 235 mysqld on
Enter below:
/etc/init.d/mysqld start
Command to start the database
Then we set the mysql password
Enter:
mysql_secure_installaution
When enter current password for root appears, we press Enter.
The following appears and press Enter again: set root password? [y/n]
He will appear new password: asking you to enter a new password:
After setting the password, it will appear 4 times for confirmation, just press Enter.
Install apache component
centos has already packaged apache software, which can be installed directly.
Enter the command:
yum install httpd
If "is this ok" appears, enter y and press Enter
The next step is to set it to boot. The command is as follows:
chkconfig –levels 235 httpd on
After completing the above, the command to start apache is as follows:
/etc/init.d/httpd start
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.
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
Next we restart the apache service:
/etc/ init.d/httpd restart
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
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();
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.
Finally enter in the browser: address file name, for example, my address is: The test diagram is as follows:
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:
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
The module was installed successfully
Now you need to restart the apache service to take effect:
/etc/init.d/httpd restart
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:
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!