Build lamp environment and install Swoole extensions under Linux

Source: Internet
Author: User
Tags install php php script phpinfo phpmyadmin zend

build lamp environment and install swoole extensions under Linux

First, CentOS 6.5 uses yum to quickly build the LAMP Environment

Preparation: Update First Yum Source

Enter the following command: yum-y Update

1. Installing Apache

[Email protected] ~]# yum-y install httpd

# Boot from Boot

[Email protected] ~]# chkconfig httpd on

# Start httpd Service

[[Email protected] ~]# service httpd start

# # # installs Apache some extensions

[Email protected] ~]# yum-y install httpd-manual mod_ssl mod_perl mod_auth_mysql

now just type http://localhost or HTTP///native IP directly in the browser and you should see the Apache test page

here, you need to pay attention to the iptables settings.

2. Installation configuration MySQL

# MySQL client program

# Mysql-server Service-side program

# Mysql-devel Development and Design Library

[[email protected] ~]# yum-y install MySQL mysql-server mysql-devel

# Boot up

[Email protected] ~]# chkconfig mysqld on

# Start MYSQLD Service

[[Email protected] ~]# service mysqld start

# Make some security configuration

[Email protected] ~]#/usr/bin/mysql_secure_installation

[Email protected] ~]# NETSTAT-TULPN | Grep-i MySQL

TCP 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1723/mysqld

OK, we see that the mysqld is up and listening on port 3306.

3. Install PHP

1) Install the relevant module: In order for PHP to support MySQL, we can install the Php-mysql software package, or you can use the following command to search for available PHP modules

[Email protected] ~]# yum-y install PHP php-mysql

# Install PHP Common extensions

[email protected] ~]# Yum search php

[Email protected] ~]# yum-y install GD php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php- Imap

# # # Restart the httpd service, this step is important

[Email protected] ~]# service httpd restart

we then provide a PHP page to test

[Email protected] ~]# cd/var/www/html/

[Email protected] html]# VI index.php

<?php

Phpinfo ();

?>

then, again, in the browser type http://localhost or http://Native IP, you should see the following page

4. Note: PHP upgrade

The version of PHP that is automatically installed with Yum is older, generally PHP5.3.3 this version, and many PHP extensions are not supported. So we sometimes need to upgrade the PHP version.

4.1 If you have installed the PHP5.3.3 version, you need to uninstall the clean

1) yum-y remove php* #这个命令可以卸载部分, but cleaning is not clean

2) Rpm-qa|grep #php查看相关的php安装组件

3) rpm-e PHP related components #这个命令可以清除所有php安装组件

4.2 No PHP installed, install PHP5.6 directly and configure Yum source

1) Add CentOS 6.5 Epel and Remi Source.

# RPM-UVH http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

# RPM-UVH http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

2) Use the Yum List command to view the installable packages (Packege).

# Yum List--enablerepo=remi--enablerepo=remi-php56 | grep php

installation PHP5.6

3) The Yum source is configured, and the next step is to install PHP5.6.

# yum Install--enablerepo=remi--enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php -phpunit-phpunit Php-pecl-xdebug Php-pecl-xhprof

with PHP command to view the version.

Copy Code

# php--version

PHP 5.6.0 (CLI) (BUILT:SEP 3 2014 19:51:31)

Copyright (c) 1997-2014 the PHP Group

Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies

With Zend Opcache V7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies

With Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans

Copy Code

The version installed here is PHP5.6.0, attentive users may have found Zendguardloader into Zend Opcahe.

5. Installation Configuration phpMyAdmin

in the installation of good Apache, MySQL, PHP, directly download the phpMyAdmin package to the www/html directory, this is more convenient than using Yum to get the source and then install.

1) Download the phpMyAdmin software package in https://www.phpmyadmin.net/downloads/and move the downloaded file to the/var/www/html directory.

Unzip it and rename the extracted directory to phpMyAdmin.

2) switch to the/phpmyadmin directory, edit the config.inc.php file, and change the configuration of the following configuration parameters:

$cfg [' Pmaabsoluteuri ']= ' http://localhost/phpmyadmin ';

Set the value of this parameter to the position where phpMyAdmin is located.

$cfg [' Servers '] [$i] [' host '] = ' localhost ';

Set the host name or IP address where MySQL resides. As 127.0.0.1, this step is important.

$cfg [' Servers '] [$i] [' auth_type '] = ' cookie ';

Set the way to access phpMyAdmin to manage MySQL in three options: config, HTTP, cookie. Config is login by profile, default, without any acknowledgement; HTTP is managed using HTTP login and can be supported under Apache module installation; Cookies are the most common way to manage. Both user names and passwords in the latter two ways are validated directly into the database.

$cfg [' Servers '] [$i] [' user '] = ' root ';

Set up an account to manage MySQL.

$cfg [' Servers '] [$i] [' password '] = ';

Set the password to manage MySQL.

If you want to use a blank password,

put the $cfg in the configuration [' Servers '] [$i] [' allownopassword '] = false;

change to $cfg [' Servers '] [$i] [' allownopassword '] = true;

3) After the setup is complete, save the config.inc.php file. Make sure that MySQL and Apache are in the running state. Open the browser, enter http://localhost/phpmyadmin/in it, will open the phpMyAdmin management interface

two ,CentOS 6.5 under php installation swoole Extensions

1.centos PHP installation Swoole extension

Official website:http://wiki.swoole.com/wiki/index/prid-1

Domestic git Image: Http://git.oschina.net/matyhtf/swoole.git

2. After downloading the source code, unzip, enter the directory

$CD Swoole

$phpize

$./configure

Make && make install

after success, modify php.ini to join extension=swoole.so. Use Php-m or phpinfo () to see if the Swoole extension was loaded successfully.

third,ubuntu16.04 use apt-get quickly build LAMP Environment

Installation Environment: Ubuntu 16.04,apache2.4.18,mysql5.7.12,php7.0.4

1. Install Apache:

1) Enter the command to install

[Email protected]:~$ sudo apt-get install apache2

2) View Apache version:

[Email protected]:~$ apache2-v

Server version:apache/2.4.18 (Ubuntu)

Server built:2016-04-15t18:00:57

above information Description Apache installation successful, Access APACHE:HTTP://127.0.0.1/via browser

sudo vim/etc/apache2/apache2.conf

Will <Directory/var/www/>

Change to <directory "Your catalogue" >

You can copy the default Web page from/var/www to your directory

sudo vim/etc/apache2/sites-available/000-default.conf

Will documentroot/var/www/html

Change to DocumentRoot "Your catalogue"

Sudo/etc/init.d/apache2 restart

Restart

2. Install PHP7:

1) Enter the command to install

[Email protected]:~$ sudo apt-get install php7.0

2) View PHP version: [Email protected]:~$ php7.0-v

PHP 7.0.4-7UBUNTU2 (CLI) (NTS)

Copyright (c) 1997-2016 the PHP Group

Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

With Zend Opcache V7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

above information Description PHP7 installation was successful.

3) Install libapache2-mod-php7.0:

[Email protected]:~$ sudo apt-get install libapache2-mod-php7.0

4) Check to see if the libapache2-mod-php7.0 is installed successfully:

[Email protected]:~$ cat/etc/apache2/mods-enabled/php7.0.load

# CONFLICTS:PHP5

LoadModule php7_module/usr/lib/apache2/modules/libphp7.0.so

The above information indicates that the libapache2-mod-php7.0 installation was successful and PHP7 successfully loaded the module libphp7.0.so

3. Install MySQL:

1) Enter the installation command

[Email protected]:~$ sudo apt-get install Mysql-server

you will be asked to set the root password during installation.

Install Php7.0-mysql:

[Email protected]:~$ sudo apt-get install Php7.0-mysql

2) Restart MySQL:

[Email protected]:~$ sudo service mysql restart

3) Restart Apache:

[Email protected]:~$ sudo service apache2 restart

4) to complete the lamp environment, let's write a PHP script to test whether Apache can parse PHP files: Create a new PHP file, phpinfo.php

[Email protected]:~$ sudo vim/var/www/html/phpinfo.php

Enter the PHP code, save and exit:

<?php

Echo Phpinfo ();

?>

Access using the browser: http://127.0.0.1/phpinfo.php

Build a lamp environment under Linux and install Swoole extensions

Related Article

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.