Install the lamp environment under CENTOS7

Source: Internet
Author: User
Tags mysql host wordpress database myadmin

(1) Configuration summary:
1, 172.16.100.31 host running httpd+php Service (PHP for module operation mode)
Configure two virtual hosts: WordPress personal blog system, phpMyAdmin remote control MySQL

2, 172.16.100.31 host running MARIADB service (MySQL)

(2) configuration process:
First configure the 172.16.100.31 host: HTTP Service
1. Installation program:
[[email protected] ' s Linux ~]# yum install httpd php php-mysql php-mbstring

========================================================================================
Package Arch Version Repository Size
========================================================================================
Installing:
httpd x86_64 2.4.6-40.el7. CentOS Base 2.7 M
PHP x86_64 5.4.16-36.el7_1 Base 1.4 M
Php-mbstring x86_64 5.4.16-36.el7_1 base 503 K
Php-mysql x86_64 5.4.16-36.el7_1 Base (k)

Transaction Summary
=======================================================================================

HTTPD: Providing Web Services
PHP: Modules that are automatically compiled to httpd after installation for handling dynamic resource PHP scripts
Php-mbstring: This package is required for phpMyAdmin remote control of MySQL
php-mysql:php Drive MySQL Library file package

2. Service Configuration

After the package is installed, proceed to the next configuration phase:

(1) Add Virtual Host: (FQDN-based)
Virtual host has three kinds of configuration: one is based on different IP, the same port (80), the second is the same IP different ports, three is the same IP different host name (FQDN), regardless of the configuration method, finally resolved to the host only one, but in the request message header information will be different! Below, only the FQDN-based configuration is demonstrated

Edit:/etc/httpd/conf.d/vhost1.conf File
[email protected] ' s Linux ~]# vim/etc/httpd/conf.d/vhost1.conf

[email protected] ' s Linux ~]# vim/etc/httpd/conf.d/vhost2.conf
# Add the following content, FQDN-based virtual host configuration
<virtualhost 172.16.100.31:80> # Fixed Syntax <virtualhost ip:port> can be ignored case
ServerName Www1.wufeng.com # It is important that the FQDN-based virtual host must have a host name
DocumentRoot "/DATA/VHOST/WWW1" # Virtual host root, can specify path

Customlog Logs/www1-access_log Combined #Specifies the log file path andname
<directory "/DATA/VHOST/WWW1" > # Permissions settings for the virtual host root directory
Options None
AllowOverride None
Require all granted # Directory permission settings
</Directory>
</VirtualHost>

<virtualhost 172.16.100.31:80>
ServerName www2.wufeng.com
DocumentRoot "/DATA/VHOST/WWW2"
Customlog Logs/www2-access_log combined
<directory "/DATA/VHOST/WWW2" >
Options None
AllowOverride None
Require all granted
</Directory>
</VirtualHost>

Options: As a directory option, you can specify multiple attributes
For example, index, which launches the resource index, is the function of returning the Web resource index when the user accesses the specified URL, this option
Very dangerous, not recommended to enable, otherwise the source code will be exposed to the Web source, the consequences are very serious

Access permission settings:
Require all Granted/deny, granted is allowed, all means all, deny means Deny
Note that CentOS7 is a resource that denies all hosts access to DocumentRoot by default, so configuring a virtual host must be configured with this first parameter

(2) Create a resource directory defined in the configuration file for the virtual host and
[[email protected] ' s Linux ~]# mkdir-pv/data/vhost/www{1,2}

(3) Add test resource
[[[email protected] ' s Linux ~]# vim/data/vhost/www1/index.php
# Earlier this is PHP code that tests PHP connectivity with MySQL
<?php
    $conn = mysql_connect (' 172.16.100.31 ', ' admin ', ' admin '); # IP fill in MySQL host IP
    If $conn                                           # User for MySQL authorized user, password null
        echo "DATABASE connet OK";
    Else
        echo "DATABASE connet Failure";
?>
# PHP code to test if PHP is working correctly
<?php
    phpinfo () #此函数调用会显示php的详细信息
;

(4) Configuring the httpd master configuration file
Editor:/etc/httpd/conf/httpd.conf
[email protected] ' s Linux ~]# vim/etc/httpd/conf/httpd.conf
# Find DocumentRoot "/var/www/html", #将其注释掉, general use of virtual machines are commented out, to avoid conflicts
#DocumentRoot "/var/www/html"

# Add PHP Home page index
DirectoryIndex index.php index.html # adds index.php to the front so that the index of such resources is accessed by default

# Cancel Server name Comment

(5) Start the service, test whether it is normal
# Detect configuration file syntax with no errors
[email protected] ' s Linux ~]# httpd-t
# syntax error start service
[[email protected] ' s Linux ~]# systemctl start Httpd.service

Open Web page to see if the service is working



HTTP service test is OK, PHP module also works, but MySQL connection is failed because we also MySQL server has not been configured



(5) Get WordPress and phpMyAdmin
Wo is downloaded from the FTP server in the LAN
WordPress configuration:

# download and unzip to/DATA/VHOST/WWW1
# CD to wordpress directory, config file as follows
[[email protected] ' s Linux wordpress]# ls
index.php wp-blog-header.php wp-cron.php wp-mail.php
License.txt wp-comments-post.php wp-includes wp-settings.php
Readme.html wp-links-opml.php wp-signup.php
wp-activate.php wp-config-sample.php wp-load.php wp-trackback.php
Wp-admin wp-content wp-login.php xmlrpc.php

# Copy config file above wp-config-sample.php to wp-config.php
[[email protected] ' s Linux wordpress]# cp wp-config-sample.php wp-config.php

# Edit configuration file
[[email protected] ' s Linux wordpress]# vim wp-config.php
* * MySQL Settings-specific information from the host you are using * *//
/** Name of WordPress database */
Define (' db_name ', ' wpdb '); # This fills in the name of the database to be authorized by MySQL (will be configured later)

/** MySQL Database user name */

Define (' Db_user ', ' wpuser '); # Fill in the database user name

/** MySQL Database password */
Define (' Db_password ', ' wppasswd '); # Fill in the data password

/** MySQL Host */
Define (' Db_host ', ' 172.16.100.31 '); # Fill in the MySQL host's IP

/** The default text encoding when creating data tables */
Define (' Db_charset ', ' UTF8 ');

/** the database collation type. If you are unsure do not change */
Define (' db_collate ', ');


phpMyAdmin configuration:
phpmyadmin-4.4.14.1-all-languages.zip# download and unzip the package to/DATA/VHOST/WWW1
# CD to file directory
# Create a symbolic connection
[[email protected] ' s Linux htdoc]# ln-s phpmyadmin-4.4.14.1-all-languages myadmin
[[email protected] ' s Linux htdoc]# ls
index.php phpmyadmin-4.4.14.1-all-languages
MyAdmin Phpmyadmin-4.4.14.1-all-languages.zip

#cd to MyAdmin directory, modify the configuration file
[[email protected] ' s Linux htdoc]# cp config.sample.inc.php config.inc.php

#编辑配置文件
[[email protected] ' s Linux htdoc]# vim config.inc.php
$cfg [' blowfish_secret '] = ' o71mi9rimj6syc00ft3g '; /* Must FILL in the this for COOKIE auth! */
#单引号填写随机密码, can be generated using OpenSSL rand-base64 15 (password length)

#can also be generated with MD5: r! echo admin | md5sum

/*
* Servers Configuration
*/
$i = 0;

/*
* First Server
*/
$i + +;
/* Authentication type */
$cfg [' Servers '] [$i] [' auth_type '] = ' cookie ';
/* Server Parameters */
$cfg [' Servers '] [$i] [' host '] = ' 172.16.100.31 '; # Database Host IP
$cfg [' Servers '] [$i] [' connect_type '] = ' TCP ';
$cfg [' Servers '] [$i] [' compress '] = false;
$cfg [' Servers '] [$i] [' allownopassword '] = false;

--------------------------------------------------------------------------------
172.16.100.31 Host configuration: MySQL Service

(1) Yum installation program
[[email protected] ' s Linux ~]# yum install Mariadb-server

========================================================================================
Installing:
Mariadb-server x86_64 1:5.5.44-2.el7.centos Base One M
Installing for dependencies:
MARIADB x86_64 1:5.5.44-2.el7.centos Base 8.9 M
Perl-compress-raw-bzip2 x86_64 2.061-3.el7 Base K
Perl-compress-raw-zlib x86_64 1:2.061-4.el7 Base, K
Perl-dbd-mysql x86_64 4.023-5.el7 Base K
PERL-DBI x86_64 1.627-4.EL7 Base 802 k
Perl-io-compress Noarch 2.061-2.EL7 Base 260 k
Perl-net-daemon Noarch 0.48-5.el7 base Wuyi K
Perl-plrpc Noarch 0.2020-14.el7 Base K

Transaction Summary
========================================================================================

A big push depends on the package, as long as there is yum in and the Yum source configuration is not a problem, you can easily resolve

(2) Start the service and perform a secure installation operation
[[email protected] ' s Linux ~]# systemctl start mariadb
# Viewing the listening port, 3306 is the default listening port for MARIADB
[email protected] ' s Linux ~]# ss-tnl
State recv-q send-q Local address:port Peer address:port
LISTEN 0 *:3306 *:*
LISTEN 0 *:22 *:*
LISTEN 0::: $:::*

Perform a secure installation operation
[email protected] ' s Linux ~]# mysql_secure_installation

Setting The root password ensures that nobody can log into the MariaDB
Root user without the proper authorisation.

Set root Password? [y/n] Y # Set Admin login Secret (this password and Linux system root is OK)

New Password:
Re-enter new Password: # Enter your password
Password Updated successfully!
Reloading privilege tables.
... success!

Remove anonymous users? [y/n] Y # Whether to remove anonymous users (no password login required before performing a secure installation)
...                    success! # Allow anonymous login is dangerous, it is recommended to remove

Disallow Root login remotely? [y/n] n # Whether the Administrator account is not allowed to log on remotely, generally recommended not allowed
... skipping.

Remove test database and access to it? [y/n] Y # Remove test database
-Dropping test database ...
... success!
-Removing privileges on test database ...
... success!

Reloading the privilege tables would ensure that all changes made so far
would take effect immediately.

Reload privilege tables now? [y/n] Y # Overloaded Permissions table
... success!

Cleaning up ...

All done! If you ' ve completed all of the above steps, your MariaDB
Installation should now is secure.

Thanks for using mariadb!

It is highly recommended that you perform a secure installation operation after the MARIADB installation, which makes the database more secure



(3) Create the required database and authorize

[email protected] ' s Linux ~]# mysql-uroot-p
Enter Password:
Welcome to the MariaDB Monitor. Commands End With; or \g.
Your MariaDB Connection ID is 66
Server VERSION:5.5.44-MARIADB MariaDB Server

Copyright (c), Oracle, MariaDB Corporation Ab and others.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

MariaDB [(None)]> CREATE DATABASE wpdb; # Create a WordPress database
Query OK, 1 row affected (0.02 sec)

# Licensed WordPress Database

# Create Data name

MariaDB [(None)]> GRANT all on wpdb.* to ' wpuser ' @ ' 172.16.%.% ' identified by ' wppass ';

and build this database.

MariaDB [(None)]> CREATE DATABASE wpdb;


(4) Support all Configurations basic complete: Verification results
1. Verifying Database Connectivity

2, check whether WordPress is normal



Finally, add:
phpMyAdmin Common errors:
1. Missing mbstring Plugin
Yum installation php-mbstring can be

2. Missing Session Directory
Generally in/var/lib/php/session, no then create


This article is from the "11332618" blog, please be sure to keep this source http://11342618.blog.51cto.com/11332618/1826507

Install the lamp environment under CENTOS7

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.