Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CentOS7LAMP deployment proc

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

(1) configuration summary:

1. 172.18.17.7 the host runs the httpd+php service (php is the module working mode)

Configure two virtual hosts: wordpress personal blog system and PHPmyadmin remote control mysql

2. 172.18.17.8 the host runs the mariadb service (mysql)

(2) configuration process:

First configure 172.18.17.7 host: http service

1. Installer:

[root@johnson'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.7m php x86 / 64 5.4.16-36.el7_1 Base 1.4m php-mbstring x86164 5.4.16-36.el7_1 base 503k php-mysql x86165.4.16-36.el7_1 base 99 kTransaction Summary=

Httpd: provide web services

Php: a module that is automatically compiled to httpd after installation, and is used to handle dynamic resource php scripts

Php-mbstring: this package is necessary for phpMyAdmin to remotely control mysql

Library file package for php-mysql:php driver mysql

2. Service configuration

After the packages have been installed, proceed to the next configuration stage:

(1) add virtual hosts: (based on FQDN)

Virtual hosts can be configured in three ways: one is based on different ip, the same port (80), the second is different ports of the same IP, and the third is different host name (FQDN) of the same IP. No matter which configuration method, there is only one host parsed at last, but the information in the first part of the request message will be different! Below, only the FQDN-based configuration is demonstrated

Edit: / etc/httpd/conf.d/vhost.conf file

[root@johnson's linux ~] # vim / etc/httpd/conf.d/vhost.conf # add the following, FQDN-based virtual host configuration # fixed syntax can ignore case ServerName # is very important, FQDN-based virtual host must have the hostname DocumentRoot "/ www/host/htdoc" # virtual host root directory You can specify the path # permission setting for the virtual host root directory Options FollowSymLinks # FollowSymLinks means that you can access the symbolic link resource require all Granted # directory permission setting ServerName www.myadmin.com DocumentRoot "/ www/host2/htdoc" Options FollowSymLinks require all Granted

Options: as an option for a directory, you can specify multiple properties

For example, Index, starts the resource index, and its function is to return the web resource index when the user accesses that the specified URL does not exist. This option

Very dangerous, it is not recommended to enable it, otherwise the source code will be exposed to web source code, and the consequences will be very serious.

Access permissions settings:

Require all Granted/deny, Granted: allow, all: all, deny: no

It should be noted that CentOS7 denies all hosts access to DocumentRoot resources by default, so this parameter must be configured to configure virtual hosts.

(2) create the resource directory defined in the configuration file for the virtual host and

[root@johnson's linux ~] # mkdir/www/ {host,host2} / htdoc

(3) add test resources

[root@johnson's linux ~] # vim / www/host/htdoc/index.php# the previous section is the PHP code to test the connectivity between php and mysql # the php code to test whether the php is working properly

(4) configure httpd master configuration file

Edit: / etc/httpd/conf/httpd.conf

[root@johnson's linux ~] # vim / etc/httpd/conf/httpd.conf# find DocumentRoot "/ var/www/html", # comment it out, generally use virtual machines to comment out, avoid conflicts # DocumentRoot "/ var/www/html" # add php home page index DirectoryIndex index.php index.html # add index.php in front, so this kind of resource index will be accessed by default # uncomment server name

(5) start the service and test whether it is normal or not

# check whether there is any error in the syntax of the configuration file [root@johnson's linux ~] # httpd-t # syntax to start the service [root@johnson's linux ~] # systemctl start httpd.service

Open the web page to see if the service is normal.

The http service test is normal, and the php module works, but, as you can see, the connection to mysql failed because we haven't configured the mysql server yet.

(5) obtain wordpress and phpmyadmin

The blogger's is downloaded from the ftp server in the local area network.

Wordpress configuration:

# download and extract to / www/host/htdoc# cd to wordpress directory The configuration file is as follows [root@johnson's linux wordpress] # lsindex.php wp-blog-header.php wp-cron.php wp-mail.phplicense.txt wp-comments-post.php wp-includes wp-settings.phpreadme.html wp-links-opml.php wp-signup.phpwp-activate.php wp-config-sample.php wp-load.php wp-trackback.phpwp-admin wp-content The wp-config-sample.php above the wp-login.php xmlrpc.php# replication configuration file edits the configuration file [root@johnson's linux wordpress] # vim wp-config.php// * * MySQL settings for wp-config.php [root@johnson's linux wordpress] # cp wp-config-sample.php wp-config.php#-specific information comes from the host * * / / * * WordPress data you are using The name of the library * / define ('DB_NAME' 'wpdb') # fill in the name of the database to be authorized by mysql (to 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.18.17.8') # enter the default text code * / define ('DB_CHARSET',' utf8') of the ip/** of the mysql host when creating the data table; / * * the type of database collation. Do not change * / define ('DB_COLLATE','') if you are not sure

Phpmyadmin configuration:

# download and extract the package to / www/host2/htdoc# cd to the file directory # create a symbolic link [root@johnson's linux htdoc] # ln-s phpMyAdmin-4.4.14.1-all-languages myadmin [root @ johnson's linux htdoc] # lsindex.php phpMyAdmin-4.4.14.1-all-languages myadmin phpMyAdmin-4.4.14.1-all-languages.zip # cd to the myadmin directory Modify configuration file [root@johnson's linux htdoc] # cp config.sample.inc.php config.inc.php# edit configuration file [root@johnson's linux htdoc] # vim config.inc.php$cfg ['blowfish_secret'] =' o71mI9rimj6syc00fT3g' / * YOU MUST FILL IN THIS FOR COOKIE AUTH! * / # enter a random password in single quotation marks. You can use openssl rand-base64 15 (password length) to generate / * * Servers configuration * / $I = 0 * First server * / $cfg ['Servers'] [$I] [' auth_type'] = 'cookie']. / * Server parameters * / $cfg ['Servers'] [$] [' host'] = '172.18.17.8'; # Database host ip $cfg ['Servers'] [$I] [' connect_type'] = 'tcp';$cfg [' Servers'] [$I] ['compress'] = false;$cfg [' Servers'] [$I] ['AllowNoPassword'] = false

172.18.17.8 Host configuration: mysql service

(1) yum installer

[root@johnson's linux ~] # yum install mariadb-server=Installing: mariadb-server x8614 61purl 5.5.44-2.el7.centos base 11 MInstalling for dependencies: mariadb x86141purge 5.5.44-2.el7.centos base 8.9m perl-Compress-Raw-Bzip2 x861564 2.061-3.el7 Base 32k perl-Compress-Raw-Zlib x8614414.el7 base 2.061-4.el7 base 57k perl-DBD-MySQL x86164 4.023-5.el7 base 140k perl-DBI x86164 1.627-4.el7 Base 802k perl-IO-Compress noarch 2.061-2.el7 base 260k perl-Net-Daemon noarch 0.48-5.el7 base 51k perl-PlRPC noarch 0.2020-14.el7 base 36 kTransaction Summary=

A large number of dependent packages can be easily solved as long as there is yum and there is no problem with yum source configuration.

(2) start the service and perform safe installation operations

[root@johnson's linux ~] # systemctl start mariadb# View listening Port 3306 is the default listening port of mariaDB [root@johnson's linux ~] # ss-tnlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 50 *: 3306 *: * LISTEN 0128 *: 22 *: * LISTEN 0128: 22: * perform a secure installation [root@johnson's linux ~] # mysql_secure_installation Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.Set root password? [] y # set the administrator login secret (this password has nothing to do with the root of the linux system) New password: Re-enter new password: # enter the password to Password updated login fulfilled Reloading privilege tables.. ... Success!Remove anonymous users? [YPop] y # whether to remove anonymous users (no password is required to log in before performing a secure installation). Success! # it is dangerous to allow anonymous login. It is recommended to remove Disallow root login remotely? [YPAPO] n # whether the administrator account is not allowed to log in remotely, it is generally recommended that it is not allowed. Skipping. Remove test database and access to it? [YBO] y # remove test database-Dropping test database... ... Success!-Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [YBO] y # overload permission table. Success!Cleaning up...All done! If you've completed all of the above steps, your MariaDBinstallation should now be secure.Thanks for using MariaDB!

It is strongly recommended that you perform a secure installation after the mariaDB installation is complete, which can make the database more secure

(3) create the required database and authorize

[root@johnson's linux] # mysql-uroot-pEnter password: Welcome to the MariaDB monitor. Commands end with; or\ g.Your MariaDB connection id is 66Server version: 5.5.44-MariaDB MariaDB ServerCopyright (c) 2000, 2015, 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 wordpress database Query OK, 1 row affected (0.02 sec) # authorize wordpress database MariaDB [(none)] > GRANT ALL ON wpdb.* TO wpuser@172.18.17.7 IDENTIFIED BY 'wppasswd' Query OK, 0 rows affected (0.01 sec) # authorized remote access host (phpMyadmin) MariaDB [(none)] > GRANT ALL ON *. * TO admin@'172.18.17.7' IDENTIFIED BY 'admin'; Query OK, 0 rows affected (0.01 sec)

(4) support all configurations are basically completed: verify the results

1. Verify database connectivity

2. Check whether the wordpress is normal.

For some reason, my phpmyadmin display is not normal, just run! The configuration is over!

Finally, I would like to add:

Common errors in phpMyadmin:

1. Missing mbstring plug-in

Yum, install php-mbstring.

two。 Missing session directory

Usually on / var/lib/php/session. If not, you can create it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report