Centos6.5 and Centos7 PHP Environment building method _php Instance

Source: Internet
Author: User
Tags install php

Some people think that Linux is very complex to build PHP environment, and then try to install LNMP one-click installation package. In fact, is to install a Web server, and then support PHP can be, very simple, compared to the installation of LNMP one-button installation package is also simple. Don't talk big, look at the actual installation steps.

First we look at the next CentOS version information

Copy Code code as follows:

#适用于所有的linux
Lsb_release-a
#或者
Cat/etc/redhat-release
#又或者
Rpm-q Centos-release

CentOS version information can be viewed in any of the above three types.

Here we install each on centos6.5 and CENTOS7, the installation process is only part of the Linux commands are different, for convenience, the installation of Yum, of course, so that the installation of the software version may be due to the problem of Yum source, if you want to install the specified version, we also have the following Said. You can also use the source code to compile the installation, because does not belong to this discussion scope, therefore slightly.

Next we'll install a Web server , and here's an example of installing Apache

Yum Install httpd

After the carriage return can install, the installation process prompts to enter Y to confirm, here enter Y to confirm, you can see the httpd version information that you want to install. So our web server is installed and the whole process is just 10 seconds.

Some small partners may fail during the installation process

You could try-using--skip-broken to work around the problem

This is your Yum source problem, now it is best to replace your yum source, otherwise you installed successfully, most of it is also ineffective. Now that we have the error, we'd better find a way to solve the problem, not to forget it first! can refer to Aliyun server yum source update problem

And then we start Apache manually.

Copy Code code as follows:

#centos7 Start httpd
Apachectl start
#centos6.5 Start httpd
/ETC/INIT.D/HTTPD Start or service httpd start

Now that the Web server is up, does that mean you can access it through the Web? Yes, the browser will open the default page of Apache by accessing your server's IP address directly.

We set up the boot boot httpd service

Copy Code code as follows:

#centos7
Systemctl Enable Httpd.service
#centos 6.* Version
Chkconfig--levels 235 httpd on

then we install PHP5, it's also very simple , a command can

Copy Code code as follows:

Yum Install PHP
#centos7 Restart Apache
Apachectl restart
#centos6 Restart Apache
/ETC/INIT.D/HTTPD Restart or service httpd restart

The above steps, due to the different Yum source, installed PHP version is also different, some of the small partner to install the PHP version estimated only 5.3 5.4 (this is in the process of installing PHP, it is possible to see before y), but this is obviously not what most people want.

If you have clicked Y to confirm the installation, but the version is too low, you can use the following command to uninstall

Copy Code code as follows:

Yum Remove PHP

Let's take a look at installing php5.6 for example, if your yum installed PHP version is high enough or to meet your wishes, this step can be skipped directly.

Copy Code code as follows:

#CentOs 6.x
RPM-UVH http://mirror.webtatic.com/yum/el6/latest.rpm
#CentOs 7.X
RPM-UVH https://mirror.webtatic.com/yum/el7/epel-release.rpm
RPM-UVH https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

And then your PHP and related modules need to be specified like the following installation

Copy Code code as follows:

Yum install php56w php56w-mysql php56w-mbstring php56w-mcrypt php56w-gd php56w-imap php56w-ldap php56w-odbc php56w-pear p Hp56w-xml Php56w-xmlrpc Php56w-pdo



Like our PHP installed well, remember to restart Apache OH

Just install a good PHP environment, you can execute commands to see which modules are installed

Copy Code code as follows:

Php-m

If we forget to install mbstring extensions, we may still need to install the Mbstring extensions manually (actually we've already installed them before, just to illustrate)

Copy Code code as follows:

Yum Install php56w-mbstring
#然后不要忘记重启apache

Finally, we introduce the default installation path of the relevant files

Copy Code code as follows:

#apache主配置文件
/etc/httpd/conf/httpd.conf
#相关配置 such as vhost files can be created in this directory
/etc/httpd/conf.d/
#模块配置文件 For example, if you want to open the rewrite module, you may need to do some configuration under this directory
/etc/httpd/conf.modules.d/
#web可访问目录 Site root directory
/var/www/html
#apache日志文件目录
/var/log/httpd/

The above is a small set to introduce the Centos6.5 and CENTOS7 PHP environment to build the relevant knowledge of the method, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.