


Teach you step by step Linux PHP environment deployment and project launch (share)
##This article will share with you Linux PHP environment deployment and project launchIt has certain reference Value, friends in need can refer to it, I hope it will be helpful to everyone.
If you want to deploy For environment online projects, the following conditions must first be met: server (IP, account password, terminal), corresponding software, domain name (recording analysis, code), etc.
Server and domain name purchaseFirst log in to the console and obtain the IP address of the host that needs to be connected:rpm -Uvhhttps://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvhhttps://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install php72w php72w-cli php72w-common php72w-develphp72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlndphp72w-opcache php72w-pdo php72w-xml
d. Test PHP installation
php -v
yum -y install httpd
Note: The default site of Apache is located at "/var /www/html"
Create index.html and index.php files with any content:yum -y install mariadb-server
systemctl enable mariadb && systemctlstart mariadb
mysql -u root -p
##5 , Domain name resolution
Before modifying the hosts file, it was actually a type of domain name resolution. At that time, it was only limited to local, but now it needs to be considered online.
To do resolution, you must log in to the domain name control panel. Before parsing the domain name, it is best to ensure that the domain name has been registered. If there is no registered domain name, although the resolution will be successful, it will affect the use. When using will be intercepted by the service provider.
Click the Add Analysis Record button:
Fill in the corresponding record information in the pop-up window interface [DY7 ]:
Use ping test:
6. Unzip the code and import it into the database
Step 1**: Import the sql**** file into the database**
Enter the command line management interface of the database, create the required database edu16, and use the source command to import the sql file:
Step 2* *: Create the running directory of the site, decompress the uploaded code zip**** package, and then copy the code to the running directory of the site**
a. The site directory is agreed to be "/var /www/html".
Create site directory:
The directory already exists, no need to create it
b. Copy the previously uploaded code compressed package to the current site directory, decompress the compressed package, and the decompression is complete You can delete it later
Decompression syntax: unzip compressed package path
At this time, because the site entry file is in the public directory, and the site of the current project is in /var In /www/html, there is a missing public, so you need to modify the DocumentRoot item in the apache configuration file.
# vim /etc/httpd/conf/httpd.conf
Solve the pseudo-static problem (if you don’t solve it, you can only access the homepage, and other pages will get 404):
## Wait for the certificate issuance to be completed, and then download the certificate:
The public and private certificate files obtained after decompressing the compressed package:
Upload the three files to the server, and fix the save path and try not to change it.
It is agreed to store the public and private certificate files in "/ssl/"
b. Install Apache's mod_ssl module
yum -y install mod_ssl
c. Virtual host configuration reference (80 443):
way# The default main configuration file for ## is located at /etc/httpd/conf/httpd.conf
根据主配置文件中的配置可以看出,其引入了conf.d目录下的全部conf文件,那么可以在该目录中创建一个vhosts.conf****文件,作为虚拟主机的配置文件:
80端口主机:
<VirtualHost *:80> ServerAdmin cherish@cherish.pw DocumentRoot"PATH" ServerName “yourdomain.com” <Directory “PATH”> Allow from all AllowOverride all Options -indexes Require all granted
443端口主机:
<VirtualHost *:443> SSLEngine on SSLCertificateFile “公钥文件路径” SSLCertificateKeyFile “私钥文件路径” SSLCertificateChainFile “证书链文件路径” SSLCipherSuite"ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4:!DH:!DHE" SSLProtocol TLSv1.1 TLSv1.2 Headeralways set Strict-Transport-Security “max-age=63072000; includeSubdomains;preload” DocumentRoot “PATH” ServerName “yourdomain.com” <Directory “PATH”> Allowfrom all AllowOverride all Options -indexes Require all granted
创建好之后,参考上述的框框中配置代码,进行修改,其中443端口的虚拟主机配置含义如下:
修改完毕之后保存退出,然后重启apache
systemctl restart httpd
d. 打开浏览器访问项目,检查https协议是否生效
问题,生效虽然生效了,但是https协议需要用户手动去补充,在直接输入域名访问的时候默认还是80的http****协议,如何解决?
答:使用重写的方法,强制用户在访问http的时候跳转到https。操作步骤如下,在站点根目录下的“.htaccess”文件中添加如下代码,保存退出即可:
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
举手之劳:框架运行的时候报错了,请解决。
错误1**:权限不足**
解决办法:
错误2**:数据库连接失败**
解决办法:修改项目目录下的.env文件
处理完毕之后项目即可访问您的项目了。
[DY1]如搭配使用的服务器在大陆境内,则需要域名先通过ICP备案。
[DY2]RHEL以及他的衍生发行版如CentOS、Scientific Linux为了稳定,官方的rpm repository提供的rpm包往往是很滞后的,当然了,这样做这是无可厚非的,毕竟这是服务器版本,安全稳定才是重点。
[DY3]EPEL:Extra Packages of EnterpriseLinux
[DY4]“指令A && 指令B”语法表示当指令A执行成功之后再去执行指令B。
systemctl指令是CentOS7中特有的指令,含义如指令名称:systemcontrol。
控制服务开关:
systemctl 开关服务名
启动项管理:
systemctl enable/disable 服务名
[DY5]在CentOS7的yum源中,数据库软件没有MySQL,取而代之的是Mariadb。
[DY6]执行该指令后依次有以下几个输入内容:
输入当前数据库root帐号密码,没有密码则直接按回车;
是否设置密码?输入Y后,为root用户设置密码;
是否移除匿名用户?选择Y;
是否禁止root用户远程登录?Y/n均可,不会生效;
是否删除测试的test数据库?选择Y/n均可;
是否刷新权限?选择Y;
[DY7]常见的几个记录类型:
A记录:将域名指向一个IPv4地址;
CNAME记录:域名的别名,将一个域名指向另一个域名;
MX记录:一般用于做域名邮箱,将域名指向一个邮件服务器;
推荐学习:《PHP视频教程》
The above is the detailed content of Teach you step by step Linux PHP environment deployment and project launch (share). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

In PHP, exception handling is achieved through the try, catch, finally, and throw keywords. 1) The try block surrounds the code that may throw exceptions; 2) The catch block handles exceptions; 3) Finally block ensures that the code is always executed; 4) throw is used to manually throw exceptions. These mechanisms help improve the robustness and maintainability of your code.

There are four main error types in PHP: 1.Notice: the slightest, will not interrupt the program, such as accessing undefined variables; 2. Warning: serious than Notice, will not terminate the program, such as containing no files; 3. FatalError: the most serious, will terminate the program, such as calling no function; 4. ParseError: syntax error, will prevent the program from being executed, such as forgetting to add the end tag.

In PHP, the difference between include, require, include_once, require_once is: 1) include generates a warning and continues to execute, 2) require generates a fatal error and stops execution, 3) include_once and require_once prevent repeated inclusions. The choice of these functions depends on the importance of the file and whether it is necessary to prevent duplicate inclusion. Rational use can improve the readability and maintainability of the code.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

HTTP request methods include GET, POST, PUT and DELETE, which are used to obtain, submit, update and delete resources respectively. 1. The GET method is used to obtain resources and is suitable for read operations. 2. The POST method is used to submit data and is often used to create new resources. 3. The PUT method is used to update resources and is suitable for complete updates. 4. The DELETE method is used to delete resources and is suitable for deletion operations.
