Home >Backend Development >PHP Tutorial >Let's learn together. PHP we learned together in those years (1)

Let's learn together. PHP we learned together in those years (1)

WBOY
WBOYOriginal
2016-07-29 08:48:141444browse

Since the creation of the PHP language in 1994, it has magically become the preferred language for website design. The release of PHP 4.0 in 2000 undoubtedly injected fresh life blood into it, and it was also respected for its open source mind. Getting started with learning a programming language is nothing more than learning syntax and basic application examples. During this period of time, I will record the PHP process bit by bit, firstly to summarize myself, and secondly to solve the doubts of subsequent learners who encounter the same problem.
 Note-taking is mainly through questions. It will not explore the basics of language bit by bit like a book-based class. Mainly in the basic stage of PHP learning, the problems are foreseen and solved one by one, recorded, and the process of never understanding the solution is recorded. Well that's where the real PHP language begins.
 1): What kind of development environment and development tools does PHP need?
Regarding the PHP language version issue, it is necessary to understand it, but I think it doesn’t matter much. Baidu/google can find these development version issues. If a worker wants to do his job well, he must choose a sharp tool! The first time is to configure the development environment. The development environment I first came into contact with was windows, but this time I am willing to conduct subsequent studies on Linux. Now I will show the deployment of both development environments once.
 2): What are the steps for windows installation? What aspects need to be paid attention to?
The first is windows. Generally, for convenience, you will choose to install a tool suite on windows. Here I use WampServer development. Wamp is the Windows Apache Mysql PHP integrated installation environment, that is, the server software of apache, php and mysql under windows. . Simple one-click installation and deployment of servers, databases, etc. without having to think too much. You can proceed directly to the next step. However, please pay attention to the following points during the installation process:
1. The path where the WampServer program is located cannot contain Chinese characters and spaces.
2. MySQL default username: root, password is empty
3. MySQL database file storage directory: wampbinmysqlmysql5.5.8data
4. Website root directory [HTML, PHP] wampwww
5. Please use http:// to access this machine 127.0.0.1/ (if port 80 is not occupied)
6. Non-default port, the URL is http://127.0.0.1:port/
If an IIS server is installed, port 80 is occupied by default, and the wamp service needs to be changed Internet port number: There is a Listen node of the file httpd.conf in the C:wampbinapacheApache2.2.17conf folder. Modify the port number to 80, or what you need. After modification, restart all services and run them.
Development tools: PHP development tools: Zend Stodio, PHPedit, EditPlus 2, easyeclipse, DW, etc. can all be completed. As an inherited development tool, Zend is easier to use.
 3): Is the installation package deployment environment also in the Linux environment? Is there a graphical management interface?
However, we can still develop PHP on Linux. The development environment I chose here is LAMP (linux+Apache+Mysql+PHP). I used the Ubuntu distribution version as an example to install the development environment. The Apache official website card can download the offline installation package or install it online. It is more convenient to choose online installation here. First use the Ubuntu system and enter the window command (Ctrl+Alt+t)
  Apache installation
Apache, as a powerful Web program, is naturally the first choice for building a Web server. Okay, let's install Apache. Enter the following command in the terminal:
sudo apt-get install apache2
After the installation is completed, you need to start Apache
sudo /etc/init.d/apache2 restart
Enter http://localhost in the browser Or http://127.0.0.1. If you see "It works!", it means that Apache has been successfully installed. The default installation of Apache will create a directory named www under /var. This is the Web Directory, all Web files that need to be accessible through the browser must be placed in this directory.
PHP installation
Installing software under Ubuntu is a very simple matter. It only requires one command. Execute the following command in the terminal:
sudo apt-get install libapache2-mod-php5 php5
After installation , we need to restart Apache and let it load the PHP module:
sudo /etc/init.d/apache2 restart
Next, we create a new PHP file under the Web directory to test whether PHP can run normally, command:
sudo gedit /var/www/phpinfo.php
Then enter:
(Note: Replace bloginfo with phpinfo when using it. Due to server restrictions, the phpinfo function cannot be used)
Then save file, enter http://127.0.0.1/phpinfo.php in the browser. If a page showing PHP running parameters appears, it means that PHP is running normally.
But if the page is not displayed, but you are prompted to download the file, it means that Apaceh has not loaded the PHP module correctly. The solution is to /etc /apache2/apache2.conf or /etc/apache2/mods-enabled Add the following line of command to the /php5.conf file:
AddType application/x-httpd-php .php .phtml .php3
After adding the above command, restart Apaceh with the following command and the problem should be solved:
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 restart
There is a situation where the expected page does not appear. It may be that the folder www does not have appropriate access rights. You can pass sudo chmod +x ./www changes the permissions of the www folder. (Those who are familiar with Linux permission management should know this)
  MySQL installation
sudo apt-get install mysql-server
At the end of the installation, it will ask for the root password. Note that the root password here is not Ubuntu root. The password is the root password you want to set for MySQL. Of course, if you are willing, you can set it to the same password. Because it is mainly used for local testing, MySQL has been installed here. If it is really going to be used as a server, you may need to refer to other settings. As for these settings, I will use them later. written down.
Okay, the installation of the development environment is over, let’s wait to write a program that complies with the rules!

The above has introduced the PHP (1) that we studied together on the Learning Together Network in those years, including the content on the Learning Together Network. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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