PHP under Linux

Source: Internet
Author: User
Tags get ip zts nginx server

Because of the stability of the Linux system, most of the PHP servers are deployed on Linux, and like Redis and other extensions in Linux can be better supported, so for PHP programmers, the use of Linux is also very important, Next, I'll summarize my experience of installing Linux from the beginning of Linux.

Linux system Installation

The first is to choose the Linux operating system, I am using cent OS 6.7, it is similar to Red Hat system, easy to contact, and open source free.

CentOS (Community Enterprise Operating System, Chinese means: Community Enterprise operating system) is one of the Linux distributions, it comes from Red Hat Enterprise Linux (Little Red Hat) Compiled from source code released in accordance with open source rules. Because of the same source code, some servers that require a high degree of stability are used with CentOS instead of the commercial version of Red Hat Enterprise Linux. The difference between the two is that CentOS does not contain closed source code software.

Then to prepare a Linux machine, the virtual machine is the best choice, it is easy to install, with on-demand.

Virtual Machine Management I recommend VM Ware Station, installation management is convenient, and powerful. Use a small virtual box, Win7 under the installation to change theme theme files, hard to install the environment for unknown reasons (compatibility problem after troubleshooting, guess is the BIOS setup problem, can refer to) do not open the virtual machine and give up, finally chose the VM, A tutorial on installing Linux under a VM is everywhere, along with a full plate.

Say something to pay attention to: Virtual machine configuration Select " bridge mode ", so that the virtual machine and the host under the same IP segment, can easily access each other under the VM:

Then there are the problems we often encounter network configuration, interaction with the virtual, yum configuration.

Network configuration

Vi/etc/sysconfig/network-scripts/ifcfg-eth0 Modify the following information as required

Device=eth0//NIC Serial numberNAME="System eth0"//Device NameTYPE=ethernet//Device TypeHWADDR=xx: 0C: in: C9:Bayi:D 7//Hardware ID detected by the systemOnboot=yes//whether to run the bootBootproto=static//get IP mode with static (static mode), DHCP (DHCP protocol), none (unspecified)ipaddr=192.168.1.66 //IP AddressNETMASK=255.255.255.0 //Subnet MaskGATEWAY=192.168.1.1//Gateway

After this is configured, if the Linux system has a desktop system, you can directly use the browser to access the extranet. You also need to connect between the host and the virtual machine, you can run the ipconfig command on the cmd command line of Windows to obtain the current IP information, and then you can use the ping command between the host and the virtual machine to test the connection status.

Ping 192.168.1.xxx

Note that the virtual machine may use a firewall to block 80 ports, resulting in virtual function access to themselves, both can ping each other, the virtual machine can also access the host, but the host is unable to access the virtual machine's Web site, by modifying the firewall settings or shutting down the firewall can solve the problem.

 the // Modify the 80 port without masking.  // firewall off

This allows the environment to be configured so that it can be accessed between the host and the virtual machine.

Operating virtual machines in the host environment

Once configured, you can use the tools to solve the problem of switching replication information between VMs and hosts, where I use the Secure CRT to connect the host to the virtual machine.

Once the installation is open, click the Quick Connect button to add a connection operation such as:

Then enter the user password to save.

Also note the encoding problem when using the secure CRT, by default, the Chinese language of the virtual machine is garbled and requires the following configuration:

Then let the virtual machine into the background running state, in the VM interface, click Close the Virtual machine window, will pop up the following menu.

Select Run in the background, so you can use the secure CRT to operate the virtual machine under Windows without having to control the virtual machine window.

Yum Configuration

Yum (full name Yellow dog Updater, Modified) is a shell front end package Manager in Fedora and Redhat and CentOS. Based on RPM package management, the ability to automatically download RPM packages from specified servers and install them automatically handles dependency relationships and installs all dependent packages at once, without the hassle of downloading and installing them over and over again.

Yum is typically installed automatically when the system is installed, and if you are prompted to find a command when using the Yum command, search the Packages folder of the CD for the Yum install package installation.

Before using yum, configure the Yum source first.

To switch to the/etc/yum.repos.d/directory, first back up the original Yum source, and then use the wget command to get a yum source.

cd/etc/Yumrepos.d/mv centos-base.repo centos-Base.repo.bakwget http://  Mirrors.163.com/.help/centos6-base-163.repo

After the configuration we can use Yum to install the required software, with the Yum source to install the necessary libraries and compile software gd gd-devel libxml2-devel gcc gcc-c++ zlib, etc.

Yum installed software will not find the installation directory, you can use the rpm-ql packagename to query the installation address

Next install MySQL Mysql-server install well remember to use mysqladmin-u root password xxxx set the root password

Then use the wget command + address to download the PHP installation package, manually compile PHP to note:

--with-apxs2=/usr/local/apache2/bin/apxs//compiles it to the core of Apache.

--ENABLE-FPM//If an Nginx server is used, this option will generate a standalone PHP process , and in php/sbin/php-fpm, direct execution would result in a PHP process with a port number of 9000.

PHP Add Extension Module

Extension modules are generally divided into two parts: the extension server and the PHP extension.

such as MONGO extension Server is the core of the extension, to be found on their own official website, with the wget command download down, and then unzip the installation, usually the official compiled executable files, directly copied to the target directory.

PHP extension file, is a function library, through the function library and extension server connection and operation of the database, you can go to the official PHP extension warehouse https://pecl.php.net/index.php download extension.

First download the expansion package, and then extract, enter the directory, with Php/bin under the Phpize run (note that PHP with Yum installation, can not find phpize, use yum install Php-devel installed phpize), Generates a configure file.

Re -use./configure--prefix=/usr/local/...–with-php-config=/usr/local/php/bin/php-config Command Compilation

Last Make/make test/make Install

Will get a shape like/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/address, this folder contains our compiled PHP module file xxx.so ( Like the Xxx.dll under Windows)

Then modify the/lib/php.ini file and add the extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/xxx.so to join the module extension.

This simple PHP environment is built.

If you think this blog is helpful to you, you can recommend or follow me, if you have any questions, you can leave a comment under the discussion, thank you.

PHP under Linux

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.