ubuntu通过apt-get方式搭建lnmp环境以及php扩展安装
一直是在用的lnmp的集成安装包搭建lnmp环境,因为工作需要需要安装ldap扩展,在网上怎么都找不到源码安装包,只能卸载掉原来的lnmp环境,用ubuntu的php5-ldap扩展, 在安装中遇到一些问题,网上的文章坑爹的比较多,写篇文章记录下来。 1.安装mysql sudo apt
一直是在用的lnmp的集成安装包搭建lnmp环境,因为工作需要需要安装ldap扩展,在网上怎么都找不到源码安装包,只能卸载掉原来的lnmp环境,用ubuntu的php5-ldap扩展,
在安装中遇到一些问题,网上的文章坑爹的比较多,写篇文章记录下来。
1.安装mysql
sudo apt-get install mysql-server mysql-client
我在安装中出错,是原来的mysql-cilent mysql-workbench 未完全卸载,将mysql组件完全卸载的方法:
删除mysql前 先删除一下 /var/lib/mysql 还有 /etc/mysql
sudo rm /var/lib/mysql/ -R sudo rm /etc/mysql/ -R sudo apt-get autoremove mysql* --purge sudo apt-get remove apparmor
全部删除之后再执行 apt-get install mysql-server mysql -client
2.安装nginx
sudo apt-get install nginx
3.安装成功后。我们重启下nginx服务
sudo service nginx restart<span> </span>
启动之后我们就可以访问以下我们的地址了。看能不能出现nginx的欢迎界面。
4.这里我们使用php5-fpm来作为我们的php解析。
sudo apt-get install php5-fpm
5.接下来我们要修改一下nginx的站点配置了。
ngnix的配置文件存放在/etc/nginx/sites-availble/default
server { listen 80; ## listen for ipv4; this line is default and implied listen [::]:80 default ipv6only=on; ## listen for ipv6 root /usr/share/nginx/www; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.html; } location /doc { root /usr/share; autoindex on; allow 127.0.0.1; deny all; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { try_files $uri =404; # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # With php5-fpm: # fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } }
6.我们在安装php5相关的一些组件。
sudo apt-cache search php5 apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
7.重启服务
sudo service php5-fpm restart sudo service nginx restart
经测试,现在应该已经安装成功了。
PHP扩展的安装方式通常分为两种:
1. 随同PHP编译
2. 生成单独的.so文件
这里介绍第二种方式,对于第二种方式执行效率可能低些,但是模块化,就是可以保持php安装不变的情况下,通过php.ini连接单独生成的so文件实现扩展,
比如您已经通过了tar包方式安装了php,那么现在想增加扩展:
安装CURL扩展
I. 生成动态链接库文件.SO
方法如下:
方法1. apt-get install php5-curl
方法2. 去PHP网站下载tar包,phpize本地编译生成.so
方法3. pear方式安装,通过pecl命令去在线下载编译生成.so
方法1在ubuntu下是最简单的,命令执行完会告知.so所在目录
II. 配置php.ini
打开php.ini,指定extension_dir目录,如果extension_dir = '/usr/lib',那么接下来把生成的.so文件(如curl.so)复制到/usr/lib目录下,并且加入一个新条目:
extension=curl.so
III. 使之生效
重新启动apache,运行phpinfo()看是否生效
安装PDO_MYSQL扩展
采用pear方式安装
I. 安装pear
apt-get install php-pear 如果没有pear要先安装pear
II. 安装pdo,pdo_mysql
pecl install pdo pecl install pdo_mysql
生成.so复制到/usr/lib目录下.
如果没有安装php和mysql的开发包,在执行第II步之前还需要安装
apt-get install php5-devapt-get install libmysqlclient15-dev
III. 修改配置文件php.ini
增加条目
extension=pdo.so
extension=pdo_mysql.so
IV. 使之生效
重新启动apache,运行phpinfo()看是否生效
在php5.2.10中,php默认已经安装了pdo,所以extension=pdo.so不加,但是发现和自己生成的pdo_mysql.so不匹配错误,解决办法是:
重新安装php,增加参数--disable-pdo 禁止pdo模块,用自己前面生成pdo.so,pdo+mysql.so就OK了
安装ImageMagic扩展
采用pear方式安装
I. 安装ImageMagick
sudo apt-get install imagemagick
II. 安装imagemagick 的lib 供php调用
sudo apt-get install libmagick++-dev
III. 调用当前的pecl安装imagick
pecl install imagick
IV. 修改php.ini.重启apache服务器
在php.ini中添加: extension = imagick.so
phpize的安装
phpize是属于php-devel的内容,所以只要运行
apt-get install php-devel就行。ubuntu 下是 apt-get install php-dev
我安装的时候装的是php5-dev
装完之后是用phpize5来装自己编写的php扩展

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

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



It is a very common problem these days that Ubuntu does not allow its users to open the terminal. If you receive a similar issue and don’t know what to do next, learn about five fixes on how to resolve this “Ubuntu cannot open terminal” issue on your Linux device. Without further ado, let’s dive into what causes it and the solutions available to it. Why can't Ubuntu open the terminal on it? This mainly happens when you install some defective software or modify the terminal configuration. In addition to this, new applications or games that interact with locales and corrupt them can cause similar problems. Some users reported a fix for this issue when searching for Terminal in Ubuntu's activity menu. This shows that

There are many software icons listed in the Ubuntu system start menu. There are many uncommon icons. If you want to delete them, how should you delete them? Let’s take a look at the detailed tutorial below. 1. First enter the ubuntu desktop and click on the start menu under the left panel. 2. You can find a text editor icon inside, we need to delete it. 3. Now we return to the desktop and right-click the mouse to open the terminal. 4. Use the command to open the application list directory. sudonautilus/usr/share/applicationssudonautilus~/.local/share/applications5. Find the corresponding text editor icon inside. 6. Then go straight

In Ubuntu systems, the root user is usually disabled. To activate the root user, you can use the passwd command to set a password and then use the su- command to log in as root. The root user is a user with unrestricted system administrative rights. He has permissions to access and modify files, user management, software installation and removal, and system configuration changes. There are obvious differences between the root user and ordinary users. The root user has the highest authority and broader control rights in the system. The root user can execute important system commands and edit system files, which ordinary users cannot do. In this guide, I'll explore the Ubuntu root user, how to log in as root, and how it differs from a normal user. Notice

Ubuntu24.04LTS, codenamed "NobleNumbat" will be released soon! If you are using a non-LTS version such as Ubuntu 23.10, sooner or later you will need to consider upgrading. For those using Ubuntu20.04LTS or Ubuntu22.04LTS, it is worth thinking about whether to upgrade. Canonical has announced that Ubuntu 24.04LTS will provide update support for up to 12 years, broken down as follows: As an LTS version, it will have 5 years of regular maintenance and security updates. If you subscribe to Ubuntu Pro, you can enjoy an additional 5 years of support. Currently, this additional support period has been extended to 7 years, which means you will get up to 12

OBS is open source software developed by volunteer contributors around the world in their free time. A video live recording software, mainly used for video recording and live streaming. Please note that when installing Ubuntu/Mint, OBSStudio cannot fully work on ChromeOS, and functions such as screen and window capture cannot be used. It is recommended to use xserver-xorg1.18.4 or newer version to avoid potential performance issues with certain features in OBS, such as full-screen projectors. FFmpeg is required. If you don't have FFmpeg installed (if you're not sure, you probably don't), you can get it with: sudoaptinstallffmpeg I already have it installed here

snap is a software packaging and deployment system developed by Canonical for operating systems that use the Linux kernel and systemdinit system. These packages, known as snaps, and the tool that uses them, snapd, are available across a range of Linux distributions and allow upstream software developers to publish their applications directly to users. With snap, users can easily install Linux applications. By default, snapd will check for updates four times a day and automatically update snap applications to the latest version. While there are many ways to control when and how often updates are installed, users cannot completely turn off automatic updates for security reasons. Although the original intention of snap is good, many people use it to

Angular.js is a freely accessible JavaScript platform for creating dynamic applications. It allows you to express various aspects of your application quickly and clearly by extending the syntax of HTML as a template language. Angular.js provides a range of tools to help you write, update and test your code. Additionally, it provides many features such as routing and form management. This guide will discuss how to install Angular on Ubuntu24. First, you need to install Node.js. Node.js is a JavaScript running environment based on the ChromeV8 engine that allows you to run JavaScript code on the server side. To be in Ub

For many users, hacking an Android TV box sounds daunting. However, developer Murray R. Van Luyn faced the challenge of looking for suitable alternatives to the Raspberry Pi during the Broadcom chip shortage. His collaborative efforts with the Armbia
