Showing posts with label Apache. Show all posts
Showing posts with label Apache. Show all posts

Wednesday, 3 August 2016

Ubuntu - Swap between PHP 5.5, 5.6 and 7.0

Hello,

This is tutorial how we can do it:
  1. Install PHP 5.5:
    • sudo apt-get install -y php5
  2. Install PHP 5.6:
    • sudo add-apt-repository ppa:ondrej/php
      • In some case, you will need to change Ubuntu codename in this file:
        • sudo vim /etc/apt/sources.list.d/ondrej-ubuntu-php-xenial.list
    •  sudo apt-get update
    • sudo apt-get install -y php5.6
  3. Install PHP 7.0:
    • sudo apt-get install -y php7.0
  4.   Create symlink in your .bashrc file for quick access:
    • vim ~/.bashrc
    • Apache2:
      • #################################################
        ############### PHP Version Toggle ##############
        #################################################
        # Remove the -q to see debugging information if there are problems
        alias enphp5.5="
         sudo a2dismod php5.6 -q;
         sudo a2dismod php7.0 -q;
         sudo a2enmod php5 -q;
         sudo ln -sf /usr/bin/php5 /usr/bin/php;
         sudo service apache2 restart"
        alias enphp5.6="
         sudo a2dismod php5 -q;
         sudo a2dismod php7.0 -q;
         sudo a2enmod php5.6 -q;
         sudo ln -sf /usr/bin/php5.6 /usr/bin/php;
         sudo service apache2 restart"
        alias enphp7.0="
         sudo a2dismod php5 -q;
         sudo a2dismod php5.6 -q;
         sudo a2enmod php7.0 -q;
         sudo ln -sf /usr/bin/php7.0 /usr/bin/php;
         sudo service apache2 restart"
        
    • Nginx:
      • Remove apache2:
        • sudo service apache2 stop
        • sudo apt-get remove apache2*
        • sudo apt-get purge apache2
      • Install php-fpm for all versions
        • sudo apt-get install php5-fpm
        • sudo apt-get install php5.6-fpm
        • sudo apt-get install php7.0-fpm
      • Stop all php-fpm:
        • sudo service php5-fpm stop
        • sudo service php5.6-fpm stop
        • sudo service php7.0-fpm stop
      • #################################################
        ############### PHP Version Toggle ##############
        #################################################
        # Remove the -q to see debugging information if there are problems
        alias enphp5.5="
         sudo ln -sf /usr/bin/php5 /usr/bin/php;
         sudo service php5.6-fpm stop;
         sudo service php7.0-fpm stop;
         sudo service php5-fpm start;
         sudo find /etc/nginx/sites-available -type f -exec sed -i 's,/run/php/php5.6-fpm.sock,/var/run/php5-fpm.sock,g;s,/run/php/php7.0-fpm.sock,/var/run/php5-fpm.sock,g' {} \;
         sudo service nginx restart"
        alias enphp5.6="
         sudo ln -sf /usr/bin/php5.6 /usr/bin/php;
         sudo service php5-fpm stop;
         sudo service php7.0-fpm stop;
         sudo service php5.6-fpm start;
         sudo find /etc/nginx/sites-available -type f -exec sed -i 's,/var/run/php5-fpm.sock,/run/php/php5.6-fpm.sock,g;s,/run/php/php7.0-fpm.sock,/run/php/php5.6-fpm.sock,g' {} \;
         sudo service nginx restart"
        alias enphp7.0="
         sudo ln -sf /usr/bin/php7.0 /usr/bin/php;
         sudo service php5-fpm stop;
         sudo service php5.6-fpm stop;
         sudo service php7.0-fpm start;
         sudo find /etc/nginx/sites-available -type f -exec sed -i 's,/var/run/php5-fpm.sock,/run/php/php7.0-fpm.sock,g;s,/run/php/php5.6-fpm.sock,/run/php/php7.0-fpm.sock,' {} \;
         sudo service nginx restart"
        
  5. Reload your new .bashrc commands:
    • source ~/.bashrc
  6. Done, now you can try it with:
    • enphp5.5
    • php -v
    • enphp5.6
    • php -v
    • enphp7.0
    • php -v

Good luck!
Source: https://github.com/JREAM/phalcon-xenial

Friday, 29 March 2013

SSL - Installation

Hi,

There are some tutorial how to install SSL in your server:
  1. Lighttpd:
    1. Create ssl folder in your server
    2. Create CSR file in your server: https://developers.google.com/search-appliance/kb/secure/external-ssl
      • Do not using special characters in your information input to your CSR file: # $ % @...
    3. Using the CSR file for buying a SSL service. After buying, you should received 2 or maybe 3 files, download and store it in your ssl folder:
      • Web Server CERTIFICATE: your-site.crt
        • -----BEGIN CERTIFICATE-----
          -----END CERTIFICATE-----
      • INTERMEDIATE CA: intermediate.crt
        • -----BEGIN CERTIFICATE-----
          -----END CERTIFICATE-----
    4. Create your pem file:
      • cat your-site.key your-site.crt > your-site.pem
    5. This is an example config file:
      • $HTTP["host"] == "your-site" {
            server.document-root = "/path/to/your/project"

            $SERVER["socket"] == ":443" {
                ssl.engine  = "enable"
                ssl.pemfile = "/path/to/your/pem/file"
                ssl.ca-file = "/path/to/your/intermediate/file"
            }
        }
    6. Auto redirect all site to HTTPS:
      • $SERVER["socket"] == ":80" {
            $HTTP["host"] =~ "(.*)" {
                url.redirect = ( "^/(.*)" => "https://%1/$1" )
            }
        }
    7. Restart Webserver and test in your browser: https://your-site
      • Amazon Server: you must enable security group HTTPS first
  2. Apache:

Good luck!

Friday, 1 March 2013

MacPorts - PHP, Apache & MySQL

Hi,

These some tutorials how to install lamp server using MarPorts:
  1. Install MacPorts:
    1. Install Xcode
    2. Launch Xcode > Preferences > Downloads > Install 'Command Line Tools'
    3. Go to MacPorts website and follow their structure to install MacPorts: http://www.macports.org/install.php
  2. Install PHP & Apache:
    1. sudo port install php5 +apache2 +mcrypt +curl +tidy +pear
    2. sudo port load apache2
    3. cd /opt/local/apache2/modules
    4. sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
    5. sudo cp /opt/local/etc/php5/php.ini-development /opt/local/etc/php5/php.ini
    6. sudo nano /opt/local/apache2/conf/httpd.conf
      1. Go to line 119 (In Nano: CTRL+w then CTRL+t and write 119), and enter the following lines:
        • AddType application/x-httpd-php .php
        • AddType application/x-httpd-php-source .phps
    7. Now, change DocumentRoot from:
      1. From: DocumentRoot "/opt/local/apache2/htdocs"
      2. To: DocumentRoot "/Users/Shin/sites"
    8. Since we just change the documentRoot folder, we need to adjust some more settings
      1. From: <Directory “/opt/local/apache2/htdocs”>
      2. To: <Directory “/Users/Shin/Sites”>
    9. Now all we have left to do is setting the User and Group. Exchange the following:
      1. From:
        • User www
        • Group www
      2. To:
        • User Shin
        • Group staff
    10. sudo /opt/local/apache2/bin/apachectl restart
  3. Install MySQL:
    1. sudo port install mysql5 +server
    2. sudo -u mysql mysql_install_db5
    3. sudo chown -R mysql:mysql /opt/local/var/db/mysql5/
    4. sudo chown -R mysql:mysql /opt/local/var/run/mysql5/
    5. sudo chown -R mysql:mysql /opt/local/var/log/mysql5/
      • If that doesn’t work try this:
        • sudo mysql_install_db5 sudo chown -R mysql:mysql /opt/local/var/db/mysql5/
        • sudo chown -R mysql:mysql /opt/local/var/run/mysql5/
    6. sudo port load mysql5-server
    7. sudo ln -s /opt/local/bin/mysql5 /opt/local/bin/mysql
    8. sudo ln -s /opt/local/bin/mysqladmin5 /opt/local/bin/mysqladmin
    9. Change new root password:
      • mysqladmin5 -u root password 'new-password'
  4. Some small bugs:
    1. httpd: Could not reliably determine the server's fully qualified domain name, using <Computer-Name>.local for ServerName
      1. sudo vim /opt/local/apache2/conf/httpd.conf
        • ServerName localhost:80
    2. If you would like to be able to access web pages in the Sites directory of your home directory
      1. sudo vim /opt/local/apache2/conf/httpd.conf
        • Include conf/extra/httpd-userdir.conf
    3. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
      1. sudo vim /opt/local/etc/mysql5/my.cnf
        • [mysqld_safe]
        • socket = /tmp/mysql.sock
        • [client]
        • socket = /tmp/mysql.sock
      2. sudo vim /opt/local/etc/php5/php.ini 
        • mysqli.default_socket = "/tmp/mysql.sock"
Good luck!

Friday, 14 October 2011

PHP, Apache & MySQL

Hi,

There are some tutorials active Webserver environment:
  1. Apache:
    1. Root folder: /Library/WebServer/Documents/
    2. Start: sudo apachectl start
    3. Stop: sudo apachectl stop
    4. Restart: sudo apachectl graceful
  2. PHP:
    1. Install:
      1. cd /etc && sudo cp php.ini.default php.ini
      2. sudo vim httpd.conf
      3. Uncomment out the hash # to leave it like:
        • LoadModule php5_module libexec/apache2/libphp5.so
      4. Restart Apache
    2. Warning: date_default_timezone_get():
      • sudo vim /private/etc/php.ini
      • date.timezone = "UTC"
    3. autoconf:
      1. Install:
        • Install Xcode
        • Launch Xcode > Preferences > Downloads > Install 'Command Line Tools'
      2. Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.
        • curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
        • tar xvfz autoconf-latest.tar.gz
        • cd autoconf-2.69/
        • ./configure
        • make
        • sudo make install
    4. Missing extension:
      • http://www.coolestguyplanettech.com/how-to-install-mcrypt-for-php-on-mac-osx-lion-10-7-development-server/
      • Download the PHP's source code. You'll need to download the one that matches the version already installed on your system. To find out which one you're using, type php -v from the command line.
      • Extract the archive you downloaded using tar -zxvf followed by the filename. Type cd php-5.4.x/ext/sqlite3/ (where "5.4.x" should be replaced with your version number and "sqlite3" can be any of the modules you want to install from your list above minus the "php_" prefix)
      • Type phpize
      • Type ./configure
      • Type make
      • Type sudo make install
      • Find shared extenstions folder:
        • E.G.: /usr/lib/php/extensions/no-debug-non-zts-20090626/
      • Add extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20090626" to your php.ini
      • Add extension=sqlite3.so to your php.ini (again make sure to replace sqlite3.so with the name of the other extensions if you compile the others).
      • Restart Apache
    5. Or you can try this tutorials:
      • http://php-osx.liip.ch/
  3. MySQL:
    1. Install:
      • Go to: http://dev.mysql.com/downloads/mysql/
      • Download DMG file for your current operation: Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive
      • Open the downloaded file and double click the file called mysql-x.x.xx-osx10.x-x86_64.pkg and continue through the installation
        • App can’t be opened because it is from an unidentified developer: http://osxdaily.com/2012/07/27/app-cant-be-opened-because-it-is-from-an-unidentified-developer/
      • Installation: MySQL.prefPane, MySQLStartupItem.pkg
    2. Enable command line:
      • sudo vim /etc/paths
      • Appended the line:
        • /usr/local/mysql/bin
      • Restart OS
    3. Missing /var/mysql/mysql.sock file:
      • Check it at:
        • /private/tmp/mysql.sock
        • /tmp/mysql.sock
        • /usr/local/mysql/run/mysql_socket
      • Try create symbolic link for: /var/mysql/mysql.sock
        • sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock
        • sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
        • sudo ln -s /usr/local/mysql/run/mysql_socket /var/mysql/mysql.sock
    4. Reference:
      • http://blog.mclaughlinsoftware.com/2011/02/10/mac-os-x-mysql-install/
Good luck!