Deploy php projects in linux-associate Apache, php, and mysql-apachemysql
There are two types of php project environments deployed in linux: Apache, php, and mysql compressed packages and yum commands.
To install the three software packages, you must manually configure the relationship between them. Configuration between apache and php is not difficult, but you need to understand php When configuring with mysql.
Configure the php environment using yum in linux:
MySql
1. It is best to install mysql and apache first, because you need to configure and test the connection with mysql and apache When configuring php.
First download the mysql-sever file. Because the master linux environment is CentOS, the mysql-sever file does not appear to be properly installed in the yum source. You need to download it from the official website.
1. Download the mysql-service file
[root@tele-1 ~]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
2. Install the mysql-service file
[root@tele-1 ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
2. Install mysql
[root@tele-1 ~]# yum install mysql-community-server
3. Start the mysql service after installation.
[root@tele-1 ~]# service mysqld restart
4. The initial installation of mysql has no password, and the default user name is root. Therefore, we need to change the password by using the mysql command line.
1. Enter the mysql Command Line
[root@tele-1 ~]# mysql -urootWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 474801Server version: 5.6.36 MySQL Community Server (GPL)Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
2. Use commands to change passwords
Mysql> set password for 'root' @ 'localhost' = password ('password you want to change '); Query OK, 0 rows affected (0.06 sec)
5. Because the blogger uses the local navicat software to connect to mysql in linux, if you want to access mysql locally, you need to change the user table in the mysql database.
1. Operate mysql database tables
mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql>
2. View data in the user table (you can directly write SQL statements in the mysql command line)
mysql> select * from user;+-----------+------+-----------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-----------------------+------------------+| Host | User | Password | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | Create_tablespace_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections | plugin | authentication_string | password_expired |+-----------+------+-----------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-----------------------+------------------+| % | root | *3ce8dad2446975d8b0c771bd7e48d15b | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | | | | | 0 | 0 | 0 | 0 | mysql_native_password | | N || localhost | root | *3ce8dad2446975d8b0c771bd7e48d15b | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | | | | | 0 | 0 | 0 | 0 | mysql_native_password | | N || 127.0.0.1 | root | *3ce8dad2446975d8b0c771bd7e48d15b | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | | | | | 0 | 0 | 0 | 0 | mysql_native_password | | N || ::1 | root | *3ce8dad2446975d8b0c771bd7e48d15b | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | | | | | 0 | 0 | 0 | 0 | mysql_native_password | | N || tele-1 | | | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | | | | | 0 | 0 | 0 | 0 | mysql_native_password | NULL | N |+-----------+------+-----------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-----------------------+------------------+5 rows in set (0.00 sec)mysql>
3. the master's table is a modified table. If you want to remotely access the table, you need the data marked in red. Host indicates the IP address that can access the database, % indicates that all requests can be connected.
You can modify or add a piece of data. But it is better not to modify the data marked in blue above. The statement to modify is the format below.
mysql> update user set Host = '%' where ???
4. The last exit or \ q method is to exit the mysql command line.
mysql> \qBye
Install Apache
1. apache installation method is relatively simple
[root@tele-2 ~]# yum install httpd
2. To access the address in the VM from the Internet, modify the apache configuration file/etc/httpd/conf/httpd. conf.
Find # ServerName www.example.com: 80 and change it to ServerName localhost: 80.
As shown in the right figure:
Find # change Listen to Listen: 8080 (port 80 XX opened in linux)
As shown in the right figure:
3. After the modification is complete, we need to start the httpd service again and check the startup status.
[root@tele-2 ~]# service httpd startRedirecting to /bin/systemctl start httpd.service[root@tele-2 ~]# service httpd statusRedirecting to /bin/systemctl status httpd.service● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2017-06-05 15:57:34 CST; 5s ago Docs: man:httpd(8) man:apachectl(8) Process: 54532 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS) Process: 39046 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS) Main PID: 54573 (httpd) Status: "Processing requests..." Memory: 15.8M CGroup: /system.slice/httpd.service ├─54573 /usr/sbin/httpd -DFOREGROUND ├─54576 /usr/sbin/httpd -DFOREGROUND ├─54577 /usr/sbin/httpd -DFOREGROUND ├─54578 /usr/sbin/httpd -DFOREGROUND ├─54579 /usr/sbin/httpd -DFOREGROUND └─54580 /usr/sbin/httpd -DFOREGROUNDJun 05 15:57:34 tele-2 systemd[1]: Starting The Apache HTTP Server...Jun 05 15:57:34 tele-2 systemd[1]: Started The Apache HTTP Server.
4. Now you can access your server. Enter localhost or IP address, and an Apache test page powered by centos test page will appear.
PHP
1. php installation command
[root@tele-2 ~]# yum install php
2. Install httpd directly. Restart the httpd service again after installation.
[root@tele-2 ~]# service httpd startRedirecting to /bin/systemctl start httpd.service
3. After the restart, We will test the PHP information. We will create a new PHP interface for testing.
Default apache page path/
var
/www/html
Next, create a test. php page and add the code
<?php phpinfo();?>
4. access this page, enter localhost/test. php, or
Ip: Port Number/test. php, you can see the configuration information of the php environment. As shown in the right figure:
Associate php with mysql
1. Search Module
[root@tele-2 ~]# yum search php
2. Install related modules
[root@tele-2 ~]# yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
3. The installation is complete. Restart mysqld and httpd.
Access info. php again, and we find that MySQL information is missing. As shown in the right figure:
Now, the php running environment in linux has been successfully configured.
1. Install the default folder and related commands in mysql yum
Database Directory:/var/lib/mysql/
Configuration File:/usr/share/mysql (mysql. server command and configuration file)
Related commands:/usr/bin (commands such as mysqladmin mysqldump)
My. cnf:/etc/my. cnf
Startup Script:/etc/rc. d/init. d/(directory of the mysql STARTUP script file)
Start command: service mysql start
Stop command: service mysql stop
Running status: service mysql status
2. apache
Configuration File Path:/etc/httpd/conf/httpd. conf
Start command: service httpd start
Stop command: service httpd stop
Running status: service httpd status
3. php
Default php page path:/var/www/html
Related links:
Http://www.centoscn.com/mysql/2014/0919/3778.html
Http://www.cnblogs.com/IEBD/p/4563840.html
Http://ernestchen.iteye.com/blog/1838168