1. Choose a suitable cloud server
First of all, you need to choose a suitable cloud server. Choose the appropriate configuration and operating system based on your needs. Here we take the CentOS system on Alibaba Cloud as an example.
2. Install the web server
The first step in setting up the environment is to install a web server such as Apache or Nginx. Here we take Apache as an example. Use the following command to install Apache in the terminal:
sudo yum update sudo yum install httpd
After the installation is complete, start the Apache service and set it to start at boot:
sudo systemctl start httpd.service sudo systemctl enable httpd.service
At this time, by accessing the public IP address of the cloud server, browse Enter the IP address into the server and you will see the default page of Apache, indicating that Apache has been successfully installed.
3. Install php
Next, install php. Use the following command to install php in the terminal:
sudo yum -y install php php-mysql
After the installation is complete, restart the Apache service:
<code><code>##<div class="code" style="position:relative; padding:0px; margin:0px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">sudo systemctl restart httpd.service</pre><div class="contentsignin">Copy after login</div></div><div class="contentsignin">Copy after login</div></div><div class="contentsignin">Copy after login</div></div><div class="contentsignin">Copy after login</div></div><code>
sudo vim /var/www/html/info.php
<?php phpinfo(); ?>
http://你的IP地址/info.php
sudo yum install php-curl
<code><code><div class="code" style="position:relative; padding:0px; margin:0px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">sudo systemctl restart httpd.service</pre><div class="contentsignin">Copy after login</div></div><div class="contentsignin">Copy after login</div></div><div class="contentsignin">Copy after login</div></div><div class="contentsignin">Copy after login</div></div><code>
sudo yum install php-gd
<code><code><div class="code" style="position:relative; padding:0px; margin:0px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">sudo systemctl restart httpd.service</pre><div class="contentsignin">Copy after login</div></div><div class="contentsignin">Copy after login</div></div><div class="contentsignin">Copy after login</div></div><div class="contentsignin">Copy after login</div></div><code>
sudo yum install php-mbstring
<code><code><div class="code" style="position:relative; padding:0px; margin:0px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">sudo systemctl restart httpd.service</pre><div class="contentsignin">Copy after login</div></div><div class="contentsignin">Copy after login</div></div><div class="contentsignin">Copy after login</div></div><div class="contentsignin">Copy after login</div></div><code>
sudo vim /etc/php.ini
display_errors = On # 显示错误信息 date.timezone = Asia/Shanghai # 设置时区 upload_max_filesize = 20M # 设置上传文件大小限制
The above is the detailed content of How to build a php environment for cloud server linux. For more information, please follow other related articles on the PHP Chinese website!