Ubuntu下搭建PHP开发环境
可以选择一键安装所有包,也可以一个个的安装,这里我选择一键安装。
步骤如下:
1.sudo apt-get install apache2 mysql-server mysql-client php5 一键安装
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
apache2 已经是最新的版本了。
将会安装下列额外的软件包:
apache2-mpm-prefork libapache2-mod-php5 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18 libnet-daemon-perl libplrpc-perl
libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common mysql-server-5.5 mysql-server-core-5.5 php5-cli php5-common
建议安装的软件包:
php-pear libipc-sharedcache-perl tinyca mailx php5-suhosin
下列软件包将被【卸载】:
apache2-mpm-worker
下列【新】软件包将被安装:
apache2-mpm-prefork libapache2-mod-php5 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18 libnet-daemon-perl libplrpc-perl
libterm-readkey-perl mysql-client mysql-client-5.5 mysql-client-core-5.5 mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php5
php5-cli php5-common php5-gd php5-mysql
升级了 0 个软件包,新安装了 21 个软件包,要卸载 1 个软件包,有 196 个软件包未被升级。
需要下载 33.0 MB 的软件包。
解压缩后会消耗掉 110 MB 的额外空间。
您希望继续执行吗?[Y/n]y
点击y,继续安装
获取:1 http://cn.archive.ubuntu.com/ubuntu/ precise/main libnet-daemon-perl all 0.48-1 [43.1 kB]
获取:2 http://cn.archive.ubuntu.com/ubuntu/ precise/main libplrpc-perl all 0.2020-2 [36.0 kB]
获取:3 http://cn.archive.ubuntu.com/ubuntu/ precise/main libdbi-perl i386 1.616-1build2 [849 kB]
获取:4 http://security.ubuntu.com/ubuntu/ precise-security/main apache2-mpm-prefork i386 2.2.22-1ubuntu1.4 [2,408 B]
获取:5 http://security.ubuntu.com/ubuntu/ precise-security/main mysql-common all 5.5.35-0ubuntu0.12.04.1 [13.0 kB]
获取:6 http://security.ubuntu.com/ubuntu/ precise-security/main libmysqlclient18 i386 5.5.35-0ubuntu0.12.04.1 [924 kB]
获取:7 http://cn.archive.ubuntu.com/ubuntu/ precise/main libdbd-mysql-perl i386 4.020-1build2 [104 kB]
获取:8 http://cn.archive.ubuntu.com/ubuntu/ precise/main libterm-readkey-perl i386 2.30-4build3 [28.4 kB]
获取:9 http://cn.archive.ubuntu.com/ubuntu/ precise/main libhtml-template-perl all 2.10-1 [65.0 kB]
获取:10 http://security.ubuntu.com/ubuntu/ precise-security/main mysql-client-core-5.5 i386 5.5.35-0ubuntu0.12.04.1 [1,860 kB]
9% [10 mysql-client-core-5.5 1,073 kB/1,860 kB 58%] 14.7 kB/s 33分 48秒^Cf
至此,环境搭建好了,可以测试一下
在firefox下输入localhost即可
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
2.sudo chmod 777 /var/ www/ 因为服务器的网站目录是放在该文件下,因此要取得777权限
3.phpmyadmin可以选,也可以不选如sudo apt-get install phpmyadmin
[email protected]:~$ sudo apt-get install phpmyadmin
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
将会安装下列额外的软件包:
apache2-mpm-prefork dbconfig-common libapache2-mod-php5 libdbd-mysql-perl
libdbi-perl libmcrypt4 libmysqlclient18 libnet-daemon-perl libplrpc-perl
libterm-readkey-perl mysql-client mysql-client-5.5 mysql-client-core-5.5
mysql-common php5-cli php5-common php5-gd php5-mcrypt php5-mysql
建议安装的软件包:
php-pear libmcrypt-dev mcrypt php5-suhosin mysql-server
下列软件包将被【卸载】:
apache2-mpm-worker
下列【新】软件包将被安装:
apache2-mpm-prefork dbconfig-common libapache2-mod-php5 libdbd-mysql-perl
libdbi-perl libmcrypt4 libmysqlclient18 libnet-daemon-perl libplrpc-perl
libterm-readkey-perl mysql-client mysql-client-5.5 mysql-client-core-5.5
mysql-common php5-cli php5-common php5-gd php5-mcrypt php5-mysql phpmyadmin
升级了 0 个软件包,新安装了 20 个软件包,要卸载 1 个软件包,有 196 个软件包未被升级。
需要下载 22.3 MB/24.3 MB 的软件包。
解压缩后会消耗掉 77.7 MB 的额外空间。
您希望继续执行吗?[Y/n]y
点击y,继续安装
获取:1 http://cn.archive.ubuntu.com/ubuntu/ precise/main dbconfig-common all 1.8.47 [458 kB]
获取:2 http://cn.archive.ubuntu.com/ubuntu/ precise/universe libmcrypt4 i386 2.5.8-3.1 [76.1 kB]
获取:3 http://cn.archive.ubuntu.com/ubuntu/ precise/universe php5-mcrypt i386 5.3.5-0ubuntu1 [16.9 kB]
获取:4 http://cn.archive.ubuntu.com/ubuntu/ precise/universe phpmyadmin all 4:3.4.10.1-1 [5,343 kB]
获取:5 http://security.ubuntu.com/ubuntu/ precise-security/main php5-common i386 5.3.10-1ubuntu3.10 [163 kB]
获取:6 http://security.ubuntu.com/ubuntu/ precise-security/main libapache2-mod-php5 i386 5.3.10-1ubuntu3.10 [3,109 kB]
在安装过程中会要求选择Web server:apache2或lighttpd,选择apache2,按tab键然后确定。然后会要求输入设置的Mysql数据库密码连接密码 Password of the database's administrative user。

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.

In PHP, use the clone keyword to create a copy of the object and customize the cloning behavior through the \_\_clone magic method. 1. Use the clone keyword to make a shallow copy, cloning the object's properties but not the object's properties. 2. The \_\_clone method can deeply copy nested objects to avoid shallow copying problems. 3. Pay attention to avoid circular references and performance problems in cloning, and optimize cloning operations to improve efficiency.

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

Key players in HTTP cache headers include Cache-Control, ETag, and Last-Modified. 1.Cache-Control is used to control caching policies. Example: Cache-Control:max-age=3600,public. 2. ETag verifies resource changes through unique identifiers, example: ETag: "686897696a7c876b7e". 3.Last-Modified indicates the resource's last modification time, example: Last-Modified:Wed,21Oct201507:28:00GMT.

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

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

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver CS6
Visual web development tools