


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.rpmb. Obtain the yum source of PHP7
rpm -Uvhhttps://mirror.webtatic.com/yum/el7/webtatic-release.rpmc. Install PHP7.2 and its common extensions
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 httpdb. Set Apache to boot and start Apache: systemctl enable httpd && systemctl start httpd[DY4]c. Write a static file and a The php script tests whether Apache parses dynamic and static files normally
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 mariadbc. Execute the initialization of the Mariadb database Instructions (setting initial password and other operations)mysql_secure_installation[DY6]d. Try to log in to Mariadb using the command line
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!

Thedifferencebetweenunset()andsession_destroy()isthatunset()clearsspecificsessionvariableswhilekeepingthesessionactive,whereassession_destroy()terminatestheentiresession.1)Useunset()toremovespecificsessionvariableswithoutaffectingthesession'soveralls

Stickysessionsensureuserrequestsareroutedtothesameserverforsessiondataconsistency.1)SessionIdentificationassignsuserstoserversusingcookiesorURLmodifications.2)ConsistentRoutingdirectssubsequentrequeststothesameserver.3)LoadBalancingdistributesnewuser

PHPoffersvarioussessionsavehandlers:1)Files:Default,simplebutmaybottleneckonhigh-trafficsites.2)Memcached:High-performance,idealforspeed-criticalapplications.3)Redis:SimilartoMemcached,withaddedpersistence.4)Databases:Offerscontrol,usefulforintegrati

Session in PHP is a mechanism for saving user data on the server side to maintain state between multiple requests. Specifically, 1) the session is started by the session_start() function, and data is stored and read through the $_SESSION super global array; 2) the session data is stored in the server's temporary files by default, but can be optimized through database or memory storage; 3) the session can be used to realize user login status tracking and shopping cart management functions; 4) Pay attention to the secure transmission and performance optimization of the session to ensure the security and efficiency of the application.

PHPsessionsstartwithsession_start(),whichgeneratesauniqueIDandcreatesaserverfile;theypersistacrossrequestsandcanbemanuallyendedwithsession_destroy().1)Sessionsbeginwhensession_start()iscalled,creatingauniqueIDandserverfile.2)Theycontinueasdataisloade

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.


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

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.
