CentOS is based on the distribution of Yum, Package Manager is a management software, Linux each release will maintain a own software warehouse, there are many software, you can choose from the inside of the software installation, which all only need to use the command can be done, in fact, it is very convenient. Lamp is a set of Web server environments consisting of Linux + apache + mysql + PHP.
In the Linux environment, a lot of software almost all the software can be compiled source installation, but this relatively troublesome, this blog is only a very shallow introduction, so do not install through the source code, directly through the installation of the source repository of Yum binary installation package. The following is the installation of the software we need to install the following commands:
installinstallinstallinstallinstall mongodb mongodb-server
The installation is basically done with the above commands, but the environment is not comprehensive enough to be configured, and there are several other common extensions that need to be installed. PHP-GD is the PHP processing graphics extension Library, the GD library provides a series of APIs for processing pictures, using the GD library can process pictures, or create pictures. Php-redis is an extension library that uses PHP to access the Redis database. Similarly, Php-mongo is an extension that supports PHP access to the MONGO database.
yum search php-gdyum install php-gd.x86_64yum search redisyum install php-redis.x86_64yum search mongoyum install php-pecl-mongo.x86_64
Start or restart the server with the following command, start means start or stop and restart.
start/etc/init.d/mysqld start
Installation of the environment, but also need a general understanding of the configuration of Apache, Apache configuration, if it is installed in this way, it should be/etc/httpd.conf. You can modify the configuration of the server by editing this file. In the Web directory, write a PHP script, hello.php.
Similarly, PHP also has a configuration file, in this way to install PHP, configuration files in/etc/php.ini, sometimes need to modify the configuration, edit this file can be no longer described here.
<?phpinfo();?>
You can see the following content, if you do not install these extensions, there will be no gd,redis,mongo these modules, in this page to search for extended keywords, if successful, there will be a redis corresponding table description, and the following redis similar. After installing these extensions, you will need to restart the server before you can see them here.
Here's a simple example of using PHP to access Redis and MONGO
PHP Redis Sample
<?php $redisnew Redis(); $redis->connect(‘127.0.0.1‘6379); echo"Connection ok"; $redis->set("tutorial-name""Redis");?>
PHP Mongo Example
<?php$server="192.168.190.123";$conn=NewMongodb ($server);$conn->selectdb ("Yourdb");$ret=$conn->update ("Your_collections",Array(' user_id '=$user _id),Array(' $set '=Array(' status '=1)));Echo $ret?>
For more usage, please read the official documentation!
CentOS Lamp Setup