1. Install apache
Enter the following command in the terminal to install apache:
sudo yum install httpd
sudo means what to do with the root user. Just click y to confirm the download and installation, which is very convenient.
Then use the following command to start the service
sudo service httpd start
Don't worry about it now, just enter the IP address digitalocean gave you in the browser, and you should be able to access the apache welcome page. Something like this:
# Isn’t it cool? If your domain name has been successfully resolved to the IP address of your host, you should be able to access it using your domain name!
2. Install mysql
sudo yum install mysql-server sudo service mysqld start
Use the above command to download and install mysql. The second one means to start the mysql service.
When you install mysql, you will be asked for some simple configurations. Press enter first. The following ones are actually very simple in English. You can choose according to your own needs.
disallow root login remotely? There is an option to allow the root user of mysql to access remotely. I chose no and it can be accessed. This is more convenient, but there are security risks. In this way, the database in this vps can also be used when making software later.
3. Install php and php components
sudo yum install php php-mysql
Use the above command to download and install php. What is more troublesome is the PHP component.
yum install php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
I simply installed 7 components here. You can also search for all PHP components and use the following command
yum search php-
4. Start the apache and mysql services by default after booting up
sudo chkconfig httpd on sudo chkconfig mysqld on
You can use the above two commands to choose to start apache and mysql at boot.
5. Test whether php is installed successfully
sudo nano /var/www/html/info.php
You can use the above commands to create a new info.php file , nano is a simple text editing tool, and vim.
Enter a simple test php command:
<?php phpinfo(); ?>
Then enter ctrl o to save, and click Enter to confirm. Then enter ctrl x to exit.
Then in the browser, enter the IP address plus info.php, you can see the php information! Similar to the picture below:
The above is the detailed content of How to install Apache and Mysql in CentOS6. For more information, please follow other related articles on the PHP Chinese website!