v
一直是在用的lnmp的集成安装包搭建lnmp环境,因为工作需要需要安装ldap扩展,在网上怎么都找不到源码安装包,只能卸载掉原来的lnmp环境,用ubuntu的php5-ldap扩展,
在安装中遇到一些问题,网上的文章坑爹的比较多,写篇文章记录下来。
1.安装MySQL
- sudo apt-get install mysql-server mysql-client
安装过程中要输入root用户的密码。
我在安装中出错,是原来的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*
- 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 style="font-size: 16px; font-family: ‘Microsoft Yahei‘, Arial, Helvetica, sans-serif;"> </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
一直是在用的lnmp的集成安装包搭建lnmp环境,因为工作需要需要安装ldap扩展,在网上怎么都找不到源码安装包,只能卸载掉原来的lnmp环境,用ubuntu的php5-ldap扩展,
在安装中遇到一些问题,网上的文章坑爹的比较多,写篇文章记录下来。
1.安装MySQL
- sudo apt-get install mysql-server mysql-client
安装过程中要输入root用户的密码。
我在安装中出错,是原来的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*
- 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 style="font-size: 16px; font-family: ‘Microsoft Yahei‘, Arial, Helvetica, sans-serif;"> </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
ubuntu通过apt-get方式搭建lnmp环境以及php扩展安装
原文:http://www.cnblogs.com/php-linux/p/5416514.html