PHP entry-installation configuration summary-php Tutorial

Source: Internet
Author: User
PHP entry-installation configuration summary This article draws on the knowledge of various experts and <21 days learning PHP>. it has passed its own verification and is practical. it is recorded here.

The environment in this article is ubuntu 14.04

The installation of. PHP is short for hypertext preprocessor. it is a scripting language and is often used for web development. Therefore, apache mysql is required.

Run sudo apt-get install apache2 mysql-server php5 libapache2-mod-php5

After the installation is complete, the PHP environment is almost a prototype.

The configuration file of apache2 is apache2.conf. in the/etc/apache2 directory, it records which files are loaded when apache2 is started and some basic information.

A commonly used file is a conf file under the/sites-enabled Directory. this file specifies the working path of apache2.

The default value is/var/www/html. you can change it to another path. (however, I tried to modify it, but it didn't work. The reason is not found yet)

During the installation of mysql, you are required to configure some information, including the root password or something. I have already installed it.

After the installation is complete, we can verify whether the installation is successful.

Open the browser and enter localhost. the window shown below is successful.

Verify that php can work.

Create the php suffix file test. php in the html directory and type the following code:

 

Then, enter localhost/test. php in the address bar of the browser to bring up the following interface.

You can also verify whether php can work with mysql normally. create mysql. php in the html directory and add the following code:

 
This code, even if you have never learned php, should be able to understand it. if success is output, it means you can link mysql.

OK. the above is a simple installation and test of php.

Invalid.

This is test php echo
 
In the address bar, what are the effects? why? I checked the materials. it turned out that I didn't add support for php in apache2. some people may be confused. I think it's just not supported by embedded. whatever.

To add support, just add two sentences to httpd. conf:

Php5-script. php. html
AddType text/html. php. html

These two statements are the same, but they are not supported. but the problem arises again. my system is ubuntu and there is no httpd. conf. what should I do?

I transferred an article and referred to it. it turned out to be the case. as mentioned in that article, the configuration file of apache2 should be named apache2.conf strictly. other files must be allowed by this file before they can be loaded.

There are two solutions: put them directly in the apache2.conf file, create an httpd. conf file, and add an Include httpd. conf file to the apache2.conf file.

I am using the second method. solve the problem. you can try it on your own. my running results are as follows:

Amount. encoding problem. The above code has a problem. how can this problem be solved? Easy to handle. just modify the html file. the modified file is as follows:

This is test php echo
     
 
 
Run the code again and it will be normal.

The above is a summary of PHP over the past few days. it basically does not involve a lot of PHP content, but it is related to configuration. but it is difficult to finish the first thing. remember it and save your time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.