Ubuntu uses apt-get to build lnmp environment and php extension Installation

Source: Internet
Author: User
Tags imagemagick php website
I have been using the Integrated lnmp installation package to build the lnmp environment. Because I need to install ldap extensions, I cannot find the source code installation package on the Internet. I can only uninstall the original lnmp environment, with ubuntu php5-ldap extension, encountered some problems in the installation, the online article pitfall more, write an article record down. 1. Install mysqlsudoapt

I have been using the Integrated lnmp installation package to build the lnmp environment. Because I need to install ldap extensions, I cannot find the source code installation package on the Internet. I can only uninstall the original lnmp environment, with ubuntu php5-ldap extension, encountered some problems in the installation, the online article pitfall more, write an article record down. 1. Install mysql sudo apt

I have been using the Integrated lnmp installation package to build the lnmp environment. Because I need to install ldap extensions, I cannot find the source code installation package on the Internet. I can only uninstall the original lnmp environment, extended with ubuntu php5-ldap,

I encountered some problems during installation. I had a lot of online articles and wrote articles to record them.

1. Install mysql

sudo apt-get install mysql-server mysql-client
Enter the root user password during installation.

An error occurred while installing mysql-cilent mysql-workbench. The method to completely uninstall the mysql component is as follows:

Delete/var/lib/mysql and/etc/mysql before deleting mysql.

sudo rm /var/lib/mysql/ -Rsudo rm /etc/mysql/ -Rsudo apt-get autoremove mysql* --purgesudo apt-get remove apparmor

Run apt-get install mysql-server mysql-client after deleting all the files.

2. Install nginx

sudo apt-get install nginx

3. After the installation is successful. Restart the nginx service.

sudo service nginx restart 
 

After starting, we can access the following address. See if the nginx welcome page is available.

4. Here we use php5-fpm for our php parsing.

sudo apt-get install php5-fpm 

5. Next, we need to modify the nginx site configuration.

Ngnix configuration files are stored in/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. install some components related to 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. Restart the service

sudo service php5-fpm restart sudo service nginx restart

 

After testing, the installation is successful now.

 

PHP extension installation methods are generally divided into two types:
1. Compile with PHP
2. Generate a separate. so file
The second method is introduced here. The execution efficiency of the second method may be lower, but the modularization means that php can be used without changing the php installation. ini connects to the separately generated so file for extension,
For example, if you have installed php using the tar package, you want to add the following extensions:

Install CURL Extension
I. generate dynamic link library file. SO
The method is as follows:
Method 1. apt-get install php5-curl
Method 2: Go to the PHP website to download the tar package and phpize the local compilation to generate. so
Method 3: Install the program in pear mode. Use the pecl command to download the program and generate. so


Method 1 is the simplest In ubuntu. After the command is executed, the Directory of. so will be notified.

II. Configure php. ini
Open php. ini: Specifies the extension_dir directory. If extension_dir = '/usr/lib', the generated. so file (such as curl. so) copy to the/usr/lib directory and add a new entry:
Extension = curl. so

III. Make it take effect
Restart apache and run phpinfo () to check whether it takes effect.

Install PDO_MYSQL Extension

Install using pear
I. Install pear
Apt-get install php-pear if no pear exists, install pear first.
II. Install pdo and pdo_mysql
Pecl install pdo pecl install pdo_mysql
Generate a. so file and copy it to the/usr/lib directory.

If php and mysql Development Kits are not installed, you need to install
Apt-get install php5-devapt-get install libmysqlclient15-dev
III. modify the configuration file php. ini
Add entry
Extension = pdo. so
Extension = pdo_mysql.so
IV. Make it take effect
Restart apache and run phpinfo () to check whether it takes effect.

In php5.2.10, php has already installed pdo by default. Therefore, extension = pdo. so is not added, but it does not match the pdo_mysql.so generated by itself. The solution is as follows:
Reinstall php, add the parameter -- disable-pdo to disable the pdo module, and generate pdo. so with your own, pdo + mysql. so will be OK.

Install ImageMagic Extension

Install using pear
I. Install ImageMagick
Sudo apt-get install imagemagick

II. Install the lib of imagemagick for php to call
Sudo apt-get install libmagick ++-dev

III. Call the current pecl to install imagick
Pecl install imagick

IV. Modify php. ini. Restart apache server
Add extension = imagick. so to php. ini.


Install phpize

Phpize is the content of php-devel, so you only need to run
Apt-get install php-devel. In ubuntu, apt-get install php-dev is used.

I installed a php5-dev.

After installation, you can use phpize5 to install your own php extensions.

 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.