Php projects under linux deployment environment can be divided into two types, one using Apache, php, mysql archive installation, yum command for performing installation.
Three compressed software installation, need to manually configure the relationship between the three. Between the apache and php configuration there is no difficulty, but when configured and mysql on the need of the knowledge of php.
My official group here .
The following is a configuration environment in linux php with yum:
MySql
1.mysql and apache is best to first install because of the need to associate with mysql and apache when configuring php configuration and testing
First, download the file mysql-sever, because bloggers environment is CentOS linux version, yum seemingly no source file mysql-sever when properly installed mysql, the need Quguan downloaded
1.下载mysql-service文件
[root@tele-1 ~]# wget
mysql-service
[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 mysql service after installation
[root@tele-1 ~]# service mysqld restart
4. The initial installation of mysql is no password, the default user name is root. So we need to change the password, be modified with the mysql command-line
1. Go to 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 its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
2. Use the command password change
mysql> set password for 'root'@'localhost' = password('你要修改的密码');
Query OK, 0 rows affected (0.06 sec)
5. Because bloggers are using to connect to local mysql navicat software under linux, so if you want to access locally, then you need to change it in the mysql database user table of
1. The operation of the database table mysql
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changedmysql>
2. Check the data in the user table (sql statement can be written directly 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>
Table after table is modified, you want remote access, you need the data marked in red on top, Host refers can access this database ip address,% represents all requests can be connected in.
We can modify a data, you can add a piece of data. But best not to modify the top blue marked data, modify the format of the statement is below
mysql> update user set Host = '%' where ???
4. Finally, the introduction of exit or \ q is quit mysql command-line methods
mysql> \q
Bye
Installing Apache
Installation is relatively simple 1.apache
[root@tele-2 ~]# yum install httpd
2. external network access to the virtual machine address, we will need to modify the apache configuration file /etc/httpd/conf/httpd.conf
Found #ServerName HTTP:. // the WWW example.com:80 changed ServerName localhost: 80
as the picture shows:
Find #Listen replaced Listen: 8080 (linux open ports number 80XX)
3. After modifications are complete we need to start the httpd service again, and view the status of start
[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 -DFOREGROUND
Jun 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. At this point you can access your server, and enter localhost or the ip address, the emergence of a Apache test page powered by centos test page
PHP
1.php installation command
[root@tele-2 ~]# yum install php
2. Direct all the way to installation, service httpd restart again after the installation is complete
[root@tele-2 ~]# service httpd startRedirecting to /bin/systemctl start httpd.service
3. After the restart we tested PHP-related information, we create a PHP interface for testing
In the apache default page path /var/www/html
create a test.php page under, add code
<?php phpinfo();?>
4. Visit this page, enter localhost / test.php, or
ip: port number /test.php can see php configuration information of the environment. Figure:
Associated php and mysql
1. Search Module
[root@tele-2 ~]# yum search php
2. Install the 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, restart httpd
Revisit earlier info.php, we found that MySQL had more relevant information. Such as the right:
So far, php linux operating environment in the configuration has been successfully completed.
1.mysql yum install the default folder and related commands
/var/lib/mysql/
:/usr/share/mysql(mysql.server)
/usr/bin(mysqladmin mysqldump)
my.cnf: /etc/my.cnf
:/etc/rc.d/init.d/mysql
:service mysql start
停止命令:service mysql stop
运行状态:service mysql status
2.apache
配置文件路径:/etc/httpd/conf/httpd.conf
service httpd start
service httpd stop
运行状态:service httpd status
3.php
php默认页面路径:/var/www/html
The above is how to deploy under linux php project
For more information please pay attention to my column know almost
以上内容希望帮助到大家,很多PHPer在进阶的时候总会遇到一些问题和瓶颈,业务代码写多了没有方向感,不知道该从那里入手去提升,对此我整理了一些资料,包括但不限于:分布式架构、高可扩展、高性能、高并发、服务器性能调优、TP6,laravel,YII2,Redis,Swoole、Swoft、Kafka、Mysql优化、shell脚本、Docker、微服务、Nginx等多个知识点高级进阶干货需要的可以免费分享给大家,需要的可以加入我的官方群点击此处。